object-all-values-equal-to
TypeScript icon, indicating that this package has built-in type declarations

4.0.21 • Public • Published

object-all-values-equal-to

Does the AST/nested-plain-object/array/whatever contain only one kind of value?

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 2.1.0 (npm i object-all-values-equal-to@2.1.0).

npm i object-all-values-equal-to

Quick Take

import { strict as assert } from "assert";

import { allEq } from "object-all-values-equal-to";

// are all values equal to null:
assert.equal(allEq({ a: null, c: null }, null), true);
// yes

// are all values equal to "false":
assert.equal(allEq({ a: false, c: "zzz" }, false), false);
// no

// are all values equal to "false"?
assert.equal(
  allEq(
    {
      a: {
        b: false,
        c: [
          {
            d: false,
            e: false,
          },
          {
            g: false,
          },
        ],
      },
      c: false,
    },
    false, // reference value to check
  ),
  true, // answer is, yes
);

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2025 Roy Revelt and other contributors.

ok codsen star

/object-all-values-equal-to/

    Package Sidebar

    Install

    npm i object-all-values-equal-to

    Weekly Downloads

    113

    Version

    4.0.21

    License

    MIT

    Unpacked Size

    29.5 kB

    Total Files

    7

    Last publish

    Collaborators

    • royston