evolve

v1.0.0arrow_drop_down
v1.0.0
v0.0.1
STATUS
Passing
DOWNLOADS
26
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 years ago
SIZE
599 B
Creates a new object by recursively evolving a shallow copy of `object`, according to the `transformation` functions.
2 contributors
Install evolve as a package?
Copied
npm i @bit/bit.utils.object.evolve
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
evolve (
transformations:Object,
object:Object
) : Object

Creates a new object by recursively evolving a shallow copy of object, according to the transformation functions. All non-primitive properties are copied by reference.

A transformation function will not be invoked if its corresponding key does not exist in the evolved object.

Example
var tomato  = {firstName: '  Tomato ', data: {elapsed: 100, remaining: 1400}, id:123};
     var transformations = {
       firstName: trim,
       lastName: trim, // Will not get invoked.
       data: {elapsed: add(1), remaining: add(-1)}
     };
     evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123}
Arguments
transformations: Object

The object specifying transformation functions to apply to the object.

object: Object

The object to be transformed.

Returns
Object

The transformed object.

Test Summary

evolve the evolve function should exist

Pass

evolve should Creates a new object by recursively evolving a shallow copy of object, according to the transformation functions.

Pass
Help and resources