@visulima/object
v1.0.6
Published
Helper functions for working with objects and arrays.
Downloads
14
Maintainers
Readme
is-plain-obj, dot-prop, deeks and type-fest
Install
npm install @visulima/object
yarn add @visulima/object
pnpm add @visulima/object
Usage
deleteProperty
escapePath
getProperty
hasProperty
setProperty
deepKeys
deepKeysFromList
isPlainObject
pick
With pick
you pass an object and an array of keys of an object - the props which may stay.
import { pick } from "@visulima/object";
const squirtle = { id: "007", name: "Squirtle", type: "water" };
const newObject = pick(squirtle, ["name", "type"]);
// returns { name: 'Squirtle', type: 'water' }
const doc = { items: { keep: "📌", discard: "✂️" } };
pick(doc, ["items.keep"]);
// returns {items: {keep: '📌'}}
omit
With omit
you pass an object and an array of keys of an object - the props which should be removed.
import { omit } from "@visulima/object";
const squirtle = { id: "007", name: "Squirtle", type: "water" };
const withoutId = omit(squirtle, ["id"]);
// returns { name: 'Squirtle', type: 'water' }
const doc = { items: { keep: "📌", discard: "✂️" } };
omit(doc, ["items.discard"]);
// returns {items: {keep: '📌'}}
Related
- is-plain-object - Returns true if the given value is an object created by the Object constructor.
- is-plain-obj - Check if a value is a plain object.
- dot-prop - Get, set, or delete a property from a nested object using a dot path.
- ts-dot-prop - TypeScript utility to transform nested objects using a dot notation path.
- dset - A tiny (194B) utility for safely writing deep Object values~!
- filter-anything - A simple (TypeScript) integration of "pick" and "omit" to filter props of an object.
Supported Node.js Versions
Libraries in this ecosystem make the best effort to track Node.js’ release schedule. Here’s a post on why we think this is important.
Contributing
If you would like to help take a look at the list of issues and check our Contributing guidelines.
Note: please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Credits
License
The visulima object is open-sourced software licensed under the MIT