Methods
(static) change(obj, action, settingsopt) → {Object}
- Source:
- See:
Change all or filtered fields of object/map/array, applying specified action/transformation.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object/map/array whose fields should be changed. |
|
action |
function | String | An action/operation that should be applied to get new field value.
See description of |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
|
Returns:
Modified object (value of obj
parameter).
- Type
- Object
(static) checkField(obj, field, filter, settingsopt) → {Boolean}
Check whether the field of given object/map/array/set corresponds to specified condition(s) or filter(s).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object, map (including WeakMap), array or set (including WeakSet) to be processed. |
|
field |
String | Symbol | Field that should be checked. |
|
filter |
Any | A filter or array of filters specifying conditions that should be checked. A filter can be:
|
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported (setting's default value is specified in parentheses):
|
Returns:
true
if the field corresponds to specified filter(s), otherwise false
.
- Type
- Boolean
(static) checkValue(value, filter, settingsopt) → {Boolean}
- Source:
- See:
Check whether the value corresponds to specified condition(s) or filter(s).
This function is a "wrap" for the following code:
checkField({value: value}, "value", filter, settings);
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
Any | Value that should be checked. |
|
filter |
Any | A filter or array of filters specifying conditions that should be checked. See checkField for details. |
|
settings |
Object |
<optional> |
Operation settings. See checkField for details. |
Returns:
true
if the value corresponds to specified filter(s), otherwise false
.
- Type
- Boolean
(static) copy(source, target, settingsopt) → {Object}
- Source:
- See:
Copy all or filtered fields from source object/map/array/set into target object/map/array/set, applying specified transformation if necessary.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
source |
Object | Object/map/array/set whose fields will be copied. |
|
target |
Object | Object/map/array/set into which fields should be copied. |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
|
Returns:
Reference to the target object (value of target
parameter).
- Type
- Object
(static) empty(value) → {Any}
Empty the given value according to the following rules:
- for array,
Map
orSet
: removes all elements from the value - for object: removes all own fields from the value
- for string: returns empty string
- for number: returns
0
- otherwise: returns
undefined
Parameters:
Name | Type | Description |
---|---|---|
value |
Any | Value to be processed. |
Returns:
Processed value (for array, object, Map
or Set
) or empty value corresponding to the given value.
- Type
- Any
(static) fromArray(list, keyFieldopt, settingsopt) → {Object}
- Source:
- See:
Create object (map) from list of objects/maps. Fields of the created object are values of specified field/key of objects/maps, values of the created object are corresponding items of the list.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
list |
Array | List of objects/values to be processed. |
|
keyField |
function | String |
<optional> |
Specifies names of fields of the created object. Can be name of field or method whose value is used as field name of the created object, or function that returns the field name. In the latter case the following parameters will be passed in the function: the source object (an item of the list), the created object, the index of the source object, operation settings. When the parameter is not set, items of the list are used as field names. |
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported (setting's default value is specified in parentheses):
|
Returns:
Object created from the given list.
- Type
- Object
(static) getClass(value) → {String}
Return class of given value (namely value of internal property [[Class]]
).
Parameters:
Name | Type | Description |
---|---|---|
value |
Any | Value whose class should be determined. |
Returns:
String indicating value class.
- Type
- String
(static) getFields(obj, settingsopt) → {Array}
- Source:
- See:
Return list of all or filtered fields of specified object or map.
Fields are searched (checked) in the object itself and in its prototype chain.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object or map to be processed. |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
|
Returns:
List of all or filtered fields of specified object.
- Type
- Array
(static) getFreeField(obj, settingsopt) → {String}
Return name of first free (absent) field/key of specified object/map, that conforms to the following pattern: <prefix><number>
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object or map in which a free field/key should be found.
If |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported (setting's default value is specified in parentheses):
|
Returns:
Name of field which is absent in the specified object and conforms to the pattern.
- Type
- String
(static) getKeys(value) → {Array|null}
Return list of all keys of specified object/map/array/set.
Parameters:
Name | Type | Description |
---|---|---|
value |
Any | Value that should be processed. |
Returns:
List of all keys of specified object/map/array/set or null
if another value is passed.
- Type
- Array | null
(static) getPropertySymbols(obj) → {Array}
Return list of all symbol property keys for given object including keys from prototype chain.
This function is defined only when Object.getOwnPropertySymbols
is available.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | Object to be processed. |
Returns:
List of all found symbol property keys.
- Type
- Array
(static) getSize(obj, settingsopt) → {Integer}
Return number of all or filtered fields of specified object or map.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object or map to be processed. |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
|
Returns:
Number of all or filtered fields of specified object.
- Type
- Integer
(static) getType(value) → {String}
Return type of given value.
Parameters:
Name | Type | Description |
---|---|---|
value |
Any | Value whose type should be determined. |
Returns:
For NaN
- 'nan'
, for null
- 'null'
, otherwise - result of typeof
operator.
- Type
- String
(static) getValueKey(obj, value, bAllopt) → {Array|String|null}
Return the name of field (or list of names) having the specified value in the given object or map.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object or map to be checked. |
|
value |
Any | Value that should be searched for. |
|
bAll |
Boolean |
<optional> |
Whether names of all found fields having the specified value should be returned.
Default value is |
Returns:
Names of fields (when bAll
is true
) or a field name having the specified value,
or null
when the object do not contain the specified value.
- Type
- Array | String | null
(static) getValues(obj, settingsopt) → {Array}
- Source:
- See:
Return list of all or filtered field values of specified object or map.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object or map to be processed. |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
|
Returns:
List of all or filtered field values of specified object.
- Type
- Array
(static) isEmpty(value) → {Boolean}
- Source:
- See:
Check whether given value is an empty value i.e. null
, undefined
, 0
, empty object, empty array,
empty map, empty set or empty string.
Parameters:
Name | Type | Description |
---|---|---|
value |
Any | Value to be checked. |
Returns:
true
if the value is an empty value, otherwise false
.
- Type
- Boolean
(static) isKindOf(value, sKind) → {Boolean}
Check whether given value has (or does not have) specified kind (type or class).
Parameters:
Name | Type | Description |
---|---|---|
value |
Any | Value to be checked. |
sKind |
String | Type or class for check. Can be any value that is returned by getType and getClass, or one of the following:
|
Returns:
true
if value has the specified kind (or does not have when the check is negated), otherwise false
.
- Type
- Boolean
(static) isMap(value, bWeakopt) → {Boolean}
Check whether given value is a Map
or a WeakMap
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
Any | Value that should be checked. |
||
bWeak |
Boolean |
<optional> |
false
|
By default the passed value is only checked for |
Returns:
true
when the passed value is a Map
or WeakMap
, otherwise false
.
- Type
- Boolean
(static) isSizeMore(obj, nValue, settingsopt) → {Boolean}
Check whether number of all or filtered fields of specified object/map is more than the given value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object or map to be checked. |
|
nValue |
Number | Value that should be used for comparison with number of fields. |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
|
Returns:
true
, when number of all or filtered fields is more than the given value, otherwise false
.
- Type
- Boolean
(static) map(obj, action, settingsopt) → {Object}
- Source:
- See:
Create new object containing all or filtered fields of the source object/map/array/set, applying specified action/transformation for field values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Array | Object | Object/map/array/set whose fields should be copied. |
|
action |
function | String | An action/operation that should be applied to get field value that will be saved in created object.
See description of |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
|
Returns:
Created object containing processed fields.
- Type
- Object
(static) remove(obj, filter, settingsopt) → {Array|Object}
- Source:
- See:
Remove filtered fields/elements from specified object/map/array/set.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Array | Object | Array, set, object or map to be processed. |
|
filter |
Any | A filter or array of filters specifying fields or elements that should be removed (see checkField). |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
|
Returns:
Processed array, set, object or map.
- Type
- Array | Object
(static) reverse(value) → {Any}
Reverse or negate the given value according to the following rules:
- for array or set: creates a copy and reverses order of elements in it
- for object or map: creates a copy where fields are swapped with their values (i.e. for
{a: "b", c: "d"}
returns{b: "a", d: "c"}
) - for string: reverses order of its characters
- for number: returns negated value (i.e.
- value
) - for boolean: returns negated value (i.e.
! value
) - otherwise: returns source value without modification
Parameters:
Name | Type | Description |
---|---|---|
value |
Any | Value to be processed. |
Returns:
Processed value.
- Type
- Any
(static) select(filter, from, settingsopt) → {Any}
- Source:
- See:
Return the value of the first element/field in the passed array/object/map/set that satisfies the specified filter(s).
If value passed for selection is not an array/set nor an object/map and settings.defaultValue
is not set, the value will be returned as is.
If no element in the passed array/set satisfies the specified filter(s),
settings.defaultValue
or the last element of the array/set (or undefined
when the array is empty) will be returned.
If no field in the passed object/map satisfies the specified filter(s), settings.defaultValue
or undefined
will be returned.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filter |
Any | Filter that should be used to select a value (see checkField for details). |
|
from |
Any | An array/object/map/set from which a value should be selected. |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported (setting's default value is specified in parentheses):
|
Returns:
The value of first element/field in the passed array/object/map/set that satisfies the specified filter(s),
or settings.defaultValue
, or the value of from
parameter or undefined
.
- Type
- Any
(static) split(obj, firstObjFields, settingsopt) → {Array}
- Source:
- See:
Divide given object or map into 2 parts: the first part includes specified fields, the second part includes all other fields.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object or map to be divided. |
|
firstObjFields |
Array | Object | null | List of names of fields that should be included in the first part,
or an object defining those fields.
If value is not specified ( |
|
settings |
Object |
<optional> |
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
|
Returns:
Created parts: item with index 0 is the first part, item with index 1 is the second part.
- Type
- Array
(static) transform(value, sAction) → {Any}
Transform the given value applying the specified operation.
Parameters:
Name | Type | Description |
---|---|---|
value |
Any | Value to be transformed. |
sAction |
String | Operation that should be applied to transform the value. Can be one of the following:
|
Returns:
Transformed value.
- Type
- Any