plexis-js / plexis

Lo-fi, powerful, community-driven string manipulation library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: `compose`

vorillaz opened this issue · comments

Since most Plexis functions are pure we can create composed functions using closures.
compose works in a more functional way and provides users with flexibility, creating complex and tricky string operations. compose actually invokes a series of functions.

@param {Function[]} [funcs] The functions to invoke.
@returns {Function} Returns the new composite function.

Example usage

import compose from '@plexis/compose';
const inc = x => x + 1;
const add = (x, y) => x + y;
const ops = compose(inc, x => add(x, 2));

ops(1); // returns 4;
ops(10); // returns 13;

Aliases

import compose from '@plexis/compose';
import {compose, _do} from 'plexis';

@vorillaz, can I take this ?

@dungwinux Thanks so much for contributing, go for it!