UNPKG

1.65 kBJavaScriptView Raw
1// Generated by LiveScript 1.6.0
2var apply, curry, flip, fix, over, memoize, toString$ = {}.toString;
3apply = curry$(function(f, list){
4 return f.apply(null, list);
5});
6curry = function(f){
7 return curry$(f);
8};
9flip = curry$(function(f, x, y){
10 return f(y, x);
11});
12fix = function(f){
13 return function(g){
14 return function(){
15 return f(g(g)).apply(null, arguments);
16 };
17 }(function(g){
18 return function(){
19 return f(g(g)).apply(null, arguments);
20 };
21 });
22};
23over = curry$(function(f, g, x, y){
24 return f(g(x), g(y));
25});
26memoize = function(f){
27 var memo;
28 memo = {};
29 return function(){
30 var args, res$, i$, to$, key, arg;
31 res$ = [];
32 for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
33 res$.push(arguments[i$]);
34 }
35 args = res$;
36 key = (function(){
37 var i$, ref$, len$, results$ = [];
38 for (i$ = 0, len$ = (ref$ = args).length; i$ < len$; ++i$) {
39 arg = ref$[i$];
40 results$.push(arg + toString$.call(arg).slice(8, -1));
41 }
42 return results$;
43 }()).join('');
44 return memo[key] = key in memo
45 ? memo[key]
46 : f.apply(null, args);
47 };
48};
49module.exports = {
50 curry: curry,
51 flip: flip,
52 fix: fix,
53 apply: apply,
54 over: over,
55 memoize: memoize
56};
57function curry$(f, bound){
58 var context,
59 _curry = function(args) {
60 return f.length > 1 ? function(){
61 var params = args ? args.concat() : [];
62 context = bound ? context || this : this;
63 return params.push.apply(params, arguments) <
64 f.length && arguments.length ?
65 _curry.call(context, params) : f.apply(context, params);
66 } : f;
67 };
68 return _curry();
69}
\No newline at end of file