UNPKG

stick-js

Version:

Fast toolkit for functional programming in JS. Provides idioms for referentially transparent expressions, clear separation of mutable and immutable operations, object factories, function calls based on English grammar, and pipe & compose operators.

1 lines 851 B
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.recurry=exports.roll=void 0;var roll=function roll(f){return function(){var g=f;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}for(var _i=0,_args=args;_i<_args.length;_i++){var i=_args[_i];g=g(i);}return g;};};exports.roll=roll;var check_dn=function check_dn(dn,f){if(dn>=0)return;throw new Error("recurry: arity error (perhaps you should call `recurry` "+"with a higher value for `n`; `f` was "+f.toString());};var recurry=function recurry(n){return function(f){return function(){var rolled=roll(f).apply(void 0,arguments);var dn=n-arguments.length;check_dn(dn,f);return dn<1?rolled:recurry(dn)(rolled);};};};exports.recurry=recurry;var _default={roll:roll,recurry:recurry};exports.default=_default;