npm install object-agent
Requires Babel 7.2+
- deepEqual(item1, item2) ⇒
Deeply compares two items.
- diffUpdate(object1, object2) ⇒
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) ⇒
Tests if an object or array has any set keys. The values of each key are not considered.
- isEqual() ⇒
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.
- combo(array, [length]) ⇒
Takes a set of values and creates an array of the unique sets of the values of a given length.
- mix(args) ⇒
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) ⇒
Create a power set from a set of values
- clone(value, [settings]) ⇒
Deep clone a value.
- erase(object, key) ⇒
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() ⇒
Performs a deep comparison of objects and returns a new object of values that are equal in all given objects.
- set(object, path, value) ⇒
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.
- Undefined values will not overwrite defined values
- Array order is maintained
- unset(object, path) ⇒
Deletes a property from a nested object.
- countInString(string, match) ⇒
Counts the number of instances of a string within another string
- fill(length, [callback]) ⇒
Returns an array of specified length filled with either the index value or the value returned from the provided callback
- forIn(object, callback) ⇒
Iterates over own and inherited properties of an object. Stops iterating as soon as the callback returns a truthy value.
- forOwn(object, callback) ⇒
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]) ⇒
Builds a new object by iterating over own properties of an object.
- nestedEach(arrays, callback, [accrue]) ⇒
Iterate over the values of multiple arrays
- pull(array, path) ⇒
Pulls values from an array of objects into a new array.
- repeat(times, callback) ⇒
Calls a callback a specified number of times
- traverse(object, callback, [isOptimistic]) ⇒
Traverses a nested object. Circular objects are only traversed once.
- appendToPath(path, key, [separator]) ⇒
Adds a key to the end of a path
- firstInPath(path, [separator]) ⇒
Returns the first key in a path
- initialInPath(path, [separator]) ⇒
Returns the path without the last key
- lastInPath(path, [separator]) ⇒
Returns the last key in a path
- tailInPath(path, [separator]) ⇒
Returns the path without the first key
- walkPath(path, callback, [separator]) ⇒
Calls a callback for every key in a path. If true is returned from the callback then no further calls will be made.