package
Set of functions to build algorithmic transformations for data structures
npm install transform-dataGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Set of functions to build algorithmic transformations for data structures.
Small attempt of mine to make transformations of data structures simplier.
I assume that you use node.js or any bundling system with commonJs module support. To install it simply run the command below:
npm install transform-dataCurrent module exports function to apply transformations to the complex data structures and also contains helpers to build transformations easier.
All the helpers are provided with the lib/tool module.
Arguments:
xf(val, keypath, isCollection) — function which is used to apply transformation.f(val, keypath, isCollection) - function which is used to reduce the resulting collection.col (array|object) - the collection itself.Example:
const { constant, identity } = require('lodash/fp');
const transform = require('transform-data');
// returns a deep copy of provided data structure
transform(identity, constant(true), {a: {b: 5}}); // {a: {b: 5}}
const { split } = require('transform-data/lib/tool');
const inc = a => a + 1;
const isOdd = a => a % 2 !== 0;
transform(split(inc), isOdd, [0, 1, Helpers:
constant (funciton)curry (funciton)identity (funciton)isArray (funciton)isCollection (funciton)isFunction (funciton)isNumber (funciton)isObjectLike (funciton)isPlainObject (funciton)isString (funciton)isUndefined (funciton)split(primitive, collection = identity)toString (funciton)The MIT License