包详细信息

object-boolean-combinations

codsen192.4kMIT6.1.8

Consumes a defaults object with booleans, generates all possible variations of it

all, array, boolean, combinations

自述文件

object-boolean-combinations

Consumes a defaults object with booleans, generates all possible variations of it

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, 4.1.0 (npm i object-boolean-combinations@4.1.0).

npm i object-boolean-combinations

Quick Take

import { strict as assert } from "assert";

import { combinations } from "object-boolean-combinations";

assert.deepEqual(
  combinations({
    a: true,
    b: false,
    c: true,
  }),
  [
    { a: false, b: false, c: false },
    { a: true, b: false, c: false },
    { a: false, b: true, c: false },
    { a: true, b: true, c: false },
    { a: false, b: false, c: true },
    { a: true, b: false, c: true },
    { a: false, b: true, c: true },
    { a: true, b: true, c: true },
  ],
);
// you get 2^n plain objects in an array

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

更新日志

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

6.1.0 (2023-05-13)

Features

  • correct the type definitions (7dd8452)

6.0.0 (2022-12-01)

BREAKING CHANGES

  • Minimum supported Node version is v14.18; we're dropping v12 support

5.1.0 (2022-08-12)

Features

5.0.0 (2021-09-09)

Features

BREAKING CHANGES

  • programs now are in ES Modules and won't work with Common JS require()

4.1.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

4.0.15 (2021-04-11)

Reverts

  • Revert "chore: setup refresh" (23cf206)

4.0.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

4.0.0 (2021-01-23)

Features

  • recode in TS and start using named exports (75d5dc0)

BREAKING CHANGES

  • previously default was exported: import combinations from ... - now use named export import { combinations } from ...

3.0.0 (2020-12-06)

BREAKING CHANGES

  • now all combinations' values are booleans, no more digits 0 or 1 (dbb2f05). Type safety, you know.

2.12.0 (2020-11-28)

Accidental version bump during migration to SourceHut. Sorry about that.

2.11.0 (2019-01-20)

  • Various documentation and setup tweaks after we migrated to monorepo
  • Setup refresh: updated dependencies and all config files using automated tools

2.5.0 (2018-12-26)

  • Allow any types in override object key values (af4f99d)

2.4.0 (2018-10-24)

  • Updated all dependencies
  • Restored coveralls.io reporting
  • Restored unit test linting

2.3.0 (2018-07-25)

  • Allow override object key values to be of any type
  • Small improvements to the setup

2.2.0 (2018-06-16)

GitHub sold us out. In the meantime, we:

  • Migrated to Bitbucket (to host repo + perform CI) and Codacy (for code quality audit)
  • Dropped BitHound (RIP) and Travis

2.1.0 (2018-05-17)

Changes

  • Set up Prettier on a custom ESLint rules, dropped airbnb-base
  • Removed package.lock and .editorconfig
  • Wired Rollup to remove comments from non-dev builds. This means we can now leave the console.logs in the source code — Rollup will remove from production code.
  • Now unit tests are pointing at ES modules build, which means that code coverage is correct now, without Babel functions being missed

2.0.0 (2017-12-12)

Changes

  • Rebased the source in ES Modules
  • Set up Rollup and now we are generating three builds: CommonJS, UMD and ES Modules (native code).
  • Small tweaks to the code, no changes to the API.

PS. Bumping the major version just in case it breaks something. But it should not.