UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 1.25 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import e from"./../assert/is-function.js";import r from"./../assert/is-positive-integer.js";var n=e,i=r.isPrimitive;function t(e,r,t){var o,u;if(!n(e))throw new TypeError("invalid argument. First argument must be a function. Value: `"+e+"`.");if(arguments.length<2)u=null;else if(arguments.length>2){if(o=t,!i(u=r))throw new TypeError("invalid argument. Arity argument must be a positive integer. Value: `"+u+"`.")}else i(r)?u=r:(u=null,o=r);return a;function a(){var r,i;if(r=e,u){if(u>arguments.length)throw new Error("insufficient input arguments. Expected "+u+" argument(s) and only received "+arguments.length+" argument(s).");for(i=0;i<u;i++){if(!n(r))throw new Error("invalid invocation. The configured arity exceeds the number of possible curried function invocations. Expected: "+u+". Actual: "+i+".");r=r.call(o,arguments[i])}return r}for(i=0;i<arguments.length;i++){if(!n(r))throw new Error("invalid invocation. Number of arguments exceeds the number of possible curried function invocations. Expected: "+arguments.length+". Actual: "+i+".");r=r.call(o,arguments[i])}return r}}var o=t;export default o; //# sourceMappingURL=uncurry.js.map