prelude-ls
Advanced tools
Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "prelude-ls", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "prelude.ls is a JavaScript functional programming library. It is the recommended base library for, and is written in, LiveScript. It is based off of Haskell's Prelude module.", | ||
@@ -23,6 +23,8 @@ "keywords": [ | ||
"engines": { | ||
"node": ">= 0.6.14 < 0.9.0" | ||
"node": ">= 0.8.0" | ||
}, | ||
"files": [ | ||
"prelude.js", | ||
"prelude-browser.js", | ||
"prelude-browser-min.js", | ||
"README.md", | ||
@@ -29,0 +31,0 @@ "LICENSE" |
479
prelude.js
@@ -1,6 +0,6 @@ | ||
// prelude.ls 0.5.0 | ||
// prelude.ls 0.6.0 | ||
// Copyright (c) 2012 George Zahariev | ||
// Released under the MIT License | ||
// raw.github.com/gkz/prelude-ls/master/LICNSE | ||
var objToFunc, each, map, filter, reject, partition, find, first, head, tail, last, initial, empty, values, keys, length, cons, append, join, reverse, foldl, fold, foldl1, fold1, foldr, foldr1, andList, orList, any, all, unique, sum, product, average, mean, concat, concatMap, listToObj, maximum, minimum, scanl, scan, scanl1, scan1, scanr, scanr1, replicate, take, drop, splitAt, takeWhile, dropWhile, span, breakIt, zip, zipWith, zipAll, zipAllWith, compose, curry, partial, id, flip, fix, lines, unlines, words, unwords, max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, asin, acos, atan, atan2, truncate, round, ceiling, floor, isItNaN, even, odd, gcd, lcm, __toString = {}.toString, __slice = [].slice; | ||
var objToFunc, each, map, filter, reject, partition, find, first, head, tail, last, initial, empty, values, keys, length, cons, append, join, reverse, foldl, fold, foldl1, fold1, foldr, foldr1, unfoldr, andList, orList, any, all, unique, sort, sortBy, compare, sum, product, average, mean, concat, concatMap, listToObj, maximum, minimum, scanl, scan, scanl1, scan1, scanr, scanr1, replicate, take, drop, splitAt, takeWhile, dropWhile, span, breakIt, zip, zipWith, zipAll, zipAllWith, compose, curry, id, flip, fix, lines, unlines, words, unwords, max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, asin, acos, atan, atan2, truncate, round, ceiling, floor, isItNaN, even, odd, gcd, lcm, toString$ = {}.toString, slice$ = [].slice; | ||
exports.objToFunc = objToFunc = function(obj){ | ||
@@ -11,12 +11,12 @@ return function(key){ | ||
}; | ||
exports.each = each = __curry(function(f, xs){ | ||
var x, __i, __len; | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
for (__i in xs) { | ||
x = xs[__i]; | ||
exports.each = each = curry$(function(f, xs){ | ||
var i$, x, len$; | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
for (i$ in xs) { | ||
x = xs[i$]; | ||
f(x); | ||
} | ||
} else { | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
f(x); | ||
@@ -27,21 +27,21 @@ } | ||
}); | ||
exports.map = map = __curry(function(f, xs){ | ||
var type, key, x, result, __res, __i, __len, __results = {}; | ||
if (__toString.call(f).slice(8, -1) !== 'Function') { | ||
exports.map = map = curry$(function(f, xs){ | ||
var type, key, x, res$, i$, len$, result, results$ = {}; | ||
if (toString$.call(f).slice(8, -1) !== 'Function') { | ||
f = objToFunc(f); | ||
} | ||
type = __toString.call(xs).slice(8, -1); | ||
type = toString$.call(xs).slice(8, -1); | ||
if (type === 'Object') { | ||
for (key in xs) { | ||
x = xs[key]; | ||
__results[key] = f(x); | ||
results$[key] = f(x); | ||
} | ||
return __results; | ||
return results$; | ||
} else { | ||
__res = []; | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
__res.push(f(x)); | ||
res$ = []; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
res$.push(f(x)); | ||
} | ||
result = __res; | ||
result = res$; | ||
if (type === 'String') { | ||
@@ -54,8 +54,8 @@ return result.join(''); | ||
}); | ||
exports.filter = filter = __curry(function(f, xs){ | ||
var type, key, x, result, __res, __i, __len, __results = {}; | ||
if (__toString.call(f).slice(8, -1) !== 'Function') { | ||
exports.filter = filter = curry$(function(f, xs){ | ||
var type, key, x, res$, i$, len$, result, results$ = {}; | ||
if (toString$.call(f).slice(8, -1) !== 'Function') { | ||
f = objToFunc(f); | ||
} | ||
type = __toString.call(xs).slice(8, -1); | ||
type = toString$.call(xs).slice(8, -1); | ||
if (type === 'Object') { | ||
@@ -65,15 +65,15 @@ for (key in xs) { | ||
if (f(x)) { | ||
__results[key] = x; | ||
results$[key] = x; | ||
} | ||
} | ||
return __results; | ||
return results$; | ||
} else { | ||
__res = []; | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
res$ = []; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
if (f(x)) { | ||
__res.push(x); | ||
res$.push(x); | ||
} | ||
} | ||
result = __res; | ||
result = res$; | ||
if (type === 'String') { | ||
@@ -86,8 +86,8 @@ return result.join(''); | ||
}); | ||
exports.reject = reject = __curry(function(f, xs){ | ||
var type, key, x, result, __res, __i, __len, __results = {}; | ||
if (__toString.call(f).slice(8, -1) !== 'Function') { | ||
exports.reject = reject = curry$(function(f, xs){ | ||
var type, key, x, res$, i$, len$, result, results$ = {}; | ||
if (toString$.call(f).slice(8, -1) !== 'Function') { | ||
f = objToFunc(f); | ||
} | ||
type = __toString.call(xs).slice(8, -1); | ||
type = toString$.call(xs).slice(8, -1); | ||
if (type === 'Object') { | ||
@@ -97,15 +97,15 @@ for (key in xs) { | ||
if (!f(x)) { | ||
__results[key] = x; | ||
results$[key] = x; | ||
} | ||
} | ||
return __results; | ||
return results$; | ||
} else { | ||
__res = []; | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
res$ = []; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
if (!f(x)) { | ||
__res.push(x); | ||
res$.push(x); | ||
} | ||
} | ||
result = __res; | ||
result = res$; | ||
if (type === 'String') { | ||
@@ -118,8 +118,8 @@ return result.join(''); | ||
}); | ||
exports.partition = partition = __curry(function(f, xs){ | ||
var type, passed, failed, key, x, __i, __len; | ||
if (__toString.call(f).slice(8, -1) !== 'Function') { | ||
exports.partition = partition = curry$(function(f, xs){ | ||
var type, passed, failed, key, x, i$, len$; | ||
if (toString$.call(f).slice(8, -1) !== 'Function') { | ||
f = objToFunc(f); | ||
} | ||
type = __toString.call(xs).slice(8, -1); | ||
type = toString$.call(xs).slice(8, -1); | ||
if (type === 'Object') { | ||
@@ -135,4 +135,4 @@ passed = {}; | ||
failed = []; | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
(f(x) ? passed : failed).push(x); | ||
@@ -147,10 +147,10 @@ } | ||
}); | ||
exports.find = find = __curry(function(f, xs){ | ||
var x, __i, __len; | ||
if (__toString.call(f).slice(8, -1) !== 'Function') { | ||
exports.find = find = curry$(function(f, xs){ | ||
var i$, x, len$; | ||
if (toString$.call(f).slice(8, -1) !== 'Function') { | ||
f = objToFunc(f); | ||
} | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
for (__i in xs) { | ||
x = xs[__i]; | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
for (i$ in xs) { | ||
x = xs[i$]; | ||
if (f(x)) { | ||
@@ -161,4 +161,4 @@ return x; | ||
} else { | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
if (f(x)) { | ||
@@ -196,3 +196,3 @@ return x; | ||
var x; | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
for (x in xs) { | ||
@@ -206,18 +206,18 @@ return false; | ||
exports.values = values = function(obj){ | ||
var x, __i, __results = []; | ||
for (__i in obj) { | ||
x = obj[__i]; | ||
__results.push(x); | ||
var i$, x, results$ = []; | ||
for (i$ in obj) { | ||
x = obj[i$]; | ||
results$.push(x); | ||
} | ||
return __results; | ||
return results$; | ||
}; | ||
exports.keys = keys = function(obj){ | ||
var x, __results = []; | ||
var x, results$ = []; | ||
for (x in obj) { | ||
__results.push(x); | ||
results$.push(x); | ||
} | ||
return __results; | ||
return results$; | ||
}; | ||
exports.length = length = function(xs){ | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
xs = values(xs); | ||
@@ -227,18 +227,18 @@ } | ||
}; | ||
exports.cons = cons = __curry(function(x, xs){ | ||
if (__toString.call(xs).slice(8, -1) === 'String') { | ||
exports.cons = cons = curry$(function(x, xs){ | ||
if (toString$.call(xs).slice(8, -1) === 'String') { | ||
return x + xs; | ||
} else { | ||
return [(x)].concat(xs); | ||
return [x].concat(xs); | ||
} | ||
}); | ||
exports.append = append = __curry(function(xs, ys){ | ||
if (__toString.call(ys).slice(8, -1) === 'String') { | ||
exports.append = append = curry$(function(xs, ys){ | ||
if (toString$.call(ys).slice(8, -1) === 'String') { | ||
return xs + ys; | ||
} else { | ||
return (xs).concat(ys); | ||
return xs.concat(ys); | ||
} | ||
}); | ||
exports.join = join = __curry(function(sep, xs){ | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
exports.join = join = curry$(function(sep, xs){ | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
xs = values(xs); | ||
@@ -249,3 +249,3 @@ } | ||
exports.reverse = reverse = function(xs){ | ||
if (__toString.call(xs).slice(8, -1) === 'String') { | ||
if (toString$.call(xs).slice(8, -1) === 'String') { | ||
return xs.split('').reverse().join(''); | ||
@@ -256,12 +256,12 @@ } else { | ||
}; | ||
exports.fold = fold = exports.foldl = foldl = __curry(function(f, memo, xs){ | ||
var x, __i, __len; | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
for (__i in xs) { | ||
x = xs[__i]; | ||
exports.fold = fold = exports.foldl = foldl = curry$(function(f, memo, xs){ | ||
var i$, x, len$; | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
for (i$ in xs) { | ||
x = xs[i$]; | ||
memo = f(memo, x); | ||
} | ||
} else { | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
memo = f(memo, x); | ||
@@ -272,12 +272,20 @@ } | ||
}); | ||
exports.fold1 = fold1 = exports.foldl1 = foldl1 = __curry(function(f, xs){ | ||
exports.fold1 = fold1 = exports.foldl1 = foldl1 = curry$(function(f, xs){ | ||
return fold(f, xs[0], xs.slice(1)); | ||
}); | ||
exports.foldr = foldr = __curry(function(f, memo, xs){ | ||
exports.foldr = foldr = curry$(function(f, memo, xs){ | ||
return fold(f, memo, xs.reverse()); | ||
}); | ||
exports.foldr1 = foldr1 = __curry(function(f, xs){ | ||
exports.foldr1 = foldr1 = curry$(function(f, xs){ | ||
xs.reverse(); | ||
return fold(f, xs[0], xs.slice(1)); | ||
}); | ||
exports.unfoldr = exports.unfold = unfoldr = curry$(function(f, b){ | ||
var that; | ||
if ((that = f(b)) != null) { | ||
return [that[0]].concat(unfoldr(f, that[1])); | ||
} else { | ||
return []; | ||
} | ||
}); | ||
exports.andList = andList = function(xs){ | ||
@@ -293,4 +301,4 @@ return fold(function(memo, x){ | ||
}; | ||
exports.any = any = __curry(function(f, xs){ | ||
if (__toString.call(f).slice(8, -1) !== 'Function') { | ||
exports.any = any = curry$(function(f, xs){ | ||
if (toString$.call(f).slice(8, -1) !== 'Function') { | ||
f = objToFunc(f); | ||
@@ -302,4 +310,4 @@ } | ||
}); | ||
exports.all = all = __curry(function(f, xs){ | ||
if (__toString.call(f).slice(8, -1) !== 'Function') { | ||
exports.all = all = curry$(function(f, xs){ | ||
if (toString$.call(f).slice(8, -1) !== 'Function') { | ||
f = objToFunc(f); | ||
@@ -312,8 +320,8 @@ } | ||
exports.unique = unique = function(xs){ | ||
var result, x, __i, __len; | ||
var result, i$, x, len$; | ||
result = []; | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
for (__i in xs) { | ||
x = xs[__i]; | ||
if (!__in(x, result)) { | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
for (i$ in xs) { | ||
x = xs[i$]; | ||
if (!in$(x, result)) { | ||
result.push(x); | ||
@@ -323,5 +331,5 @@ } | ||
} else { | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
if (!__in(x, result)) { | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
if (!in$(x, result)) { | ||
result.push(x); | ||
@@ -331,3 +339,3 @@ } | ||
} | ||
if (__toString.call(xs).slice(8, -1) === 'String') { | ||
if (toString$.call(xs).slice(8, -1) === 'String') { | ||
return result.join(''); | ||
@@ -338,13 +346,41 @@ } else { | ||
}; | ||
exports.sort = sort = function(xs){ | ||
return xs.concat().sort(function(x, y){ | ||
switch (false) { | ||
case !(x > y): | ||
return 1; | ||
case !(x < y): | ||
return -1; | ||
default: | ||
return 0; | ||
} | ||
}); | ||
}; | ||
exports.sortBy = sortBy = curry$(function(f, xs){ | ||
if (!xs.length) { | ||
return []; | ||
} | ||
return xs.concat().sort(f); | ||
}); | ||
exports.compare = compare = curry$(function(f, x, y){ | ||
switch (false) { | ||
case !(f(x) > f(y)): | ||
return 1; | ||
case !(f(x) < f(y)): | ||
return -1; | ||
default: | ||
return 0; | ||
} | ||
}); | ||
exports.sum = sum = function(xs){ | ||
var result, x, __i, __len; | ||
var result, i$, x, len$; | ||
result = 0; | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
for (__i in xs) { | ||
x = xs[__i]; | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
for (i$ in xs) { | ||
x = xs[i$]; | ||
result += x; | ||
} | ||
} else { | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
result += x; | ||
@@ -356,12 +392,12 @@ } | ||
exports.product = product = function(xs){ | ||
var result, x, __i, __len; | ||
var result, i$, x, len$; | ||
result = 1; | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
for (__i in xs) { | ||
x = xs[__i]; | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
for (i$ in xs) { | ||
x = xs[i$]; | ||
result *= x; | ||
} | ||
} else { | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
result *= x; | ||
@@ -378,10 +414,10 @@ } | ||
}; | ||
exports.concatMap = concatMap = __curry(function(f, xs){ | ||
exports.concatMap = concatMap = curry$(function(f, xs){ | ||
return concat(map(f, xs)); | ||
}); | ||
exports.listToObj = listToObj = function(xs){ | ||
var result, x, __i, __len; | ||
var result, i$, len$, x; | ||
result = {}; | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
result[x[0]] = x[1]; | ||
@@ -397,37 +433,37 @@ } | ||
}; | ||
exports.scan = scan = exports.scanl = scanl = __curry(function(f, memo, xs){ | ||
exports.scan = scan = exports.scanl = scanl = curry$(function(f, memo, xs){ | ||
var last, x; | ||
last = memo; | ||
if (__toString.call(xs).slice(8, -1) === 'Object') { | ||
return ([memo]).concat((function(){ | ||
var __i, __ref, __results = []; | ||
for (__i in __ref = xs) { | ||
x = __ref[__i]; | ||
__results.push(last = f(last, x)); | ||
if (toString$.call(xs).slice(8, -1) === 'Object') { | ||
return [memo].concat((function(){ | ||
var i$, ref$, results$ = []; | ||
for (i$ in ref$ = xs) { | ||
x = ref$[i$]; | ||
results$.push(last = f(last, x)); | ||
} | ||
return __results; | ||
return results$; | ||
}())); | ||
} else { | ||
return ([memo]).concat((function(){ | ||
var __i, __ref, __len, __results = []; | ||
for (__i = 0, __len = (__ref = xs).length; __i < __len; ++__i) { | ||
x = __ref[__i]; | ||
__results.push(last = f(last, x)); | ||
return [memo].concat((function(){ | ||
var i$, ref$, len$, results$ = []; | ||
for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) { | ||
x = ref$[i$]; | ||
results$.push(last = f(last, x)); | ||
} | ||
return __results; | ||
return results$; | ||
}())); | ||
} | ||
}); | ||
exports.scan1 = scan1 = exports.scanl1 = scanl1 = __curry(function(f, xs){ | ||
exports.scan1 = scan1 = exports.scanl1 = scanl1 = curry$(function(f, xs){ | ||
return scan(f, xs[0], xs.slice(1)); | ||
}); | ||
exports.scanr = scanr = __curry(function(f, memo, xs){ | ||
exports.scanr = scanr = curry$(function(f, memo, xs){ | ||
xs.reverse(); | ||
return scan(f, memo, xs).reverse(); | ||
}); | ||
exports.scanr1 = scanr1 = __curry(function(f, xs){ | ||
exports.scanr1 = scanr1 = curry$(function(f, xs){ | ||
xs.reverse(); | ||
return scan(f, xs[0], xs.slice(1)).reverse(); | ||
}); | ||
exports.replicate = replicate = __curry(function(n, x){ | ||
exports.replicate = replicate = curry$(function(n, x){ | ||
var result, i; | ||
@@ -439,12 +475,8 @@ result = []; | ||
} | ||
if (__toString.call(x).slice(8, -1) === 'String') { | ||
return result.join(''); | ||
} else { | ||
return result; | ||
} | ||
return result; | ||
}); | ||
exports.take = take = __curry(function(n, xs){ | ||
exports.take = take = curry$(function(n, xs){ | ||
switch (false) { | ||
case !(n <= 0): | ||
if (__toString.call(xs).slice(8, -1) === 'String') { | ||
if (toString$.call(xs).slice(8, -1) === 'String') { | ||
return ''; | ||
@@ -461,3 +493,3 @@ } else { | ||
}); | ||
exports.drop = drop = __curry(function(n, xs){ | ||
exports.drop = drop = curry$(function(n, xs){ | ||
switch (false) { | ||
@@ -472,16 +504,16 @@ case !(n <= 0): | ||
}); | ||
exports.splitAt = splitAt = __curry(function(n, xs){ | ||
exports.splitAt = splitAt = curry$(function(n, xs){ | ||
return [take(n, xs), drop(n, xs)]; | ||
}); | ||
exports.takeWhile = takeWhile = __curry(function(p, xs){ | ||
var result, x, __i, __len; | ||
exports.takeWhile = takeWhile = curry$(function(p, xs){ | ||
var result, i$, len$, x; | ||
if (!xs.length) { | ||
return xs; | ||
} | ||
if (__toString.call(p).slice(8, -1) !== 'Function') { | ||
if (toString$.call(p).slice(8, -1) !== 'Function') { | ||
p = objToFunc(p); | ||
} | ||
result = []; | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
if (!p(x)) { | ||
@@ -492,3 +524,3 @@ break; | ||
} | ||
if (__toString.call(xs).slice(8, -1) === 'String') { | ||
if (toString$.call(xs).slice(8, -1) === 'String') { | ||
return result.join(''); | ||
@@ -499,13 +531,13 @@ } else { | ||
}); | ||
exports.dropWhile = dropWhile = __curry(function(p, xs){ | ||
var i, x, __i, __len; | ||
exports.dropWhile = dropWhile = curry$(function(p, xs){ | ||
var i, i$, len$, x; | ||
if (!xs.length) { | ||
return xs; | ||
} | ||
if (__toString.call(p).slice(8, -1) !== 'Function') { | ||
if (toString$.call(p).slice(8, -1) !== 'Function') { | ||
p = objToFunc(p); | ||
} | ||
i = 0; | ||
for (__i = 0, __len = xs.length; __i < __len; ++__i) { | ||
x = xs[__i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
if (!p(x)) { | ||
@@ -518,14 +550,14 @@ break; | ||
}); | ||
exports.span = span = __curry(function(p, xs){ | ||
exports.span = span = curry$(function(p, xs){ | ||
return [takeWhile(p, xs), dropWhile(p, xs)]; | ||
}); | ||
exports.breakIt = breakIt = __curry(function(p, xs){ | ||
return span(__compose((__not),(p)), xs); | ||
exports.breakIt = breakIt = curry$(function(p, xs){ | ||
return span(compose$([not$, p]), xs); | ||
}); | ||
exports.zip = zip = __curry(function(xs, ys){ | ||
var result, i, zs, j, z, __ref, __len, __len1, __ref1; | ||
exports.zip = zip = curry$(function(xs, ys){ | ||
var result, i, ref$, len$, zs, j, len1$, z, ref1$; | ||
result = []; | ||
for (i = 0, __len = (__ref = [xs, ys]).length; i < __len; ++i) { | ||
zs = __ref[i]; | ||
for (j = 0, __len1 = zs.length; j < __len1; ++j) { | ||
for (i = 0, len$ = (ref$ = [xs, ys]).length; i < len$; ++i) { | ||
zs = ref$[i]; | ||
for (j = 0, len1$ = zs.length; j < len1$; ++j) { | ||
z = zs[j]; | ||
@@ -535,4 +567,4 @@ if (i === 0) { | ||
} | ||
if ((__ref1 = result[j]) != null) { | ||
__ref1.push(z); | ||
if ((ref1$ = result[j]) != null) { | ||
ref1$.push(z); | ||
} | ||
@@ -543,5 +575,5 @@ } | ||
}); | ||
exports.zipWith = zipWith = __curry(function(f, xs, ys){ | ||
var zs, __i, __ref, __len, __results = []; | ||
if (__toString.call(f).slice(8, -1) !== 'Function') { | ||
exports.zipWith = zipWith = curry$(function(f, xs, ys){ | ||
var i$, ref$, len$, zs, results$ = []; | ||
if (toString$.call(f).slice(8, -1) !== 'Function') { | ||
f = objToFunc(f); | ||
@@ -552,16 +584,16 @@ } | ||
} else { | ||
for (__i = 0, __len = (__ref = zip.call(this, xs, ys)).length; __i < __len; ++__i) { | ||
zs = __ref[__i]; | ||
__results.push(f.apply(this, zs)); | ||
for (i$ = 0, len$ = (ref$ = zip.call(this, xs, ys)).length; i$ < len$; ++i$) { | ||
zs = ref$[i$]; | ||
results$.push(f.apply(this, zs)); | ||
} | ||
return __results; | ||
return results$; | ||
} | ||
}); | ||
exports.zipAll = zipAll = function(){ | ||
var xss, result, i, xs, j, x, __len, __len1, __ref; | ||
xss = __slice.call(arguments); | ||
var xss, result, i, len$, xs, j, len1$, x, ref$; | ||
xss = slice$.call(arguments); | ||
result = []; | ||
for (i = 0, __len = xss.length; i < __len; ++i) { | ||
for (i = 0, len$ = xss.length; i < len$; ++i) { | ||
xs = xss[i]; | ||
for (j = 0, __len1 = xs.length; j < __len1; ++j) { | ||
for (j = 0, len1$ = xs.length; j < len1$; ++j) { | ||
x = xs[j]; | ||
@@ -571,4 +603,4 @@ if (i === 0) { | ||
} | ||
if ((__ref = result[j]) != null) { | ||
__ref.push(x); | ||
if ((ref$ = result[j]) != null) { | ||
ref$.push(x); | ||
} | ||
@@ -580,5 +612,5 @@ } | ||
exports.zipAllWith = zipAllWith = function(f){ | ||
var xss, xs, __i, __ref, __len, __results = []; | ||
xss = __slice.call(arguments, 1); | ||
if (__toString.call(f).slice(8, -1) !== 'Function') { | ||
var xss, i$, ref$, len$, xs, results$ = []; | ||
xss = slice$.call(arguments, 1); | ||
if (toString$.call(f).slice(8, -1) !== 'Function') { | ||
f = objToFunc(f); | ||
@@ -589,7 +621,7 @@ } | ||
} else { | ||
for (__i = 0, __len = (__ref = zipAll.apply(this, xss)).length; __i < __len; ++__i) { | ||
xs = __ref[__i]; | ||
__results.push(f.apply(this, xs)); | ||
for (i$ = 0, len$ = (ref$ = zipAll.apply(this, xss)).length; i$ < len$; ++i$) { | ||
xs = ref$[i$]; | ||
results$.push(f.apply(this, xs)); | ||
} | ||
return __results; | ||
return results$; | ||
} | ||
@@ -599,8 +631,8 @@ }; | ||
var funcs; | ||
funcs = __slice.call(arguments); | ||
funcs = slice$.call(arguments); | ||
return function(){ | ||
var args, f, __i, __ref, __len; | ||
var args, i$, ref$, len$, f; | ||
args = arguments; | ||
for (__i = 0, __len = (__ref = funcs).length; __i < __len; ++__i) { | ||
f = __ref[__i]; | ||
for (i$ = 0, len$ = (ref$ = funcs).length; i$ < len$; ++i$) { | ||
f = ref$[i$]; | ||
args = [f.apply(this, args)]; | ||
@@ -612,25 +644,20 @@ } | ||
exports.curry = curry = function(f){ | ||
return __curry(f); | ||
return curry$(f); | ||
}; | ||
exports.partial = partial = function(f){ | ||
var initArgs; | ||
initArgs = __slice.call(arguments, 1); | ||
return function(){ | ||
var args; | ||
args = __slice.call(arguments); | ||
return f.apply(this, (initArgs).concat(args)); | ||
}; | ||
}; | ||
exports.id = id = function(x){ | ||
return x; | ||
}; | ||
exports.flip = flip = __curry(function(f, x, y){ | ||
exports.flip = flip = curry$(function(f, x, y){ | ||
return f(y, x); | ||
}); | ||
exports.fix = fix = function(f){ | ||
return __curry(function(g, x){ | ||
return f(g(g))(x); | ||
})(__curry(function(g, x){ | ||
return f(g(g))(x); | ||
})); | ||
return function(g, x){ | ||
return function(){ | ||
return f(g(g)).apply(null, arguments); | ||
}; | ||
}(function(g, x){ | ||
return function(){ | ||
return f(g(g)).apply(null, arguments); | ||
}; | ||
}); | ||
}; | ||
@@ -655,3 +682,3 @@ exports.lines = lines = function(str){ | ||
}; | ||
exports.max = max = __curry(function(x, y){ | ||
exports.max = max = curry$(function(x, y){ | ||
if (x > y) { | ||
@@ -663,3 +690,3 @@ return x; | ||
}); | ||
exports.min = min = __curry(function(x, y){ | ||
exports.min = min = curry$(function(x, y){ | ||
if (x > y) { | ||
@@ -685,14 +712,14 @@ return y; | ||
}; | ||
exports.quot = quot = __curry(function(x, y){ | ||
exports.quot = quot = curry$(function(x, y){ | ||
return ~~(x / y); | ||
}); | ||
exports.rem = rem = __curry(function(x, y){ | ||
exports.rem = rem = curry$(function(x, y){ | ||
return x % y; | ||
}); | ||
exports.div = div = __curry(function(x, y){ | ||
exports.div = div = curry$(function(x, y){ | ||
return Math.floor(x / y); | ||
}); | ||
exports.mod = mod = __curry(function(x, y){ | ||
var __ref; | ||
return ((x) % (__ref = y) + __ref) % __ref; | ||
exports.mod = mod = curry$(function(x, y){ | ||
var ref$; | ||
return ((x) % (ref$ = y) + ref$) % ref$; | ||
}); | ||
@@ -707,3 +734,3 @@ exports.recip = recip = function(x){ | ||
exports.ln = ln = Math.log; | ||
exports.pow = pow = __curry(function(x, y){ | ||
exports.pow = pow = curry$(function(x, y){ | ||
return Math.pow(x, y); | ||
@@ -717,3 +744,3 @@ }); | ||
exports.atan = atan = Math.atan; | ||
exports.atan2 = atan2 = __curry(function(x, y){ | ||
exports.atan2 = atan2 = curry$(function(x, y){ | ||
return Math.atan2(x, y); | ||
@@ -736,3 +763,3 @@ }); | ||
}; | ||
exports.gcd = gcd = __curry(function(x, y){ | ||
exports.gcd = gcd = curry$(function(x, y){ | ||
var z; | ||
@@ -748,9 +775,9 @@ x = Math.abs(x); | ||
}); | ||
exports.lcm = lcm = __curry(function(x, y){ | ||
exports.lcm = lcm = curry$(function(x, y){ | ||
return Math.abs(Math.floor(x / gcd(x, y) * y)); | ||
}); | ||
exports.installPrelude = function(target){ | ||
var __ref; | ||
if (!((__ref = target.prelude) != null && __ref.isInstalled)) { | ||
__import(target, exports); | ||
var ref$; | ||
if (!((ref$ = target.prelude) != null && ref$.isInstalled)) { | ||
import$(target, exports); | ||
target.prelude.isInstalled = true; | ||
@@ -760,10 +787,10 @@ } | ||
exports.prelude = exports; | ||
function __curry(f, args){ | ||
function curry$(f, args){ | ||
return f.length > 1 ? function(){ | ||
var params = args ? args.concat() : []; | ||
return params.push.apply(params, arguments) < f.length && arguments.length ? | ||
__curry.call(this, f, params) : f.apply(this, params); | ||
curry$.call(this, f, params) : f.apply(this, params); | ||
} : f; | ||
} | ||
function __in(x, arr){ | ||
function in$(x, arr){ | ||
var i = 0, l = arr.length >>> 0; | ||
@@ -773,9 +800,11 @@ while (i < l) if (x === arr[i++]) return true; | ||
} | ||
function __compose(f, g){ | ||
function compose$(fs){ | ||
return function(){ | ||
return f(g.apply(this, arguments)); | ||
} | ||
var i, args = arguments; | ||
for (i = fs.length; i > 0; --i) { args = [fs[i-1].apply(this, args)]; } | ||
return args[0]; | ||
}; | ||
} | ||
function __not(x){ return !x; } | ||
function __import(obj, src){ | ||
function not$(x){ return !x; } | ||
function import$(obj, src){ | ||
var own = {}.hasOwnProperty; | ||
@@ -782,0 +811,0 @@ for (var key in src) if (own.call(src, key)) obj[key] = src[key]; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49244
6
1540
1
1