ish.type.obj

Object-based type functionality.

Source:

Methods

[mixin] ish.type.obj.clone(x, vKeysOrFromToopt) → {Array.<variant>}

Source:
Copies the referenced keys into a new instance.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Description
x Array.<variant> Value representing the object to copy.
vKeysOrFromTo string | Array.<string> | object <optional>
Value representing the key(s) to copy into the new object, with the option to remap keys when an object is passed.
Returns:
Type Description
Array.<variant> Value representing the passed value as a new instance.

[mixin] ish.type.obj.concat(vTarget, vSource(s)) → {object|function}

Source:
Concat's arrays and copies properties into an object.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Description
vTarget object | function Value representing the target object to receive properties.
vSource(s) object | function | Array.<object> | Array.<function()> representing the source object(s) whose arrays will be concat'ed and properties will be copied into the target.
Returns:
Type Description
object | function Value representing the passed target object.

[mixin] ish.type.obj.cp(x, vMaxDepthopt) → {Array.<variant>}

Source:
Copies the passed value into a new instance.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Default Description
x Array.<variant> Value representing the object to copy.
vMaxDepth boolean | integer <optional>
0 Value representing if a deep copy is to occur. false/0 performs a shallow copy, a positive integer indicates the max depth to perform a deep copy to, true and all other integer values perform a deep copy to an unlimited depth.
Returns:
Type Description
Array.<variant> Value representing the passed value as a new instance.

[mixin] ish.type.obj.diff(x, y, oOptionsopt) → {object}

Source:
Determines the differences between the passed values.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Description
x object | function Value to interrogate.
y object | function Value to interrogate.
oOptions object <optional>
Value representing the following options:
Properties
Name Type Attributes Default Description
compare function <optional>
Value representing the function that implements the compare, accepting 2 arguments (a, b) and returning truthy if a > b.
useCoercion boolean <optional>
true Value representing if coercion is to be used during comparisons.
caseInsensitive boolean <optional>
false Value representing if the values are to be compared in a case-insensitive manor.
trimWhitespace boolean <optional>
false Value representing if leading and trailing whitespace is to be trimmed prior to comparison.
includeMissingKeys boolean <optional>
false Value representing if keys present in y but missing from x are to be included in the reported differences.
caseInsensitiveKeys boolean <optional>
false Value representing if keys are to be treated as case insensitive.
pruneUndefinedValues boolean <optional>
false Value representing if if keys with undefined as their value are to be removed from the return value.
Returns:
Type Description
object Value representing the differences between the passed values.

[mixin] ish.type.obj.empty() → {object}

Source:
See:
Creates an empty object.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Note: Creating an object via {} results in an object that includes __proto__ and hasOwnProperty. This method returns an object with no properties.
Returns:
Type Description
object Value representing an empty object.

[mixin] ish.type.obj.eq(x, y, oOptionsopt) → {boolean}

Source:
Determines if the passed values are equal.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Description
x object | function Value to interrogate.
y object | function Value to interrogate.
oOptions object <optional>
Value representing the following options:
Properties
Name Type Attributes Default Description
compare function <optional>
Value representing the function that implements the compare, accepting 2 arguments (a, b) and returning truthy if a > b.
useCoercion boolean <optional>
true Value representing if coercion is to be used during comparisons.
caseInsensitive boolean <optional>
false Value representing if the values are to be compared in a case-insensitive manor.
trimWhitespace boolean <optional>
false Value representing if leading and trailing whitespace is to be trimmed prior to comparison.
maxDepth boolean | integer <optional>
0 Value representing if a deep comparison is to occur. false/0 performs a shallow comparison, a positive integer indicates the max depth to perform a deep comparison to, true and all other integer values perform a deep comparison to an unlimited depth.
Returns:
Type Description
boolean Value representing if the passed values are equal.

[mixin] ish.type.obj.flatten(x, vOptionsopt) → {object|function|Array.<object>|Array.<function()>}

Source:
Flattens the structure of an object into a single depth object as parent_child_grandchild using ish.type.obj.rekey to preprocess key names.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Default Description
x object | function | Array.<object> | Array.<function()> Value representing the object(s) to rekey.
vOptions string | boolean | object <optional>
Value representing the replacementChar, if we are to deleteRekeyed values or the following options:
oOptions.replacementChar string <optional>
"" Value representing the char (or characters) used to replace any unfriendly characters.
oOptions.trackRekeyed string <optional>
"" Value representing the key to store the remapped key data.
oOptions.deleteRekeyed boolean <optional>
true Value representing if the original key/value is to be deleted from the object.
Returns:
Type Description
object | function | Array.<object> | Array.<function()> Value representing the rekeyed object(s) (i.e. the passed x is returned for convenience).

ish.type.obj.get(oSource, vKey, bReturnAllMatchingopt) → {variant|Array.<variant>}

Source:
Determines the value of the passed key within the passed value via a case-insensitive match, a RegExp match or truthy function return.
Note: As the key is searched for, the first matching key enumerated by the for...in statement will be returned unless bReturnAllMatching is set to true.
Parameters:
Name Type Attributes Default Description
oSource object | function Value to interrogate.
vKey string | RegExp | function Value representing the key(s) to retrieve from the passed value or a function(sCurrentKey) returning truthy to indicate inclusion into the return value.
bReturnAllMatching boolean <optional>
false Value representing if multiple keys are to be retrieve from the passed value.
Returns:
Type Description
variant | Array.<variant> Value representing the value of the passed key or an array representing all values of the passed key.

[mixin] ish.type.obj.has(x, vKeys, bKeysArePathsopt) → {boolean}

Source:
Determines if the referenced keys are present in the passed value.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Default Description
x object | function Value representing the object to interrogate.
vKeys string | Array.<string> Value representing the key(s) to interrogate.
bKeysArePaths boolean <optional>
true Value representing if the passed keys represent dot-delimited paths (e.g. grandparent.parent.array.1.property, see: {@link: ish.resolve}).
Returns:
Type Description
boolean Value representing if the referenced keys are present in the passed value.

ish.type.obj.is(x, vOptionsopt) → {boolean}

Source:
Determines if the passed value represents an object.
Parameters:
Name Type Attributes Description
x variant Value to interrogate.
vOptions boolean | object <optional>
Value representing if empty objects are to be ignored or the following options:
Properties
Name Type Attributes Default Description
nonEmpty boolean <optional>
false Value representing if empty objects are to be ignored.
strict boolean <optional>
false Value representing if only [object Objects] are to be allowed.
allowFn boolean <optional>
false Value representing if functions are to be allowed.
allowJSON boolean <optional>
false Value representing if JSON-strings are to be allowed.
requiredKeys boolean <optional>
Value listing the keys required to be present in the object.
interface boolean <optional>
false Value representing the required the keys and types (see: {@link: ish.type}).
Returns:
Type Description
boolean Value representing if the passed value represents an object.

[mixin] ish.type.obj.is.cyclic(x, bReturnReportopt) → {boolean|Array.<object>}

Source:
Determines if the passed value has any circular references.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Default Description
x object | function Value to interrogate.
bReturnReport boolean <optional>
false Value indicating if an array of circular references is to be returned.
Returns:
Type Description
boolean | Array.<object> Value representing if the passed value has any circular references or an array of objects describing any circular references.

[mixin] ish.type.obj.is.interface(x, oInterface, bStrictopt) → {boolean}

Source:
Determines if the passed value conforms to the passed interface.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Default Description
x object | function Value to interrogate.
oInterface object Value representing the interface, where each value represents a string representing a type under ish.type or a value representing the function that implements the test, accepting 1 argument (x) and returning truthy if the value is of a valid type.
bStrict boolean <optional>
false Value indicating if the passed value is not allowed to have any additional keys outside of the those in the passed interface.
Returns:
Type Description
boolean Value representing if the passed value conforms to the passed interface.

[mixin] ish.type.obj.join(x, sDelimiteropt, sKeyDelimiteropt) → {Array.<variant>}

Source:
Joins the passed value into a string.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Default Description
x object | function Value representing the object to join.
sDelimiter string <optional>
"" Value representing the delimiter to be included between values.
sKeyDelimiter string <optional>
Value representing if the keys are to be included within the string, defining the delimiter to be included between keys and their related values.
Returns:
Type Description
Array.<variant> Value representing the passed value mutated into an array.

ish.type.obj.mk(x, vDefaultValopt) → {object}

Source:
Casts the passed value into an object.
Parameters:
Name Type Attributes Default Description
x variant Value to interrogate.
vDefaultVal variant <optional>
{} Value representing the default return value if casting fails.
Returns:
Type Description
object Value representing the passed value as an object type.

[mixin] ish.type.obj.mv(x, oFromToopt, bSetToUndefinedopt) → {boolean}

Source:
Moves the referenced keys into the passed new keys.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Default Description
x object | function | Array.<variant> Value representing the object(s) to interrogate.
oFromTo object <optional>
Value representing the keys to move.
bSetToUndefined boolean <optional>
false Value representing if the moved keys are to be deleted (false) or reset to undefined (true).
Returns:
Type Description
boolean Value representing if the keys have been moved.

ish.type.obj.ownKeys(oSource, vOptionsopt) → {Array.<string>}

Source:
Determines the enumerable and/or non-enumerable keys of the passed value.
Parameters:
Name Type Attributes Default Description
oSource object Value to interrogate.
vOptions object | boolean <optional>
false Value representing if non-enumerable properties are to be included or the desired options:
Properties
Name Type Attributes Default Description
includeNonEnumerable boolean <optional>
false Value representing if non-enumerable properties are to be included.
onlyNonEnumerable boolean <optional>
false Value representing if only non-enumerable properties are to be returned.
Returns:
Type Description
Array.<string> Value representing the requested keys of the passed value.

[mixin] ish.type.obj.prune(x, vAddlKeysToPruneopt) → {boolean}

Source:
Removes values set to undefined along with any referenced keys from the passed value.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Description
x object | function Value representing the object to interrogate.
vAddlKeysToPrune string | Array.<string> <optional>
Value representing any additional key(s) to remove.
Returns:
Type Description
boolean Value representing the remaining keys from the passed value.

[mixin] ish.type.obj.rekey(x, vOptionsopt) → {object|function|Array.<object>|Array.<function()>}

Source:
Removes any characters from object keys that require bracket-style notation (e.g. oObject["2 this is\n1 valid key"] becomes oObject.thisis1validkey)
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Default Description
x object | function | Array.<object> | Array.<function()> Value representing the object(s) to rekey.
vOptions string | boolean | object <optional>
Value representing the replacementChar, if we are to deleteRekeyed values or the following options:
oOptions.replacementChar string <optional>
"" Value representing the char (or characters) used to replace any unfriendly characters.
oOptions.trackRekeyed string <optional>
"" Value representing the key to store the remapped key data.
oOptions.deleteRekeyed boolean <optional>
false Value representing if the original key/value is to be deleted from the object.
Returns:
Type Description
object | function | Array.<object> | Array.<function()> Value representing the rekeyed object(s) (i.e. the passed x is returned for convenience).

[mixin] ish.type.obj.resolveFirst(oObject, a_vPaths) → {variant}

Source:
Provides access to an object structure's nested properties, returning the first found path.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Description
oObject object Value to interrogate.
a_vPaths Array.<string> | Array.<Array.<string>> Value representing the paths to the requested property's as a period-delimited string (e.g. "parent.child.array.0.key") or an array of strings.
Returns:
Type Description
variant Value representing the variant at the referenced path.

ish.type.obj.rm(a_vArray, vTargets, vReplacements) → {boolean}

Source:
Removes the passed target(s) from the passed object (optionally replacing them with updated values).
Parameters:
Name Type Description
a_vArray Array.<variant> Values to interrogate.
vTargets variant | Array.<variant> Value(s) to remove.
vReplacements variant | Array.<variant> Value(s) to replace the removed items with.
Note: The number of replacements must match the number of targets.
Returns:
Type Description
boolean Value representing if one or more of the passed value(s) were successfully removed / replaced.

[mixin] ish.type.obj.stringify(oObject) → {variant}

Source:
See:
Provides an object structure as a string in Javascript's Object Literal Notation.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Description
oObject object Value to interrogate.
Returns:
Type Description
variant Value representing the passed object as a string in Javascript's Object Literal Notation.

[mixin] ish.type.obj.toArr(x, sSetKeyAsopt) → {Array.<variant>}

Source:
Mutates the passed value into an array.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Description
x object | function Value representing the object to mutate.
sSetKeyAs string <optional>
Value representing the name of the key to set the original key's name under.
Returns:
Type Description
Array.<variant> Value representing the passed value mutated into an array.

[mixin] ish.type.obj.unique(x, vPaths, oOptionsopt) → {Array.<variant>}

Source:
Determines the unique entries within the passed value.
From Mixin: ish.type-ex.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Description
x Array.<object> | Array.<function()> Value representing the array to compare.
vPaths string | Array.<string> Value representing the values to interrogate.
oOptions object <optional>
Value representing the following options:
Properties
Name Type Attributes Default Description
compare function <optional>
Value representing the function that implements the compare, accepting 2 arguments (a, b) and returning truthy if a > b.
useCoercion boolean <optional>
true Value representing if coercion is to be used during comparisons.
caseInsensitive boolean <optional>
false Value representing if the values are to be compared in a case-insensitive manor.
trimWhitespace boolean <optional>
false Value representing if leading and trailing whitespace is to be trimmed prior to comparison.
maxDepth boolean | integer <optional>
0 Value representing if a deep comparison is to occur. false/0 performs a shallow comparison, a positive integer indicates the max depth to perform a deep comparison to, true and all other integer values perform a deep comparison to an unlimited depth.
Returns:
Type Description
Array.<variant> Value representing the passed values' unique entries.