UNPKG

@riim/curry

Version:

Fast curry implementation

1 lines 1.06 kB
!(function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):n.curry=r()})(this,(function(){"use strict";function n(n,r){return(o[r]||(o[r]=Function("fn","return function("+Array(r+1).join(", _").slice(2)+") { return fn.apply(this, arguments); };")))(n)}function r(){}function e(n,r){for(var e=0,t=0,o=n.length,f=r.length,i=Array(o),c=0;e<o;e++){var a=n[e];if(a===u){if(t<f&&r[t++]!==u){i[e]=r[t-1];continue}c++}i[e]=a}for(;t<f;t++)(i[e++]=r[t])===u&&c++;return{arguments:i,placeholderCount:c}}function t(){function r(t,o){function u(){for(var n=arguments.length,o=Array(n),u=0;u<n;u++)o[u]=arguments[u];var f=e(t,o);return f.placeholderCount?r(f.arguments,f.placeholderCount):i.apply(void 0,f.arguments)}return void 0!==o?n(u,o):u}for(var t=arguments.length,o=Array(t),f=0;f<t;f++)o[f]=arguments[f];for(var i="function"==typeof this?this:o.shift(),c=i.length,a=o.length;a<c;a++)o[a]=u;return r(o)()}var o=Object.create(null),u=new r;return t.placeholder=t.__=t._=u,t.curry=t,t}));