Package Exports
- object-agent
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (object-agent) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Object Agent
A javascript library for working with objects
Installation
npm install object-agent
Requires Babel 7.2+
Functions
- clone(value, [settings]) ⇒
*
Deep clone a value.
- combo(array, [length]) ⇒
array
Takes a set of values and creates an array of the unique sets of the values of a given length.
- 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
- erase(object, key) ⇒
boolean
Deletes a property from an object, if the property exists.
- 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
- 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.
- 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.
- mapOwn(object, callback, [ignoreKeys]) ⇒
Object
|*
Builds a new object by iterating over own properties of an object.
- 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.
- nestedEach(arrays, callback, [accrue]) ⇒
array
Iterate over the values of multiple arrays
- powerset(input) ⇒
array
Create a power set from a set of values
- 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
- 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
- traverse(object, callback, [isOptimistic]) ⇒
Boolean
Traverses a nested object. Circular objects are only traversed once.
- unset(object, path) ⇒
Object
Deletes a property from a nested object.
- appendToPath(path, key, [separator]) ⇒
String
Adds a key to the end of a path
- countInString(string, match) ⇒
Number
Counts the number of instances of a string within another string
- 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.