help-object v0.1.0
help-object
Small js package I use to help me dealing with objects
Install
$ npm install help-object
Import
This package is pure ESM. It cannot be require()
'd from CommonJS.
Use import foo from 'foo'
instead of const foo = require('foo')
to import the package.
// Load entire build
import * as helpObject from 'help-object';
// Load by method
import {main} from 'help-object';
If the package is used in an async context, you could use await import(…)
from CommonJS instead of require(…)
.
You also need to make sure you're on the latest minor version of Node.js. At minimum Node.js 12.20, 14.14, or 16.0.
Read more here: sindresorhus/esm-package
Usage
const object = { 'a': { 'b': 2 } }
const other = create({ 'a': create({ 'b': 2 }) })
helpObject.has(object, 'a')
// => true
helpObject.has(other, 'a')
// => false
forEachEntry
: The function will be called with (key
, value
) as arguments.
functions
: Creates an array of function property names from own enumerable properties of object
.
has
: Checks if key
is a direct property of object
.
invert
: Creates an object composed of the inverted keys and values of object
.
invertBy
: This method is like invert
except that the inverted object is generated from the results of running each element of object
thru iteratee
.
keysIn
: Creates an array of the own and inherited enumerable property names of object
.
mapKey
: The opposite of mapValue
this method creates an object with the same values as object
and keys generated by running each own enumerable string keyed property of object
thru iteratee
.
mapObj
: Creates an array of values by running each property of object
thru iteratee
.
mapValue
: Creates an object with the same keys as object
and values generated by running each own enumerable string keyed property of object
thru iteratee
.
toPlainObject
: Converts value
to a plain object flattening inherited enumerable string keyed properties of value
to own properties of the plain object.
License
MIT © Paul Nodet
3 years ago