AlterSet

AlterSet

new AlterSet(objopt)

Initialize AlterSet (Constructor Function)

Source:
Parameters:
Name Type Attributes Description
obj Object <optional>

Object whose properties you want to have in alterset @

Methods

addProps(…arr) → {Object}

Add values of properties which are common between all objects, others remain as it is.

Source:
Parameters:
Name Type Attributes Description
arr Array.<AlterSet> | Array.<Object> <repeatable>

Array of objects to add properties of

Returns:
Type:
Object
  • Values will be sum of individual values of passed object

get(key, dopt) → {*}

Return default value if property not found

Source:
Parameters:
Name Type Attributes Default Description
key String

Property to search for

d * <optional>
null

Value to return in case of miss

Returns:
Type:
*
  • Value against a Key in the object

getMax() → {Array}

Get key of maximum value

Source:
Returns:
Type:
Array
  • Array of keys with the maximum value

getMin() → {Array}

Get key of minimum value

Source:
Returns:
Type:
Array
  • Array of keys with the maximum value

hasKey(key) → {Boolean}

Intuitive way of checking key existence

Source:
Parameters:
Name Type Description
key String

Key to check existence of

Returns:
Type:
Boolean
  • True/False

intersection(arr, optionsopt) → {Object}

Create an object with values from existing object and properties specified in array.

Source:
Parameters:
Name Type Attributes Default Description
arr Array

Properties array.

options Object <optional>
{unref:true, protoLookup:true}

Object containing control params

Name Type Attributes Default Description
unref Boolean <optional>
true

true to reserve protochain

protoLookup Boolean <optional>
true

true to look in protochain for value

Returns:
Type:
Object
  • An object with keys which are passed in array.

json() → {String}

Get JSON representation of the object

Source:
Returns:
Type:
String
  • Object to JSON

sort(optionsopt) → {Array}

Get array of keys, in Ascending or Descending order of values

Source:
Parameters:
Name Type Attributes Description
options Object <optional>

Object containing control params

Name Type Attributes Default Description
order String <optional>
ASC

Ascending ASC or Descending DESC

returns String <optional>
keys

Array of Keys || Value

Returns:
Type:
Array
  • Either array of keys or values based on value of returns

subProps(…arr) → {Object}

Subtract values of properties which are common between all objects, others remain as it is.

Source:
Parameters:
Name Type Attributes Description
arr Array.<AlterSet> | Array.<Object> <repeatable>

Array of objects to subtract properties of

Returns:
Type:
Object
  • Values will be Instance Value - Sum of passed object values of individual values of passed object

union(obj, optionsopt) → {Object}

Create an object with key, value pairs in both objects, overring with the pairs of passed object

Source:
Parameters:
Name Type Attributes Default Description
obj AlterSet | Object

Object to append key value paris of

options Object <optional>
{unref:false}

Object containing control params

Name Type Attributes Default Description
unref Boolean <optional>
false

true to create new object else modify this

Returns:
Type:
Object
  • An concatinated object Instance U Passed Object

withValue(value, options) → {Array}

Find keys having a certain value

Source:
Parameters:
Name Type Description
value String | Number

Value to search the keys for

options Object

Object with control params

Name Type Description
strict Boolean

Flag to switch between strict/unstrict value matching

Returns:
Type:
Array
  • Array of keys matching a certain value