Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

evolve

v0.26.1arrow_drop_down
v0.26.1
STATUS
Passing
DOWNLOADS
0
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 months ago
SIZE
883 B
subject
Creates a new object by recursively evolving a shallow copy of `object`, according to the `transformation` functions.
1 contributor
Use evolve in your project ?
Copied
npm i @bit/ramda.ramda.evolve
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
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';
revert changes
reload
toggle layout
maximize
add(1);
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
const tomato = {firstName: '  Tomato ', data: {elapsed: 100, remaining: 1400}, id:123};
     const transformations = {
       firstName: R.trim,
       lastName: R.trim, // Will not get invoked.
       data: {elapsed: R.add(1), remaining: R.add(-1)}
     };
     R.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.