Nondeterministic Programming Methodology
Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

object-agent

1.4.12 • Public • Published

Object Agent

A javascript library for working with objects

npm build coverage deps size vulnerabilities license


Installation

npm install object-agent

Requires Babel 7.2+


Functions

Comparison Functions

deepEqual(item1, item2)Boolean

Deeply compares two items.

diffUpdate(object1, object2)Object

Performs a deep comparison of two objects, returns a new object with only the first level values that have been changed or added on the second object

isEmpty(item)Boolean

Tests if an object or array has any set keys. The values of each key are not considered.

isEqual()Boolean

Shallow compares two or more items. All items are compared with SameValue equality except Dates and RegExps which compare their values with SameValue equality, Objects and Arrays which compare key lengths, and instances of objects that compare all properties and prototype objects.

Data Generation Functions

combo(array, [length])array

Takes a set of values and creates an array of the unique sets of the values of a given length.

mix(args)Array

Mix the contents of multiple arrays into a nested array where all variations of one item from each array is in each of the nested arrays.

powerset(input)array

Create a power set from a set of values

Interaction Functions

clone(value, [settings])*

Deep clone a value.

erase(object, key)boolean

Deletes a property from an object, if the property exists.

get(object, path)*

Gets a nested value from an object.

has(object, path)*

Determines if a nested value is defined

intersection()Object

Performs a deep comparison of objects and returns a new object of values that are equal in all given objects.

set(object, path, value)Object

Sets a nested value in an object. Keys in the path that don't exist at any point in the object will be created and added to the object once.

superimpose(args, [mutateFirst])*

Deeply superimposes two or more items on each other.

Notes:

  • Undefined values will not overwrite defined values
  • Array order is maintained
unset(object, path)Object

Deletes a property from a nested object.

countInString(string, match)Number

Counts the number of instances of a string within another string

Iteration Functions

fill(length, [callback])Array

Returns an array of specified length filled with either the index value or the value returned from the provided callback

forIn(object, callback)Boolean

Iterates over own and inherited properties of an object. Stops iterating as soon as the callback returns a truthy value.

forOwn(object, callback)Boolean

Iterates over own properties of an object. Stops iterating as soon as the callback returns a truthy value.

forOwnReduce(object, callback, initialValue)*

Iterates over own properties of an object and returns a reduced value

mapOwn(object, callback, [ignoreKeys])Object | *

Builds a new object by iterating over own properties of an object.

nestedEach(arrays, callback, [accrue])array

Iterate over the values of multiple arrays

pull(array, path)Array

Pulls values from an array of objects into a new array.

repeat(times, callback)Array

Calls a callback a specified number of times

traverse(object, callback, [isOptimistic])Boolean

Traverses a nested object. Circular objects are only traversed once.

Path Utility Functions

appendToPath(path, key, [separator])String

Adds a key to the end of a path

firstInPath(path, [separator])String

Returns the first key in a path

initialInPath(path, [separator])String

Returns the path without the last key

lastInPath(path, [separator])String

Returns the last key in a path

tailInPath(path, [separator])String

Returns the path without the first key

walkPath(path, callback, [separator])String

Calls a callback for every key in a path. If true is returned from the callback then no further calls will be made.

Install

npm i object-agent

DownloadsWeekly Downloads

361

Version

1.4.12

License

MIT

Unpacked Size

50.9 kB

Total Files

39

Last publish

Collaborators

  • avatar