jul-data-mapper

Converts an object to another using a namespace path mapping.
Isomorphic: works both in backends and in frontends via e.g. webpack
Source:

Members

(private, inner, constant) rexs :Object

Cached regexs for internal use
Source:

Methods

(inner) compact(oMap) → {Object}

Compacts a mapping (key:value) object into a tree-like structure
Parameters:
Name Type Description
oMap Object Key-value object to compact
Source:

(private, inner) dotted(aSeg) → {String}

Makes a dotted path from an array of path segments
e.g. ['a', 'b', 1, 0, 'c'] => 'a.b.1.0.c'
Parameters:
Name Type Description
aSeg Array An array of path segments
Source:

(private, inner) intersect(aNs1, aNs2) → {Array}

Gets the intersection of two arrays of path segments
Parameters:
Name Type Description
aNs1 Array First array to intersect
aNs2 Array Second array to intersect
Source:

(inner) mapper(oDest, oSrc, oMap, oConfigopt) → {Object}

Performs a mapping with a given object from a data schema to another data schema
Parameters:
Name Type Attributes Description
oDest Object The destination object where the mapped values are applied over
oSrc Object The source object
oMap Object A key-value hash (mapping) between namespace paths in the source and those in the destination
oConfig Object <optional>
Optional configuration object with any of the following options:
  • uint {RegExp|String} - regular expression or string to match an array index placeholder e.g. '$n'.
    Defaults to /\$[a-z]/
  • prefixProp {String} - name of a property of the mapping the will be used as a prefix when computing the destination namespace for the current siblings.
    Defaults to '_mapToPrefix'
  • strict {Boolean} - performs checkings of not overwriting descendant values that are already mapped.
    Defaults to false
Source:

(private, inner) segments(sNs) → {Array}

Gets the array of segments for a JavaScript path
e.g. 'a.b.c[1][2].d' => ['a', 'b', 'c', '1', '2', 'd']
Parameters:
Name Type Description
sNs String A JavaScript (namespace) path
Source: