Package detail

util-array-object-or-both

codsen1.3kMIT5.0.14

Validate and normalise user choice: array, object or both?

array, both, choice, normalise

readme

util-array-object-or-both

Validate and normalise user choice: array, object or both?

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, 3.1.0 (npm i util-array-object-or-both@3.1.0).

npm i util-array-object-or-both

Quick Take

import { strict as assert } from "assert";

import { arrObjOrBoth } from "util-array-object-or-both";

// normalises string, a user preference:

assert.equal(arrObjOrBoth("arrays"), "array");
assert.equal(arrObjOrBoth("array"), "array");
assert.equal(arrObjOrBoth("arr"), "array");
assert.equal(arrObjOrBoth("a"), "array");

assert.equal(arrObjOrBoth("objects"), "object");
assert.equal(arrObjOrBoth("object"), "object");
assert.equal(arrObjOrBoth("obj"), "object");
assert.equal(arrObjOrBoth("o"), "object");

assert.equal(arrObjOrBoth("whatever"), "any");
assert.equal(arrObjOrBoth("either"), "any");
assert.equal(arrObjOrBoth("both"), "any");
assert.equal(arrObjOrBoth("any"), "any");
assert.equal(arrObjOrBoth("all"), "any");
assert.equal(arrObjOrBoth("e"), "any");

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

changelog

Change Log

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

5.0.0 (2022-12-01)

BREAKING CHANGES

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

4.2.0 (2022-08-12)

Features

4.1.2 (2022-04-18)

Fixed

4.1.0 (2022-04-10)

Features

  • export defaults and version (1107244)

4.0.0 (2021-09-09)

Features

BREAKING CHANGES

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

3.1.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

3.0.15 (2021-04-11)

Reverts

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

3.0.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

3.0.0 (2021-01-23)

Features

  • rewrite in TS and start using named exports (e97fcc8)

BREAKING CHANGES

  • previously: import arrObjOrBoth from ... - now import { arrObjOrBoth } from ...

2.7.58 (2020-04-26)

Fixed

  • harden the eslint rules set and make all unit tests pass (8821ee5)

2.7.44 (2019-10-02)

Performance Improvements

  • remove check-types-mini for around 500x speed improvement (4f69441)

2.7.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.3.0 (2018-10-26)

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

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-25)

  • Set up Prettier on a custom ESLint rule set.
  • Remove 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 — there's no need to comment-out console.log statements or care about them not spilling into production. Now it's done automatically.
  • Unit tests are pointing at ES modules build, which means that code coverage is correct now, without Babel functions being missed. This is important because now code coverage is real again and now there are no excuses not to perfect it.

2.0.0 (2017-12-13)

  • Rebased in ES Modules
  • Set up Rollup. Now we serve three builds: CommonJS, UMD and ES Module.

1.2.0 (2017-09-20)

  • 💥 Dropped JS Standard and switched to raw ESLint on airbnb-base preset. Of course, with overrides to ban semicolons and allow plus-plus in loops.

1.1.0 (2017-08-09)

  • 💥 Replaced object-assign with native ES6 Object.assign
  • 💥 We don't need lodash.clonedeep either, we can just Object.assign onto a empty object literal because Object.assign sources are not mutated.

1.0.0 (2017-06-13)

  • First public release