prelude-ls
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -1,2 +0,6 @@ | ||
var curry, flip, fix, apply; | ||
// Generated by LiveScript 1.2.0 | ||
var apply, curry, flip, fix, over; | ||
apply = curry$(function(f, list){ | ||
return f.apply(null, list); | ||
}); | ||
curry = function(f){ | ||
@@ -9,7 +13,7 @@ return curry$(f); | ||
fix = function(f){ | ||
return function(g, x){ | ||
return function(g){ | ||
return function(){ | ||
return f(g(g)).apply(null, arguments); | ||
}; | ||
}(function(g, x){ | ||
}(function(g){ | ||
return function(){ | ||
@@ -20,4 +24,4 @@ return f(g(g)).apply(null, arguments); | ||
}; | ||
apply = curry$(function(f, list){ | ||
return f.apply(null, list); | ||
over = curry$(function(f, g, x, y){ | ||
return f(g(x), g(y)); | ||
}); | ||
@@ -28,3 +32,4 @@ module.exports = { | ||
fix: fix, | ||
apply: apply | ||
apply: apply, | ||
over: over | ||
}; | ||
@@ -43,2 +48,2 @@ function curry$(f, bound){ | ||
return _curry(); | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
// Generated by LiveScript 1.2.0 | ||
var Func, List, Obj, Str, Num, id, isType, replicate, prelude, toString$ = {}.toString; | ||
@@ -70,2 +71,3 @@ Func = require('./Func.js'); | ||
prelude.unique = List.unique; | ||
prelude.uniqueBy = List.uniqueBy; | ||
prelude.sort = List.sort; | ||
@@ -83,2 +85,4 @@ prelude.sortWith = List.sortWith; | ||
prelude.minimum = List.minimum; | ||
prelude.maximumBy = List.maximumBy; | ||
prelude.minimumBy = List.minimumBy; | ||
prelude.scan = List.scan; | ||
@@ -102,2 +106,7 @@ prelude.scanl = List.scanl; | ||
prelude.zipAllWith = List.zipAllWith; | ||
prelude.at = List.at; | ||
prelude.elemIndex = List.elemIndex; | ||
prelude.elemIndices = List.elemIndices; | ||
prelude.findIndex = List.findIndex; | ||
prelude.findIndices = List.findIndices; | ||
prelude.apply = Func.apply; | ||
@@ -107,2 +116,3 @@ prelude.curry = Func.curry; | ||
prelude.fix = Func.fix; | ||
prelude.over = Func.over; | ||
prelude.split = Str.split; | ||
@@ -116,2 +126,6 @@ prelude.join = Str.join; | ||
prelude.unchars = Str.unchars; | ||
prelude.repeat = Str.repeat; | ||
prelude.capitalize = Str.capitalize; | ||
prelude.camelize = Str.camelize; | ||
prelude.dasherize = Str.dasherize; | ||
prelude.values = Obj.values; | ||
@@ -155,3 +169,3 @@ prelude.keys = Obj.keys; | ||
prelude.lcm = Num.lcm; | ||
prelude.VERSION = '1.0.3'; | ||
prelude.VERSION = '1.1.0'; | ||
module.exports = prelude; | ||
@@ -170,2 +184,2 @@ function curry$(f, bound){ | ||
return _curry(); | ||
} | ||
} |
169
lib/List.js
@@ -1,2 +0,3 @@ | ||
var each, map, compact, filter, reject, partition, find, head, first, tail, last, initial, empty, reverse, unique, fold, foldl, fold1, foldl1, foldr, foldr1, unfoldr, concat, concatMap, flatten, difference, intersection, union, countBy, groupBy, andList, orList, any, all, sort, sortWith, sortBy, sum, product, mean, average, maximum, minimum, scan, scanl, scan1, scanl1, scanr, scanr1, slice, take, drop, splitAt, takeWhile, dropWhile, span, breakList, zip, zipWith, zipAll, zipAllWith, toString$ = {}.toString, slice$ = [].slice; | ||
// Generated by LiveScript 1.2.0 | ||
var each, map, compact, filter, reject, partition, find, head, first, tail, last, initial, empty, reverse, unique, uniqueBy, fold, foldl, fold1, foldl1, foldr, foldr1, unfoldr, concat, concatMap, flatten, difference, intersection, union, countBy, groupBy, andList, orList, any, all, sort, sortWith, sortBy, sum, product, mean, average, maximum, minimum, maximumBy, minimumBy, scan, scanl, scan1, scanl1, scanr, scanr1, slice, take, drop, splitAt, takeWhile, dropWhile, span, breakList, zip, zipWith, zipAll, zipAllWith, at, elemIndex, elemIndices, findIndex, findIndices, toString$ = {}.toString, slice$ = [].slice; | ||
each = curry$(function(f, xs){ | ||
@@ -18,3 +19,3 @@ var i$, len$, x; | ||
}); | ||
compact = curry$(function(xs){ | ||
compact = function(xs){ | ||
var i$, len$, x, results$ = []; | ||
@@ -28,3 +29,3 @@ for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
return results$; | ||
}); | ||
}; | ||
filter = curry$(function(f, xs){ | ||
@@ -70,5 +71,2 @@ var i$, len$, x, results$ = []; | ||
head = first = function(xs){ | ||
if (!xs.length) { | ||
return; | ||
} | ||
return xs[0]; | ||
@@ -83,14 +81,9 @@ }; | ||
last = function(xs){ | ||
if (!xs.length) { | ||
return; | ||
} | ||
return xs[xs.length - 1]; | ||
}; | ||
initial = function(xs){ | ||
var len; | ||
len = xs.length; | ||
if (!len) { | ||
if (!xs.length) { | ||
return; | ||
} | ||
return xs.slice(0, len - 1); | ||
return xs.slice(0, -1); | ||
}; | ||
@@ -114,2 +107,16 @@ empty = function(xs){ | ||
}; | ||
uniqueBy = function(f, xs){ | ||
var seen, i$, len$, x, val, results$ = []; | ||
seen = []; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
val = f(x); | ||
if (in$(val, seen)) { | ||
continue; | ||
} | ||
seen.push(val); | ||
results$.push(x); | ||
} | ||
return results$; | ||
}; | ||
fold = foldl = curry$(function(f, memo, xs){ | ||
@@ -127,8 +134,11 @@ var i$, len$, x; | ||
foldr = curry$(function(f, memo, xs){ | ||
return fold(f, memo, xs.concat().reverse()); | ||
var i$, x; | ||
for (i$ = xs.length - 1; i$ >= 0; --i$) { | ||
x = xs[i$]; | ||
memo = f(x, memo); | ||
} | ||
return memo; | ||
}); | ||
foldr1 = curry$(function(f, xs){ | ||
var ys; | ||
ys = xs.concat().reverse(); | ||
return fold(f, ys[0], ys.slice(1)); | ||
return foldr(f, xs[xs.length - 1], xs.slice(0, -1)); | ||
}); | ||
@@ -159,3 +169,3 @@ unfoldr = curry$(function(f, b){ | ||
}); | ||
flatten = curry$(function(xs){ | ||
flatten = function(xs){ | ||
var x; | ||
@@ -174,3 +184,3 @@ return [].concat.apply([], (function(){ | ||
}())); | ||
}); | ||
}; | ||
difference = function(xs){ | ||
@@ -303,11 +313,5 @@ var yss, results, i$, len$, x, j$, len1$, ys; | ||
sortWith = curry$(function(f, xs){ | ||
if (!xs.length) { | ||
return []; | ||
} | ||
return xs.concat().sort(f); | ||
}); | ||
sortBy = curry$(function(f, xs){ | ||
if (!xs.length) { | ||
return []; | ||
} | ||
return xs.concat().sort(function(x, y){ | ||
@@ -342,10 +346,9 @@ if (f(x) > f(y)) { | ||
mean = average = function(xs){ | ||
var sum, len, i$, i; | ||
var sum, i$, len$, x; | ||
sum = 0; | ||
len = xs.length; | ||
for (i$ = 0; i$ < len; ++i$) { | ||
i = i$; | ||
sum += xs[i]; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
x = xs[i$]; | ||
sum += x; | ||
} | ||
return sum / len; | ||
return sum / xs.length; | ||
}; | ||
@@ -374,2 +377,24 @@ maximum = function(xs){ | ||
}; | ||
maximumBy = curry$(function(f, xs){ | ||
var max, i$, ref$, len$, x; | ||
max = xs[0]; | ||
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) { | ||
x = ref$[i$]; | ||
if (f(x) > f(max)) { | ||
max = x; | ||
} | ||
} | ||
return max; | ||
}); | ||
minimumBy = function(f, xs){ | ||
var min, i$, ref$, len$, x; | ||
min = xs[0]; | ||
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) { | ||
x = ref$[i$]; | ||
if (f(x) < f(min)) { | ||
min = x; | ||
} | ||
} | ||
return min; | ||
}; | ||
scan = scanl = curry$(function(f, memo, xs){ | ||
@@ -410,4 +435,2 @@ var last, x; | ||
return xs.slice(0, 0); | ||
} else if (!xs.length) { | ||
return xs; | ||
} else { | ||
@@ -418,3 +441,3 @@ return xs.slice(0, n); | ||
drop = curry$(function(n, xs){ | ||
if (n <= 0 || !xs.length) { | ||
if (n <= 0) { | ||
return xs; | ||
@@ -456,3 +479,5 @@ } else { | ||
breakList = curry$(function(p, xs){ | ||
return span(compose$([not$, p]), xs); | ||
return span(function(){ | ||
return not$(p.apply(this, arguments)); | ||
}, xs); | ||
}); | ||
@@ -528,2 +553,51 @@ zip = curry$(function(xs, ys){ | ||
}; | ||
at = curry$(function(n, xs){ | ||
if (n < 0) { | ||
return xs[xs.length + n]; | ||
} else { | ||
return xs[n]; | ||
} | ||
}); | ||
elemIndex = curry$(function(el, xs){ | ||
var i$, len$, i, x; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
i = i$; | ||
x = xs[i$]; | ||
if (x === el) { | ||
return i; | ||
} | ||
} | ||
}); | ||
elemIndices = curry$(function(el, xs){ | ||
var i$, len$, i, x, results$ = []; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
i = i$; | ||
x = xs[i$]; | ||
if (x === el) { | ||
results$.push(i); | ||
} | ||
} | ||
return results$; | ||
}); | ||
findIndex = curry$(function(f, xs){ | ||
var i$, len$, i, x; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
i = i$; | ||
x = xs[i$]; | ||
if (f(x)) { | ||
return i; | ||
} | ||
} | ||
}); | ||
findIndices = curry$(function(f, xs){ | ||
var i$, len$, i, x, results$ = []; | ||
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { | ||
i = i$; | ||
x = xs[i$]; | ||
if (f(x)) { | ||
results$.push(i); | ||
} | ||
} | ||
return results$; | ||
}); | ||
module.exports = { | ||
@@ -561,2 +635,3 @@ each: each, | ||
unique: unique, | ||
uniqueBy: uniqueBy, | ||
sort: sort, | ||
@@ -574,2 +649,4 @@ sortWith: sortWith, | ||
minimum: minimum, | ||
maximumBy: maximumBy, | ||
minimumBy: minimumBy, | ||
scan: scan, | ||
@@ -592,3 +669,8 @@ scan1: scan1, | ||
zipAll: zipAll, | ||
zipAllWith: zipAllWith | ||
zipAllWith: zipAllWith, | ||
at: at, | ||
elemIndex: elemIndex, | ||
elemIndices: elemIndices, | ||
findIndex: findIndex, | ||
findIndices: findIndices | ||
}; | ||
@@ -608,14 +690,7 @@ function curry$(f, bound){ | ||
} | ||
function in$(x, arr){ | ||
var i = -1, l = arr.length >>> 0; | ||
while (++i < l) if (x === arr[i] && i in arr) return true; | ||
function in$(x, xs){ | ||
var i = -1, l = xs.length >>> 0; | ||
while (++i < l) if (x === xs[i]) return true; | ||
return false; | ||
} | ||
function compose$(fs){ | ||
return function(){ | ||
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 not$(x){ return !x; } |
@@ -0,1 +1,2 @@ | ||
// Generated by LiveScript 1.2.0 | ||
var 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; | ||
@@ -129,2 +130,2 @@ max = curry$(function(x$, y$){ | ||
return _curry(); | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
// Generated by LiveScript 1.2.0 | ||
var values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty, each, map, compact, filter, reject, partition, find; | ||
@@ -76,3 +77,3 @@ values = function(object){ | ||
}); | ||
compact = curry$(function(object){ | ||
compact = function(object){ | ||
var k, x, results$ = {}; | ||
@@ -86,3 +87,3 @@ for (k in object) { | ||
return results$; | ||
}); | ||
}; | ||
filter = curry$(function(f, object){ | ||
@@ -155,2 +156,2 @@ var k, x, results$ = {}; | ||
return _curry(); | ||
} | ||
} |
@@ -1,2 +0,3 @@ | ||
var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat; | ||
// Generated by LiveScript 1.2.0 | ||
var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capitalize, camelize, dasherize; | ||
split = curry$(function(sep, str){ | ||
@@ -36,10 +37,30 @@ return str.split(sep); | ||
repeat = curry$(function(n, str){ | ||
var out, res$, i$; | ||
res$ = []; | ||
var result, i$; | ||
result = ''; | ||
for (i$ = 0; i$ < n; ++i$) { | ||
res$.push(str); | ||
result += str; | ||
} | ||
out = res$; | ||
return out.join(''); | ||
return result; | ||
}); | ||
capitalize = function(str){ | ||
return str.charAt(0).toUpperCase() + str.slice(1); | ||
}; | ||
camelize = function(it){ | ||
return it.replace(/[-_]+(.)?/g, function(arg$, c){ | ||
return (c != null ? c : '').toUpperCase(); | ||
}); | ||
}; | ||
dasherize = function(str){ | ||
return str.replace(/([^-A-Z])([A-Z]+)/g, function(arg$, lower, upper){ | ||
return lower + "-" + (upper.length > 1 | ||
? upper | ||
: upper.toLowerCase()); | ||
}).replace(/^([A-Z]+)/, function(arg$, upper){ | ||
if (upper.length > 1) { | ||
return upper + "-"; | ||
} else { | ||
return upper.toLowerCase(); | ||
} | ||
}); | ||
}; | ||
module.exports = { | ||
@@ -55,3 +76,6 @@ split: split, | ||
reverse: reverse, | ||
repeat: repeat | ||
repeat: repeat, | ||
capitalize: capitalize, | ||
camelize: camelize, | ||
dasherize: dasherize | ||
}; | ||
@@ -70,2 +94,2 @@ function curry$(f, bound){ | ||
return _curry(); | ||
} | ||
} |
{ | ||
"name": "prelude-ls", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"author": "George Zahariev <z@georgezahariev.com>", | ||
@@ -45,7 +45,8 @@ "description": "prelude.ls is a functionally oriented utility library. It is powerful and flexible. Almost all of its functions are curried. It is written in, and is the recommended base library for, LiveScript.", | ||
"devDependencies": { | ||
"LiveScript": "~1.1.1", | ||
"uglify-js": "~2.2.5", | ||
"mocha": "~1.8.2", | ||
"browserify": "~2.13.2" | ||
"LiveScript": "~1.2.0", | ||
"uglify-js": "~2.4.12", | ||
"mocha": "~1.17.1", | ||
"istanbul": "~0.2.4", | ||
"browserify": "~3.24.13" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
31160
1272
5