2.2.1 • Published 5 years ago

oniyi-object-transform v2.2.1

Weekly downloads
16
License
Apache-2.0
Repository
github
Last release
5 years ago

oniyi-object-transform NPM version

offers simple transformations for object literals

Installation

$ npm install --save oniyi-object-transform

Usage

const transform = require('oniyi-object-transform');

transform(params) ⇒ Object

Transforms one object into another

Kind: global function
Returns: Object - result of transforms applied to params.source

ParamTypeDescription
paramsObjectdescribing the function arguments
params.sourceObjectsource object to be transformed. takes precendence over params.src
params.srcObjectalias for params.source
params.targetObjecttarget object to join the transformed source into
params.methodStringname of method to be used when joining results from pick and map. Options are: merge, assign, defaults, defaultsDeep. For details see lodash documentation: https://lodash.com/docs#assign
params.mapObjectkey => value map of source properties to be copied to target with a different name
params.whitelistArray.<String>list of strings that are allowed as params.map values. This feature is helpful when you transform from one object to a specified schema and want to restrict target names of params.map to the list of schema keys
params.pickArray.<String>properties to be picked from source and copied to target with the same name
params.parseObjectkey => value map of target properties to be run through value parsers. Value can be either of type String to reference one of the built-in parsers integer, date, lowercase, uppercase, trim or of type Function to be called with the original value as single argument.

License

Apache-2.0 © Benjamin Kroeger

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

7 years ago

2.0.0

8 years ago

1.2.0

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago