Class: module:Mapper

module:Mapper()

Simple JS mapper that allows you to map array and objects keys according to your's instructions.

Constructor

new module:Mapper()

It only binds functions to correct 'this'.
Source:

Methods

map(objOrArray, objOrArray, mapInstructions)

Map function
Parameters:
Name Type Description
objOrArray Object Object that will be mapped according to map instructions passed as second parameter. [REQUIRED]
objOrArray Array Array of objects that will be mapped according to map instructions passed as second parameter. [REQUIRED]
mapInstructions Array Array of objects {field: 'obj_field', to: 'obj_field_mapped'}. [REQUIRED]
Source:

mapArray(array, mapInstructions)

Direct array mapper function
Parameters:
Name Type Description
array Array Array of objects that will be mapped according to map instructions passed as second parameter. [REQUIRED]
mapInstructions Array Array of objects {field: 'obj_field', to: 'obj_field_mapped'}. [REQUIRED]
Source:

mapObj(obj, mapInstructions)

Direct object mapper function
Parameters:
Name Type Description
obj Object Object that will be mapped according to map instructions passed as second parameter. [REQUIRED]
mapInstructions Array Array of objects {field: 'obj_field', to: 'obj_field_mapped'}. [REQUIRED]
Source: