Object

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

Members

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

Methods

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

Members

(inner, constant) hashObj

Description:
  • Creates a consistent hash string from the passed in object
    Not intended to be secure
    Given the same input keys and values, it will always return the same output hash

Source:

Creates a consistent hash string from the passed in object
Not intended to be secure
Given the same input keys and values, it will always return the same output hash

(inner, constant) transformKeys

Description:
  • Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Source:

Transforms the keys of an object to a matching key value in keyMap object Keys not in the keyMap are included as is, unless strict === true option is passed

Examples
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}) === { myKey: `1234`, other_key: `4321` }
const opts = { strict: true }
transformKeys({my_key: `1234`, other_key: `4321`}, {my_key: `myKey`}, opts) === { myKey: `1234` }

Methods

(inner) applyToCloneOf(obj, mutatorCb) → {Object|Array}

Description:
  • Deep clones Object obj, then returns the result of calling function mutatorCb with the clone as its argument

Source:
Example
const obj = {}
const clone = applyToCloneOf(obj, (clone) => { clone.test = 'foo'; return clone })
console.log(obj === clone) // prints false
console.log(clone.test === 'foo') // prints true
Parameters:
Name Type Description
obj Object

object

mutatorCb function

a callback that accepts one argument, the cloned obj, and mutates it in some way

Returns:

the mutated clone

Type
Object | Array

(inner) clearObj(obj, filteropt) → {void}

Description:
  • Removes all properties from an object.

Source:
Parameters:
Name Type Attributes Description
obj Object

object to remove properties from

filter Array <optional>

list of keys to not remove

Returns:
Type
void

(inner) cloneJson(obj) → {Object}

Description:
  • Clones an object by converting to JSON string and back.

Source:
Parameters:
Name Type Description
obj Object

object to clone

Returns:

copy of original object

Type
Object

(inner) deepFreeze(obj) → {Object}

Description:
  • Recursively freezes and object.

Source:
Parameters:
Name Type Description
obj Object
Returns:
  • frozen Object
Type
Object

(inner) deepMerge(sources) → {Object|Array}

Description:
  • Deep merges an array of objects together.

Source:
Parameters:
Name Type Description
sources Array

array of objects to join

Returns:
  • merged object or array
Type
Object | Array

(inner) eitherObj(obj1, obj2) → {Object}

Description:
  • Returns the first param if correct type of second param.

Source:
Parameters:
Name Type Description
obj1 Object

return if is object

obj2 Object

use if first is not an object

Returns:
Type
Object

(inner) everyEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "every" for arrays, but operates across each entry in an object

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to the it's entries iterated on

predicate function

Function of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Boolean indicating that every entry satisfied the predicate or not
Type
Boolean

(inner) filterObj(obj, predicate, logErroropt) → {Object}

Description:
  • Returns a new object, consisting of every key-value pair from obj that, when passed into the predicate, returned true

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object that should have it's properties filtered

predicate function

function of form: (key, value) => Boolean

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • Object consisting of a subset of the entries from obj
Type
Object

(inner) hasOwn(obj, prop) → {Boolean}

Description:
  • Checks if prop exists on the object.

Source:
Parameters:
Name Type Description
obj Object

data to check

prop String

prop to check for

Returns:

T/F if the prop exists

Type
Boolean

(inner) isArrMap(obj) → {Boolean}

Description:
  • Returns true if the input is an object and every value is an array

Source:
Parameters:
Name Type Description
obj Object | *

data to check

Returns:
  • true if input is an array map
Type
Boolean

(inner) isEntry(maybeEntry) → {Boolean}

Description:
  • Checks if the input is a valid entry - a 2-element array, like what Object.entries produces. Expects the first element in the entry to be either a string or a number.

Source:
Examples
isEntry([1, 2]) // true
isEntry(["id", 87]) // true
isEntry([new Date(), 2]) // false, first element not string or number
isEntry([1, 2, 3]) // false, too many elements
Parameters:
Name Type Description
maybeEntry *

Item to check if it's an entry

Returns:
  • True if it is an entry, false otherwise
Type
Boolean

(inner) isObj(obj) → {Boolean}

Description:
  • Checks if data is an object and not an array.

Source:
Parameters:
Name Type Description
obj Object

data to check

Returns:
Type
Boolean

(inner) jsonEqual(one, two) → {Boolean}

Description:
  • Compares two objects by converting to JSON, and checking string equality.

Source:
Parameters:
Name Type Description
one object | array

object to compare with param two

two object | array

object to compare with param one

Returns:

status of equality

Type
Boolean

(inner) keyMap(arr, toUpperCase) → {Object}

Description:
  • Converts an array of strings to a matching key/value pair object.

Source:
Parameters:
Name Type Description
arr Array

to be converted to object

toUpperCase Boolean

converts the key and value to uppercase

Returns:

built object

Type
Object

(inner) mapEntries(obj, cb) → {Object}

Description:
  • Returns a new object, each entry of which is the result of applying the cb function to input's corresponding entry

Source:
Examples
mapObj({a: 2, b: 3}, (k, v) => [k, v * v]) returns: {a: 4, b: 9}
mapObj({a: 1}, (k, v) => ['b', v]) returns: {b: 1}
Parameters:
Name Type Description
obj Object | Array

regular object or array

cb function

function of form: (key, value) => [nextKey, nextValue]

  • the return type here is an array of two elements, key and value, where key must be either a string or a number
  • if a cb does not return an entry, then the original [key, value] pair that was passed into cb will be used instead
Returns:
  • new object with mapping applied, or the original obj if input was invalid
Type
Object

(inner) mapKeys(obj, keyMapper) → {Object}

Description:
  • Shortcut helper for mapping just the keys of an object.

Source:
Parameters:
Name Type Description
obj Object

Object to have it's property keys mapped

keyMapper function

Function of shape (key) => nextKey

Returns:
  • The new object with each key mapped to the response of keyMapper
Type
Object

(inner) mapObj(obj, cb) → {Array}

Description:
  • Map over and objects props and values.

Source:
Parameters:
Name Type Description
obj Object

Object to map over

cb function

Method to call for each entry in the passed in obj

Returns:
  • returned values from callback || The entries of the passed in obj
Type
Array

(inner) omitKeys(target, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys not defined from array.

Source:
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:

new object with only keys not in array

Type
Object

(inner) pickKeys(obj, keys) → {Object}

Description:
  • Creates a new object from passed in object with keys defined from array.

Source:
Parameters:
Name Type Description
obj Object

object to pull keys from

keys Array

keys to add to new object

Returns:

new object with only keys from passed in keys array

Type
Object

(inner) reduceObj(obj, cb, startopt) → {Object}

Description:
  • Loop over and objects props and values and reduce to new object.

Source:
Parameters:
Name Type Attributes Description
obj Object

Object to reduce over it's properties

cb function

Method to call on each property of the obj argument

start Object <optional>

Starting accumulator object passed to the reduce method

Returns:
  • updated object after running the reduce method
Type
Object

(inner) sanitizeCopy(obj) → {Object}

Description:
  • Sanitizes all html strings in an object's properties.

Source:
Parameters:
Name Type Description
obj Object

Object to be sanitize

Returns:
  • obj with strings sanitized
Type
Object

(inner) someEntry(obj, predicate, logErroropt) → {Boolean}

Description:
  • Like "some" for arrays, but operates across each entry in obj

Source:
Parameters:
Name Type Attributes Default Description
obj Object

Object to have it's properties checked

predicate function

of form (key, value) => boolean. Returns true or false for the entry

logError Boolean <optional>
true

Boolean indicating if errors should be logged

Returns:
  • True if at least one entry satisfied the predicate, false if not
Type
Boolean

(inner) splitByKeys(target, keys) → {Array.<Object>}

Description:
  • Creates an intersection of the passed in object, based on the passed in keys

Source:
Example
const [matching, nonMatching] = splitByKeys({ 1: 'match', 2: 'non-matching' }, [ 1 ])
matching === { 1: 'match' } === true
nonMatching === { 2: 'non-matching' }  === true
Parameters:
Name Type Description
target Object

object to pull keys from

keys Array

keys to not add to new object

Returns:
  • First object contains keys matching keys of the keys argument - Second object contains keys not matching keys of the keys argument
Type
Array.<Object>

(inner) toObj(val, divideropt, splitopt) → {Object}

Description:
  • Converts an array or string into an object.

Source:
Parameters:
Name Type Attributes Description
val array | string

to be converted to object

divider String <optional>

if string, what divides key from value

split String <optional>

if string, what splits each key/value pair

Returns:
  • Converted object
Type
Object

(inner) trimStringFields(object) → {Object}

Description:
  • Trims objects string fields.

Source:
Parameters:
Name Type Description
object Object
Returns:
  • object with string fields trimmed
Type
Object