2.0.1 • Published 4 years ago

source-to-target v2.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

SOURCE-TO-TARGET

Description

* This module will transform one object to another type of object. This can transform most complex structures.

Installation

* npm i source-to-target

Use

* const mapper = require("source-to-target");

* const target = mapper(sourceObject, targetToSourceMap)

* Example: 
    const sourceObject = {
        a:1, 
        b: {
            c: 1, 
            d: [{e: 2}]
        }
    } 

    const targetToSourceMap = {
        "_a": "a",
        "_b._c": "b.c",
        "_b._d[_e]": "b.d[e]"
    }

    const target = mapper(sourceObject, targetToSourceMap);

    output => {
        _a: 1,
        _b: {
            _c: 1,
            _d: [{_e: 2}]
        }
    }

Parameters

* sourceObject: It is the original object.
* targetToSourceMap: This object is map between target to source, Which tell mapper the relation between target keys and source keys. In targetToSourceMap, Symbol dot(.) represent "inside object" and [] reprent "inside array".
2.0.1

4 years ago

2.0.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago