Skip to main content
Home

Built and signed on GitHub Actions

Works with
This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score100%
Publisheda year ago (0.3.0)

TypeScript types and predicate `isPlainObject` and `isPlainObjectValue`, which are serializable POJOs.

@plandek-utils/plain-object

JSR Scope JSR JSR Score Maintainability Test Coverage

TypeScript types and predicate utils isPlainObject and isPlainObjectValue.

A PlainObject is a POJO where all values are PlainObjectValue.

A PlainObjectValue is one of:

  • null or undefined
  • 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 files
  • deno lint: lint files
  • deno dev: run tests on each change in mod.ts
  • deno run test && deno run lcov && deno run html: run the tests with coverage, then convert to lcov and prepare in html_cov an 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)

Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@plandek-utils/plain-object

Import symbol

import * as plain_object from "@plandek-utils/plain-object";
or

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
or (using pnpm 10.8 or older)
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
or (using Yarn 4.8 or older)
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";