Detalhes do pacote

object-delete-key

codsen895MIT4.0.29

Delete keys from all arrays or plain objects, nested within anything, by key or by value or by both, and clean up afterwards. Accepts wildcards.

ast, by, delete, drop

readme (leia-me)

object-delete-key

Delete keys from all arrays or plain objects, nested within anything, by key or by value or by both, and clean up afterwards. Accepts wildcards.

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-delete-key@2.1.0).

npm i object-delete-key

Quick Take

import { strict as assert } from "assert";

import { deleteKey } from "object-delete-key";

// deleting key 'c', with value 'd'
assert.deepEqual(
  deleteKey(
    {
      a: "b",
      c: "d",
    },
    {
      key: "c",
      val: "d",
    },
  ),
  { a: "b" },
);

// deleting key 'b' with value - array ['c', 'd']
assert.deepEqual(
  deleteKey(
    {
      a: { e: [{ b: ["c", "d"] }] },
      b: ["c", "d"],
    },
    {
      key: "b",
      val: ["c", "d"],
    },
  ),
  {},
);
// notice program cleaned after itself, it didn't leave empty "a" key

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 (log de mudanças)

Change Log

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

4.0.0 (2022-12-01)

BREAKING CHANGES

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

3.2.0 (2022-08-12)

Features

3.1.3 (2022-04-18)

Fixed

3.1.0 (2022-04-10)

Features

3.0.0 (2021-09-09)

Features

BREAKING CHANGES

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

2.1.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

2.0.16 (2021-04-14)

Fixed

  • correctly treat non-JSON data structures with undefined as a value (bf1454a), closes #8

2.0.15 (2021-04-11)

Reverts

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

2.0.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

2.0.0 (2021-01-23)

Features

  • rewrite in TS, start using named exports (d72dde6)

BREAKING CHANGES

  • previously you'd consume like: import deleteKey from ... - now: import { deleteKey } from ...

1.10.0 (2020-11-28)

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

1.9.0 (2019-10-02)

Features

  • make program run faster by removing options validation (9d8cef6)

1.8.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

1.5.0 (2018-10-24)

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

1.4.0 (2018-06-19)

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

1.3.0 (2018-05-25)

  • Set up Prettier on a custom ESLint rule set.
  • 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 — 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.

1.2.0 (2018-03-11)

  • Updated all dependencies
  • Switched from deprecated posthtml-ast-is-empty to ast-is-empty (npm, GitLab)

1.1.0 (2017-10-30)

  • Now accepts globs everywhere, see matcher's API which is driving the globbing. This comes from ast-monkey (npm, GitLab) tapping matcher.

1.0.0 (2017-10-23)

  • First public release