braid

Fancy function composition for JavaScript

Usage no npm install needed!

<script type="module">
  import braid from 'https://cdn.skypack.dev/braid';
</script>

README

Braid

Fancy function composition for JavaScript.

Show me how

// Create a new function from several other functions.
var combinedFn = braid.compose(
  fn1,               // Use any number of function references
  fn2,
  [fn3, arg1, arg2], // You can provide a function with additional arguments
  fn4
);

// Now, let's use the returned function.
var value1 = combinedFn('abc');
var value2 = combinedFn('def');

// You can also pipe a value directly through a set of functions, returning
// the result.
var value = braid.pipe('ghi', fn1, fn2, [fn3, arg1, arg2], fn4);