@plandek-utils/plain-object@0.3.0Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
TypeScript types and predicate `isPlainObject` and `isPlainObjectValue`, which are serializable POJOs.
@plandek-utils/plain-object
TypeScript types and predicate utils isPlainObject and isPlainObjectValue.
A PlainObject is a POJO where all values are PlainObjectValue.
A PlainObjectValue is one of:
nullorundefined- Finite number (no NaN or Infinite)
- String
- Boolean
- Dayjs
- Array of PlainObjectValue
- PlainObject
Usage
import { isPlainObject, isPlainObjectValue } from "@plandek-utils/plain-object"; isPlainObjectValue(null); // => true isPlainObjectValue(undefined); // => true isPlainObjectValue(1); // => true isPlainObjectValue(Infinite); // => false isPlainObjectValue(NaN); // => false isPlainObjectValue("something"); // => true isPlainObjectValue(true); // => true isPlainObjectValue(false); // => true isPlainObjectValue([]); // => true isPlainObjectValue([1, 2]); // => true isPlainObjectValue([1, "something", 2]); // => true isPlainObjectValue([1, "something", [2, 3]]); // => true isPlainObjectValue(() => "oh no"); // => false isPlainObjectValue({ a: 1, b: "stuff", c: [1], d: {}, e: { e1: true } }); // => true isPlainObjectValue({ a: 1, b: "stuff", c: [1], d: {}, e: { e1: () => "oh no" } }); // => false isPlainObject(null); // => false isPlainObject(undefined); // => false isPlainObject(1); // => false isPlainObject(Infinite); // => false isPlainObject(NaN); // => false isPlainObject("something"); // => false isPlainObject(true); // => false isPlainObject(false); // => false isPlainObject([]); // => false isPlainObject([1, 2]); // => false isPlainObject([1, "something", 2]); // => false isPlainObject([1, "something", [2, 3]]); // => false isPlainObject(() => "oh no"); // => false isPlainObject({ a: 1, b: "stuff", c: [1], d: {}, e: { e1: true } }); // => true isPlainObject({ a: 1, b: "stuff", c: [1], d: {}, e: { e1: () => "oh no" } }); // => false
Development
This package is developed with deno 2. The production code is in src/mod.ts and its test in
src/__tests__/mod.spec.ts
deno fmt: format filesdeno lint: lint filesdeno dev: run tests on each change in mod.tsdeno run test && deno run lcov && deno run html: run the tests with coverage, then convert to lcov and prepare inhtml_covan HTML export of the coverage info.
TypeScript types and predicate isPlainObject and isPlainObjectValue. PlainObject = POJO where all values are
PlainObjectValue. PlainObjectValue = serializable value (Dayjs, nil, number, string, boolean, PlainObjectValue[],
PlainObject)
Add Package
deno add jsr:@plandek-utils/plain-object
Import symbol
import * as plain_object from "@plandek-utils/plain-object";
Import directly with a jsr specifier
import * as plain_object from "jsr:@plandek-utils/plain-object";
Add Package
pnpm i jsr:@plandek-utils/plain-object
pnpm dlx jsr add @plandek-utils/plain-object
Import symbol
import * as plain_object from "@plandek-utils/plain-object";
Add Package
yarn add jsr:@plandek-utils/plain-object
yarn dlx jsr add @plandek-utils/plain-object
Import symbol
import * as plain_object from "@plandek-utils/plain-object";
Add Package
vlt install jsr:@plandek-utils/plain-object
Import symbol
import * as plain_object from "@plandek-utils/plain-object";
Add Package
npx jsr add @plandek-utils/plain-object
Import symbol
import * as plain_object from "@plandek-utils/plain-object";
Add Package
bunx jsr add @plandek-utils/plain-object
Import symbol
import * as plain_object from "@plandek-utils/plain-object";