Repository: gkz/prelude-ls Branch: master Commit: 4457c5cf834b Files: 30 Total size: 130.9 KB Directory structure: gitextract_3gmtmqye/ ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── README.md ├── browser/ │ ├── prelude-browser-min.js │ └── prelude-browser.js ├── lib/ │ ├── Func.js │ ├── List.js │ ├── Num.js │ ├── Obj.js │ ├── Str.js │ └── index.js ├── package.json ├── package.json.ls ├── preroll.ls ├── src/ │ ├── Func.ls │ ├── List.ls │ ├── Num.ls │ ├── Obj.ls │ ├── Str.ls │ └── index.ls └── test/ ├── Func.ls ├── List.ls ├── Num.ls ├── Obj.ls ├── Str.ls ├── browser.html └── index.ls ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.swp node_modules coverage ================================================ FILE: .travis.yml ================================================ language: node_js node_js: - 12 ================================================ FILE: CHANGELOG.md ================================================ # 1.2.1 - fix version # 1.2.0 - add `List.remove` - build with LiveScript 1.6.0 - update dependencies - remove coverage calculation # 1.1.2 - add `Func.memoize` - fix `zip-all` and `zip-with-all` corner case (no input) - build with LiveScript 1.4.0 # 1.1.1 - curry `unique-by`, `minimum-by` # 1.1.0 - added `List` functions: `maximum-by`, `minimum-by`, `unique-by` - added `List` functions: `at`, `elem-index`, `elem-indices`, `find-index`, `find-indices` - added `Str` functions: `capitalize`, `camelize`, `dasherize` - added `Func` function: `over` - eg. ``same-length = (==) `over` (.length)`` - exported `Str.repeat` through main `prelude` object - fixed definition of `foldr` and `foldr1`, the new correct definition is backwards incompatible with the old, incorrect one - fixed issue with `fix` - improved code coverage # 1.0.3 - build browser versions # 1.0.2 - bug fix for `flatten` - slight change with bug fix, flattens arrays only, not array-like objects # 1.0.1 - bug fixes for `drop-while` and `take-while` # 1.0.0 * massive update - separated functions into separate modules * functions do not accept multiple types anymore - use different versions in their respective modules in some cases (eg. `Obj.map`), or use `chars` or `values` in other cases to transform into a list * objects are no longer transformed into functions, simply use `(obj.)` in LiveScript to do that * browser version now using browserify - use `prelude = require('prelude-ls')` * added `compact`, `split`, `flatten`, `difference`, `intersection`, `union`, `count-by`, `group-by`, `chars`, `unchars`, `apply` * added `lists-to-obj` which takes a list of keys and list of values and zips them up into an object, and the converse `obj-to-lists` * added `pairs-to-obj` which takes a list of pairs (2 element lists) and creates an object, and the converse `obj-to-pairs` * removed `cons`, `append` - use the concat operator * removed `compose` - use the compose operator * removed `obj-to-func` - use partially applied access (eg. `(obj.)`) * removed `length` - use `(.length)` * `sort-by` renamed to `sort-with` * added new `sort-by` * removed `compare` - just use the new `sort-by` * `break-it` renamed `break-list`, (`Str.break-str` for the string version) * added `Str.repeat` which creates a new string by repeating the input n times * `unfold` as alias to `unfoldr` is no longer used * fixed up style and compiled with LiveScript 1.1.1 * use Make instead of Slake * greatly improved tests # 0.6.0 * fixed various bugs * added `fix`, a fixpoint (Y combinator) for anonymous recursive functions * added `unfoldr` (alias `unfold`) * calling `replicate` with a string now returns a list of strings * removed `partial`, just use native partial application in LiveScript using the `_` placeholder, or currying * added `sort`, `sortBy`, and `compare` # 0.5.0 * removed `lookup` - use (.prop) * removed `call` - use (.func arg1, arg2) * removed `pluck` - use map (.prop), xs * fixed buys wtih `head` and `last` * added non-minifed browser version, as `prelude-browser.js` * renamed `prelude-min.js` to `prelude-browser-min.js` * renamed `zip` to `zipAll` * renamed `zipWith` to `zipAllWith` * added `zip`, a curried zip that takes only two arguments * added `zipWith`, a curried zipWith that takes only two arguments # 0.4.0 * added `parition` function * added `curry` function * removed `elem` function (use `in`) * removed `notElem` function (use `not in`) # 0.3.0 * added `listToObject` * added `unique` * added `objToFunc` * added support for using strings in map and the like * added support for using objects in map and the like * added ability to use objects instead of functions in certain cases * removed `error` (just use throw) * added `tau` constant * added `join` * added `values` * added `keys` * added `partial` * renamed `log` to `ln` * added alias to `head`: `first` * added `installPrelude` helper # 0.2.0 * removed functions that simply warp operators as you can now use operators as functions in LiveScript * `min/max` are now curried and take only 2 arguments * added `call` # 0.1.0 * initial public release ================================================ FILE: LICENSE ================================================ Copyright (c) George Zahariev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: Makefile ================================================ default: all SRC = $(shell find src -name "*.ls" -type f | sort) LIB = $(SRC:src/%.ls=lib/%.js) LS = node_modules/livescript LSC = node_modules/.bin/lsc BROWSERIFY = node_modules/.bin/browserify UGLIFYJS = node_modules/.bin/uglifyjs MOCHA = node_modules/.bin/mocha lib: mkdir -p lib/ lib/%.js: src/%.ls lib $(LSC) --output lib --bare --compile "$<" browser: mkdir browser/ prelude-browser.js: $(LIB) browser preroll.ls { $(LSC) ./preroll.ls ; $(BROWSERIFY) -r ./lib/index.js:prelude-ls ; } > browser/prelude-browser.js prelude-browser-min.js: browser/prelude-browser.js $(UGLIFYJS) browser/prelude-browser.js --mangle --comments "all" > browser/prelude-browser-min.js package.json: package.json.ls $(LSC) --compile package.json.ls .PHONY: build build-browser test dev-install loc clean all: build build: $(LIB) package.json build-browser: prelude-browser.js prelude-browser-min.js test: build $(MOCHA) --ui tdd --require livescript "test/**/*.ls" dev-install: package.json npm install . loc: wc --lines src/* clean: rm -f ./*.js rm -rf lib rm -rf browser rm -f package.json ================================================ FILE: README.md ================================================ # prelude.ls [![Build Status](https://travis-ci.org/gkz/prelude-ls.png?branch=master)](https://travis-ci.org/gkz/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. See **[the prelude.ls site](http://preludels.com)** for examples, a reference, and more. You can install via npm `npm install prelude-ls` ### Development `make test` to test `make build` to build `lib` from `src` `make build-browser` to build browser versions ================================================ FILE: browser/prelude-browser-min.js ================================================ // Generated by LiveScript 1.6.0 // prelude.ls 1.2.1 // Copyright (c) George Zahariev // Released under the MIT License // https://raw.githubusercontent.com/gkz/prelude-ls/master/LICENSE require=function(){function l(u,o,a){function f(t,n){if(!o[t]){if(!u[t]){var r="function"==typeof require&&require;if(!n&&r)return r(t,!0);if(c)return c(t,!0);var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}var i=o[t]={exports:{}};u[t][0].call(i.exports,function(n){var r=u[t][1][n];return f(r||n)},i,i.exports,l,u,o,a)}return o[t].exports}for(var c="function"==typeof require&&require,n=0;n1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)=0;--e){i=t[e];r=n(i,r)}return r});w=bn(function(n,r){return k(n,r[r.length-1],r.slice(0,-1))});L=bn(function(n,r){var t,e,i;t=[];e=r;while((i=n(e))!=null){t.push(i[0]);e=i[1]}return t});W=function(n){return[].concat.apply([],n)};q=bn(function(i,u){var o;return[].concat.apply([],function(){var n,r,t,e=[];for(n=0,t=(r=u).length;nr){return 1}else if(nt(r)){return 1}else if(t(n)r){r=u}}return r};H=function(n){var r,t,e,i,u;r=n[0];for(t=0,i=(e=n.slice(1)).length;tn(t)){t=o}}return t});K=bn(function(n,r){var t,e,i,u,o;t=r[0];for(e=0,u=(i=r.slice(1)).length;e1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)>>0;while(++tr?n:r});i=S(function(n,r){return n0){return 1}else{return 0}};f=S(function(n,r){return~~(n/r)});c=S(function(n,r){return n%r});l=S(function(n,r){return Math.floor(n/r)});s=S(function(n,r){var t;return(n%(t=r)+t)%t});h=function(n){return 1/n};p=Math.PI;v=p*2;g=Math.exp;d=Math.sqrt;m=Math.log;y=S(function(n,r){return Math.pow(n,r)});j=Math.sin;x=Math.tan;b=Math.cos;M=Math.asin;z=Math.acos;k=Math.atan;w=S(function(n,r){return Math.atan2(n,r)});L=function(n){return~~n};W=Math.round;q=Math.ceil;B=Math.floor;I=function(n){return n!==n};A=function(n){return n%2===0};T=function(n){return n%2!==0};O=S(function(n,r){var t;n=Math.abs(n);r=Math.abs(r);while(r!==0){t=n%r;n=r;r=t}return n});N=S(function(n,r){return Math.abs(Math.floor(n/O(n,r)*r))});r.exports={max:e,min:i,negate:u,abs:o,signum:a,quot:f,rem:c,div:l,mod:s,recip:h,pi:p,tau:v,exp:g,sqrt:d,ln:m,pow:y,sin:j,tan:x,cos:b,acos:z,asin:M,atan:k,atan2:w,truncate:L,round:W,ceiling:q,floor:B,isItNaN:I,even:A,odd:T,gcd:O,lcm:N};function S(t,e){var i,u=function(r){return t.length>1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)1?t:t.toLowerCase())}).replace(/^([A-Z]+)/,function(n,r){if(r.length>1){return r+"-"}else{return r.toLowerCase()}})};r.exports={split:e,join:i,lines:u,unlines:o,words:a,unwords:f,chars:c,unchars:l,reverse:s,repeat:h,capitalize:p,camelize:v,dasherize:g};function d(t,e){var i,u=function(r){return t.length>1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments)1?function(){var n=r?r.concat():[];i=e?i||this:this;return n.push.apply(n,arguments) 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } },{}],2:[function(require,module,exports){ // Generated by LiveScript 1.6.0 var each, map, compact, filter, reject, remove, 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; each = curry$(function(f, xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; f(x); } return xs; }); map = curry$(function(f, xs){ var i$, len$, x, results$ = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; results$.push(f(x)); } return results$; }); compact = function(xs){ var i$, len$, x, results$ = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (x) { results$.push(x); } } return results$; }; filter = curry$(function(f, xs){ var i$, len$, x, results$ = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (f(x)) { results$.push(x); } } return results$; }); reject = curry$(function(f, xs){ var i$, len$, x, results$ = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (!f(x)) { results$.push(x); } } return results$; }); remove = curry$(function(el, xs){ var i, x$; i = elemIndex(el, xs); x$ = xs.slice(); if (i != null) { x$.splice(i, 1); } return x$; }); partition = curry$(function(f, xs){ var passed, failed, i$, len$, x; passed = []; failed = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; (f(x) ? passed : failed).push(x); } return [passed, failed]; }); find = curry$(function(f, xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (f(x)) { return x; } } }); head = first = function(xs){ return xs[0]; }; tail = function(xs){ if (!xs.length) { return; } return xs.slice(1); }; last = function(xs){ return xs[xs.length - 1]; }; initial = function(xs){ if (!xs.length) { return; } return xs.slice(0, -1); }; empty = function(xs){ return !xs.length; }; reverse = function(xs){ return xs.concat().reverse(); }; unique = function(xs){ var result, i$, len$, x; result = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (!in$(x, result)) { result.push(x); } } return result; }; uniqueBy = curry$(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){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; memo = f(memo, x); } return memo; }); fold1 = foldl1 = curry$(function(f, xs){ return fold(f, xs[0], xs.slice(1)); }); foldr = curry$(function(f, memo, xs){ 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){ return foldr(f, xs[xs.length - 1], xs.slice(0, -1)); }); unfoldr = curry$(function(f, b){ var result, x, that; result = []; x = b; while ((that = f(x)) != null) { result.push(that[0]); x = that[1]; } return result; }); concat = function(xss){ return [].concat.apply([], xss); }; concatMap = curry$(function(f, xs){ var x; return [].concat.apply([], (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) { x = ref$[i$]; results$.push(f(x)); } return results$; }())); }); flatten = function(xs){ var x; return [].concat.apply([], (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) { x = ref$[i$]; if (toString$.call(x).slice(8, -1) === 'Array') { results$.push(flatten(x)); } else { results$.push(x); } } return results$; }())); }; difference = function(xs){ var yss, res$, i$, to$, results, len$, x, j$, len1$, ys; res$ = []; for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } yss = res$; results = []; outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) { ys = yss[j$]; if (in$(x, ys)) { continue outer; } } results.push(x); } return results; }; intersection = function(xs){ var yss, res$, i$, to$, results, len$, x, j$, len1$, ys; res$ = []; for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } yss = res$; results = []; outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) { ys = yss[j$]; if (!in$(x, ys)) { continue outer; } } results.push(x); } return results; }; union = function(){ var xss, res$, i$, to$, results, len$, xs, j$, len1$, x; res$ = []; for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } xss = res$; results = []; for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) { xs = xss[i$]; for (j$ = 0, len1$ = xs.length; j$ < len1$; ++j$) { x = xs[j$]; if (!in$(x, results)) { results.push(x); } } } return results; }; countBy = curry$(function(f, xs){ var results, i$, len$, x, key; results = {}; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; key = f(x); if (key in results) { results[key] += 1; } else { results[key] = 1; } } return results; }); groupBy = curry$(function(f, xs){ var results, i$, len$, x, key; results = {}; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; key = f(x); if (key in results) { results[key].push(x); } else { results[key] = [x]; } } return results; }); andList = function(xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (!x) { return false; } } return true; }; orList = function(xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (x) { return true; } } return false; }; any = curry$(function(f, xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (f(x)) { return true; } } return false; }); all = curry$(function(f, xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (!f(x)) { return false; } } return true; }); sort = function(xs){ return xs.concat().sort(function(x, y){ if (x > y) { return 1; } else if (x < y) { return -1; } else { return 0; } }); }; sortWith = curry$(function(f, xs){ return xs.concat().sort(f); }); sortBy = curry$(function(f, xs){ return xs.concat().sort(function(x, y){ if (f(x) > f(y)) { return 1; } else if (f(x) < f(y)) { return -1; } else { return 0; } }); }); sum = function(xs){ var result, i$, len$, x; result = 0; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; result += x; } return result; }; product = function(xs){ var result, i$, len$, x; result = 1; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; result *= x; } return result; }; mean = average = function(xs){ var sum, i$, len$, x; sum = 0; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; sum += x; } return sum / xs.length; }; maximum = function(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 (x > max) { max = x; } } return max; }; minimum = function(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 (x < min) { min = x; } } return min; }; 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 = curry$(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){ var last, x; last = memo; 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$; }())); }); scan1 = scanl1 = curry$(function(f, xs){ if (!xs.length) { return; } return scan(f, xs[0], xs.slice(1)); }); scanr = curry$(function(f, memo, xs){ xs = xs.concat().reverse(); return scan(f, memo, xs).reverse(); }); scanr1 = curry$(function(f, xs){ if (!xs.length) { return; } xs = xs.concat().reverse(); return scan(f, xs[0], xs.slice(1)).reverse(); }); slice = curry$(function(x, y, xs){ return xs.slice(x, y); }); take = curry$(function(n, xs){ if (n <= 0) { return xs.slice(0, 0); } else { return xs.slice(0, n); } }); drop = curry$(function(n, xs){ if (n <= 0) { return xs; } else { return xs.slice(n); } }); splitAt = curry$(function(n, xs){ return [take(n, xs), drop(n, xs)]; }); takeWhile = curry$(function(p, xs){ var len, i; len = xs.length; if (!len) { return xs; } i = 0; while (i < len && p(xs[i])) { i += 1; } return xs.slice(0, i); }); dropWhile = curry$(function(p, xs){ var len, i; len = xs.length; if (!len) { return xs; } i = 0; while (i < len && p(xs[i])) { i += 1; } return xs.slice(i); }); span = curry$(function(p, xs){ return [takeWhile(p, xs), dropWhile(p, xs)]; }); breakList = curry$(function(p, xs){ return span(compose$(p, not$), xs); }); zip = curry$(function(xs, ys){ var result, len, i$, len$, i, x; result = []; len = ys.length; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { i = i$; x = xs[i$]; if (i === len) { break; } result.push([x, ys[i]]); } return result; }); zipWith = curry$(function(f, xs, ys){ var result, len, i$, len$, i, x; result = []; len = ys.length; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { i = i$; x = xs[i$]; if (i === len) { break; } result.push(f(x, ys[i])); } return result; }); zipAll = function(){ var xss, res$, i$, to$, minLength, len$, xs, ref$, i, lresult$, j$, results$ = []; res$ = []; for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } xss = res$; minLength = undefined; for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) { xs = xss[i$]; minLength <= (ref$ = xs.length) || (minLength = ref$); } for (i$ = 0; i$ < minLength; ++i$) { i = i$; lresult$ = []; for (j$ = 0, len$ = xss.length; j$ < len$; ++j$) { xs = xss[j$]; lresult$.push(xs[i]); } results$.push(lresult$); } return results$; }; zipAllWith = function(f){ var xss, res$, i$, to$, minLength, len$, xs, ref$, i, results$ = []; res$ = []; for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } xss = res$; minLength = undefined; for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) { xs = xss[i$]; minLength <= (ref$ = xs.length) || (minLength = ref$); } for (i$ = 0; i$ < minLength; ++i$) { i = i$; results$.push(f.apply(null, (fn$()))); } return results$; function fn$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = xss).length; i$ < len$; ++i$) { xs = ref$[i$]; results$.push(xs[i]); } return results$; } }; 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 = { each: each, map: map, filter: filter, compact: compact, reject: reject, remove: remove, partition: partition, find: find, head: head, first: first, tail: tail, last: last, initial: initial, empty: empty, reverse: reverse, difference: difference, intersection: intersection, union: union, countBy: countBy, groupBy: groupBy, fold: fold, fold1: fold1, foldl: foldl, foldl1: foldl1, foldr: foldr, foldr1: foldr1, unfoldr: unfoldr, andList: andList, orList: orList, any: any, all: all, unique: unique, uniqueBy: uniqueBy, sort: sort, sortWith: sortWith, sortBy: sortBy, sum: sum, product: product, mean: mean, average: average, concat: concat, concatMap: concatMap, flatten: flatten, maximum: maximum, minimum: minimum, maximumBy: maximumBy, minimumBy: minimumBy, scan: scan, scan1: scan1, scanl: scanl, scanl1: scanl1, scanr: scanr, scanr1: scanr1, slice: slice, take: take, drop: drop, splitAt: splitAt, takeWhile: takeWhile, dropWhile: dropWhile, span: span, breakList: breakList, zip: zip, zipWith: zipWith, zipAll: zipAll, zipAllWith: zipAllWith, at: at, elemIndex: elemIndex, elemIndices: elemIndices, findIndex: findIndex, findIndices: findIndices }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } function compose$() { var functions = arguments; return function() { var i, result; result = functions[0].apply(this, arguments); for (i = 1; i < functions.length; ++i) { result = functions[i](result); } return result; }; } function not$(x){ return !x; } },{}],3:[function(require,module,exports){ // Generated by LiveScript 1.6.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; max = curry$(function(x$, y$){ return x$ > y$ ? x$ : y$; }); min = curry$(function(x$, y$){ return x$ < y$ ? x$ : y$; }); negate = function(x){ return -x; }; abs = Math.abs; signum = function(x){ if (x < 0) { return -1; } else if (x > 0) { return 1; } else { return 0; } }; quot = curry$(function(x, y){ return ~~(x / y); }); rem = curry$(function(x$, y$){ return x$ % y$; }); div = curry$(function(x, y){ return Math.floor(x / y); }); mod = curry$(function(x$, y$){ var ref$; return ((x$) % (ref$ = y$) + ref$) % ref$; }); recip = (function(it){ return 1 / it; }); pi = Math.PI; tau = pi * 2; exp = Math.exp; sqrt = Math.sqrt; ln = Math.log; pow = curry$(function(x$, y$){ return Math.pow(x$, y$); }); sin = Math.sin; tan = Math.tan; cos = Math.cos; asin = Math.asin; acos = Math.acos; atan = Math.atan; atan2 = curry$(function(x, y){ return Math.atan2(x, y); }); truncate = function(x){ return ~~x; }; round = Math.round; ceiling = Math.ceil; floor = Math.floor; isItNaN = function(x){ return x !== x; }; even = function(x){ return x % 2 === 0; }; odd = function(x){ return x % 2 !== 0; }; gcd = curry$(function(x, y){ var z; x = Math.abs(x); y = Math.abs(y); while (y !== 0) { z = x % y; x = y; y = z; } return x; }); lcm = curry$(function(x, y){ return Math.abs(Math.floor(x / gcd(x, y) * y)); }); module.exports = { max: max, min: min, negate: negate, abs: abs, signum: signum, quot: quot, rem: rem, div: div, mod: mod, recip: recip, pi: pi, tau: tau, exp: exp, sqrt: sqrt, ln: ln, pow: pow, sin: sin, tan: tan, cos: cos, acos: acos, asin: asin, atan: atan, atan2: atan2, truncate: truncate, round: round, ceiling: ceiling, floor: floor, isItNaN: isItNaN, even: even, odd: odd, gcd: gcd, lcm: lcm }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } },{}],4:[function(require,module,exports){ // Generated by LiveScript 1.6.0 var values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty, each, map, compact, filter, reject, partition, find; values = function(object){ var i$, x, results$ = []; for (i$ in object) { x = object[i$]; results$.push(x); } return results$; }; keys = function(object){ var x, results$ = []; for (x in object) { results$.push(x); } return results$; }; pairsToObj = function(object){ var i$, len$, x, resultObj$ = {}; for (i$ = 0, len$ = object.length; i$ < len$; ++i$) { x = object[i$]; resultObj$[x[0]] = x[1]; } return resultObj$; }; objToPairs = function(object){ var key, value, results$ = []; for (key in object) { value = object[key]; results$.push([key, value]); } return results$; }; listsToObj = curry$(function(keys, values){ var i$, len$, i, key, resultObj$ = {}; for (i$ = 0, len$ = keys.length; i$ < len$; ++i$) { i = i$; key = keys[i$]; resultObj$[key] = values[i]; } return resultObj$; }); objToLists = function(object){ var keys, values, key, value; keys = []; values = []; for (key in object) { value = object[key]; keys.push(key); values.push(value); } return [keys, values]; }; empty = function(object){ var x; for (x in object) { return false; } return true; }; each = curry$(function(f, object){ var i$, x; for (i$ in object) { x = object[i$]; f(x); } return object; }); map = curry$(function(f, object){ var k, x, resultObj$ = {}; for (k in object) { x = object[k]; resultObj$[k] = f(x); } return resultObj$; }); compact = function(object){ var k, x, resultObj$ = {}; for (k in object) { x = object[k]; if (x) { resultObj$[k] = x; } } return resultObj$; }; filter = curry$(function(f, object){ var k, x, resultObj$ = {}; for (k in object) { x = object[k]; if (f(x)) { resultObj$[k] = x; } } return resultObj$; }); reject = curry$(function(f, object){ var k, x, resultObj$ = {}; for (k in object) { x = object[k]; if (!f(x)) { resultObj$[k] = x; } } return resultObj$; }); partition = curry$(function(f, object){ var passed, failed, k, x; passed = {}; failed = {}; for (k in object) { x = object[k]; (f(x) ? passed : failed)[k] = x; } return [passed, failed]; }); find = curry$(function(f, object){ var i$, x; for (i$ in object) { x = object[i$]; if (f(x)) { return x; } } }); module.exports = { values: values, keys: keys, pairsToObj: pairsToObj, objToPairs: objToPairs, listsToObj: listsToObj, objToLists: objToLists, empty: empty, each: each, map: map, filter: filter, compact: compact, reject: reject, partition: partition, find: find }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } },{}],5:[function(require,module,exports){ // Generated by LiveScript 1.6.0 var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capitalize, camelize, dasherize; split = curry$(function(sep, str){ return str.split(sep); }); join = curry$(function(sep, xs){ return xs.join(sep); }); lines = function(str){ if (!str.length) { return []; } return str.split('\n'); }; unlines = function(it){ return it.join('\n'); }; words = function(str){ if (!str.length) { return []; } return str.split(/[ ]+/); }; unwords = function(it){ return it.join(' '); }; chars = function(it){ return it.split(''); }; unchars = function(it){ return it.join(''); }; reverse = function(str){ return str.split('').reverse().join(''); }; repeat = curry$(function(n, str){ var result, i$; result = ''; for (i$ = 0; i$ < n; ++i$) { result += str; } 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 = { split: split, join: join, lines: lines, unlines: unlines, words: words, unwords: unwords, chars: chars, unchars: unchars, reverse: reverse, repeat: repeat, capitalize: capitalize, camelize: camelize, dasherize: dasherize }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } },{}],"prelude-ls":[function(require,module,exports){ // Generated by LiveScript 1.6.0 var Func, List, Obj, Str, Num, id, isType, replicate, prelude, toString$ = {}.toString; Func = require('./Func.js'); List = require('./List.js'); Obj = require('./Obj.js'); Str = require('./Str.js'); Num = require('./Num.js'); id = function(x){ return x; }; isType = curry$(function(type, x){ return toString$.call(x).slice(8, -1) === type; }); replicate = curry$(function(n, x){ var i$, results$ = []; for (i$ = 0; i$ < n; ++i$) { results$.push(x); } return results$; }); Str.empty = List.empty; Str.slice = List.slice; Str.take = List.take; Str.drop = List.drop; Str.splitAt = List.splitAt; Str.takeWhile = List.takeWhile; Str.dropWhile = List.dropWhile; Str.span = List.span; Str.breakStr = List.breakList; prelude = { Func: Func, List: List, Obj: Obj, Str: Str, Num: Num, id: id, isType: isType, replicate: replicate }; prelude.each = List.each; prelude.map = List.map; prelude.filter = List.filter; prelude.compact = List.compact; prelude.reject = List.reject; prelude.partition = List.partition; prelude.find = List.find; prelude.head = List.head; prelude.first = List.first; prelude.tail = List.tail; prelude.last = List.last; prelude.initial = List.initial; prelude.empty = List.empty; prelude.reverse = List.reverse; prelude.difference = List.difference; prelude.intersection = List.intersection; prelude.union = List.union; prelude.countBy = List.countBy; prelude.groupBy = List.groupBy; prelude.fold = List.fold; prelude.foldl = List.foldl; prelude.fold1 = List.fold1; prelude.foldl1 = List.foldl1; prelude.foldr = List.foldr; prelude.foldr1 = List.foldr1; prelude.unfoldr = List.unfoldr; prelude.andList = List.andList; prelude.orList = List.orList; prelude.any = List.any; prelude.all = List.all; prelude.unique = List.unique; prelude.uniqueBy = List.uniqueBy; prelude.sort = List.sort; prelude.sortWith = List.sortWith; prelude.sortBy = List.sortBy; prelude.sum = List.sum; prelude.product = List.product; prelude.mean = List.mean; prelude.average = List.average; prelude.concat = List.concat; prelude.concatMap = List.concatMap; prelude.flatten = List.flatten; prelude.maximum = List.maximum; prelude.minimum = List.minimum; prelude.maximumBy = List.maximumBy; prelude.minimumBy = List.minimumBy; prelude.scan = List.scan; prelude.scanl = List.scanl; prelude.scan1 = List.scan1; prelude.scanl1 = List.scanl1; prelude.scanr = List.scanr; prelude.scanr1 = List.scanr1; prelude.slice = List.slice; prelude.take = List.take; prelude.drop = List.drop; prelude.splitAt = List.splitAt; prelude.takeWhile = List.takeWhile; prelude.dropWhile = List.dropWhile; prelude.span = List.span; prelude.breakList = List.breakList; prelude.zip = List.zip; prelude.zipWith = List.zipWith; prelude.zipAll = List.zipAll; 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; prelude.curry = Func.curry; prelude.flip = Func.flip; prelude.fix = Func.fix; prelude.over = Func.over; prelude.split = Str.split; prelude.join = Str.join; prelude.lines = Str.lines; prelude.unlines = Str.unlines; prelude.words = Str.words; prelude.unwords = Str.unwords; prelude.chars = Str.chars; prelude.unchars = Str.unchars; prelude.repeat = Str.repeat; prelude.capitalize = Str.capitalize; prelude.camelize = Str.camelize; prelude.dasherize = Str.dasherize; prelude.values = Obj.values; prelude.keys = Obj.keys; prelude.pairsToObj = Obj.pairsToObj; prelude.objToPairs = Obj.objToPairs; prelude.listsToObj = Obj.listsToObj; prelude.objToLists = Obj.objToLists; prelude.max = Num.max; prelude.min = Num.min; prelude.negate = Num.negate; prelude.abs = Num.abs; prelude.signum = Num.signum; prelude.quot = Num.quot; prelude.rem = Num.rem; prelude.div = Num.div; prelude.mod = Num.mod; prelude.recip = Num.recip; prelude.pi = Num.pi; prelude.tau = Num.tau; prelude.exp = Num.exp; prelude.sqrt = Num.sqrt; prelude.ln = Num.ln; prelude.pow = Num.pow; prelude.sin = Num.sin; prelude.tan = Num.tan; prelude.cos = Num.cos; prelude.acos = Num.acos; prelude.asin = Num.asin; prelude.atan = Num.atan; prelude.atan2 = Num.atan2; prelude.truncate = Num.truncate; prelude.round = Num.round; prelude.ceiling = Num.ceiling; prelude.floor = Num.floor; prelude.isItNaN = Num.isItNaN; prelude.even = Num.even; prelude.odd = Num.odd; prelude.gcd = Num.gcd; prelude.lcm = Num.lcm; prelude.VERSION = '1.2.1'; module.exports = prelude; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } },{"./Func.js":1,"./List.js":2,"./Num.js":3,"./Obj.js":4,"./Str.js":5}]},{},[]); ================================================ FILE: lib/Func.js ================================================ // Generated by LiveScript 1.6.0 var apply, curry, flip, fix, over, memoize, toString$ = {}.toString; apply = curry$(function(f, list){ return f.apply(null, list); }); curry = function(f){ return curry$(f); }; flip = curry$(function(f, x, y){ return f(y, x); }); fix = function(f){ return function(g){ return function(){ return f(g(g)).apply(null, arguments); }; }(function(g){ return function(){ return f(g(g)).apply(null, arguments); }; }); }; over = curry$(function(f, g, x, y){ return f(g(x), g(y)); }); memoize = function(f){ var memo; memo = {}; return function(){ var args, res$, i$, to$, key, arg; res$ = []; for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } args = res$; key = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = args).length; i$ < len$; ++i$) { arg = ref$[i$]; results$.push(arg + toString$.call(arg).slice(8, -1)); } return results$; }()).join(''); return memo[key] = key in memo ? memo[key] : f.apply(null, args); }; }; module.exports = { curry: curry, flip: flip, fix: fix, apply: apply, over: over, memoize: memoize }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } ================================================ FILE: lib/List.js ================================================ // Generated by LiveScript 1.6.0 var each, map, compact, filter, reject, remove, 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; each = curry$(function(f, xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; f(x); } return xs; }); map = curry$(function(f, xs){ var i$, len$, x, results$ = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; results$.push(f(x)); } return results$; }); compact = function(xs){ var i$, len$, x, results$ = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (x) { results$.push(x); } } return results$; }; filter = curry$(function(f, xs){ var i$, len$, x, results$ = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (f(x)) { results$.push(x); } } return results$; }); reject = curry$(function(f, xs){ var i$, len$, x, results$ = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (!f(x)) { results$.push(x); } } return results$; }); remove = curry$(function(el, xs){ var i, x$; i = elemIndex(el, xs); x$ = xs.slice(); if (i != null) { x$.splice(i, 1); } return x$; }); partition = curry$(function(f, xs){ var passed, failed, i$, len$, x; passed = []; failed = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; (f(x) ? passed : failed).push(x); } return [passed, failed]; }); find = curry$(function(f, xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (f(x)) { return x; } } }); head = first = function(xs){ return xs[0]; }; tail = function(xs){ if (!xs.length) { return; } return xs.slice(1); }; last = function(xs){ return xs[xs.length - 1]; }; initial = function(xs){ if (!xs.length) { return; } return xs.slice(0, -1); }; empty = function(xs){ return !xs.length; }; reverse = function(xs){ return xs.concat().reverse(); }; unique = function(xs){ var result, i$, len$, x; result = []; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (!in$(x, result)) { result.push(x); } } return result; }; uniqueBy = curry$(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){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; memo = f(memo, x); } return memo; }); fold1 = foldl1 = curry$(function(f, xs){ return fold(f, xs[0], xs.slice(1)); }); foldr = curry$(function(f, memo, xs){ 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){ return foldr(f, xs[xs.length - 1], xs.slice(0, -1)); }); unfoldr = curry$(function(f, b){ var result, x, that; result = []; x = b; while ((that = f(x)) != null) { result.push(that[0]); x = that[1]; } return result; }); concat = function(xss){ return [].concat.apply([], xss); }; concatMap = curry$(function(f, xs){ var x; return [].concat.apply([], (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) { x = ref$[i$]; results$.push(f(x)); } return results$; }())); }); flatten = function(xs){ var x; return [].concat.apply([], (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) { x = ref$[i$]; if (toString$.call(x).slice(8, -1) === 'Array') { results$.push(flatten(x)); } else { results$.push(x); } } return results$; }())); }; difference = function(xs){ var yss, res$, i$, to$, results, len$, x, j$, len1$, ys; res$ = []; for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } yss = res$; results = []; outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) { ys = yss[j$]; if (in$(x, ys)) { continue outer; } } results.push(x); } return results; }; intersection = function(xs){ var yss, res$, i$, to$, results, len$, x, j$, len1$, ys; res$ = []; for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } yss = res$; results = []; outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) { ys = yss[j$]; if (!in$(x, ys)) { continue outer; } } results.push(x); } return results; }; union = function(){ var xss, res$, i$, to$, results, len$, xs, j$, len1$, x; res$ = []; for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } xss = res$; results = []; for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) { xs = xss[i$]; for (j$ = 0, len1$ = xs.length; j$ < len1$; ++j$) { x = xs[j$]; if (!in$(x, results)) { results.push(x); } } } return results; }; countBy = curry$(function(f, xs){ var results, i$, len$, x, key; results = {}; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; key = f(x); if (key in results) { results[key] += 1; } else { results[key] = 1; } } return results; }); groupBy = curry$(function(f, xs){ var results, i$, len$, x, key; results = {}; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; key = f(x); if (key in results) { results[key].push(x); } else { results[key] = [x]; } } return results; }); andList = function(xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (!x) { return false; } } return true; }; orList = function(xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (x) { return true; } } return false; }; any = curry$(function(f, xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (f(x)) { return true; } } return false; }); all = curry$(function(f, xs){ var i$, len$, x; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; if (!f(x)) { return false; } } return true; }); sort = function(xs){ return xs.concat().sort(function(x, y){ if (x > y) { return 1; } else if (x < y) { return -1; } else { return 0; } }); }; sortWith = curry$(function(f, xs){ return xs.concat().sort(f); }); sortBy = curry$(function(f, xs){ return xs.concat().sort(function(x, y){ if (f(x) > f(y)) { return 1; } else if (f(x) < f(y)) { return -1; } else { return 0; } }); }); sum = function(xs){ var result, i$, len$, x; result = 0; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; result += x; } return result; }; product = function(xs){ var result, i$, len$, x; result = 1; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; result *= x; } return result; }; mean = average = function(xs){ var sum, i$, len$, x; sum = 0; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { x = xs[i$]; sum += x; } return sum / xs.length; }; maximum = function(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 (x > max) { max = x; } } return max; }; minimum = function(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 (x < min) { min = x; } } return min; }; 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 = curry$(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){ var last, x; last = memo; 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$; }())); }); scan1 = scanl1 = curry$(function(f, xs){ if (!xs.length) { return; } return scan(f, xs[0], xs.slice(1)); }); scanr = curry$(function(f, memo, xs){ xs = xs.concat().reverse(); return scan(f, memo, xs).reverse(); }); scanr1 = curry$(function(f, xs){ if (!xs.length) { return; } xs = xs.concat().reverse(); return scan(f, xs[0], xs.slice(1)).reverse(); }); slice = curry$(function(x, y, xs){ return xs.slice(x, y); }); take = curry$(function(n, xs){ if (n <= 0) { return xs.slice(0, 0); } else { return xs.slice(0, n); } }); drop = curry$(function(n, xs){ if (n <= 0) { return xs; } else { return xs.slice(n); } }); splitAt = curry$(function(n, xs){ return [take(n, xs), drop(n, xs)]; }); takeWhile = curry$(function(p, xs){ var len, i; len = xs.length; if (!len) { return xs; } i = 0; while (i < len && p(xs[i])) { i += 1; } return xs.slice(0, i); }); dropWhile = curry$(function(p, xs){ var len, i; len = xs.length; if (!len) { return xs; } i = 0; while (i < len && p(xs[i])) { i += 1; } return xs.slice(i); }); span = curry$(function(p, xs){ return [takeWhile(p, xs), dropWhile(p, xs)]; }); breakList = curry$(function(p, xs){ return span(compose$(p, not$), xs); }); zip = curry$(function(xs, ys){ var result, len, i$, len$, i, x; result = []; len = ys.length; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { i = i$; x = xs[i$]; if (i === len) { break; } result.push([x, ys[i]]); } return result; }); zipWith = curry$(function(f, xs, ys){ var result, len, i$, len$, i, x; result = []; len = ys.length; for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) { i = i$; x = xs[i$]; if (i === len) { break; } result.push(f(x, ys[i])); } return result; }); zipAll = function(){ var xss, res$, i$, to$, minLength, len$, xs, ref$, i, lresult$, j$, results$ = []; res$ = []; for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } xss = res$; minLength = undefined; for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) { xs = xss[i$]; minLength <= (ref$ = xs.length) || (minLength = ref$); } for (i$ = 0; i$ < minLength; ++i$) { i = i$; lresult$ = []; for (j$ = 0, len$ = xss.length; j$ < len$; ++j$) { xs = xss[j$]; lresult$.push(xs[i]); } results$.push(lresult$); } return results$; }; zipAllWith = function(f){ var xss, res$, i$, to$, minLength, len$, xs, ref$, i, results$ = []; res$ = []; for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) { res$.push(arguments[i$]); } xss = res$; minLength = undefined; for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) { xs = xss[i$]; minLength <= (ref$ = xs.length) || (minLength = ref$); } for (i$ = 0; i$ < minLength; ++i$) { i = i$; results$.push(f.apply(null, (fn$()))); } return results$; function fn$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = xss).length; i$ < len$; ++i$) { xs = ref$[i$]; results$.push(xs[i]); } return results$; } }; 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 = { each: each, map: map, filter: filter, compact: compact, reject: reject, remove: remove, partition: partition, find: find, head: head, first: first, tail: tail, last: last, initial: initial, empty: empty, reverse: reverse, difference: difference, intersection: intersection, union: union, countBy: countBy, groupBy: groupBy, fold: fold, fold1: fold1, foldl: foldl, foldl1: foldl1, foldr: foldr, foldr1: foldr1, unfoldr: unfoldr, andList: andList, orList: orList, any: any, all: all, unique: unique, uniqueBy: uniqueBy, sort: sort, sortWith: sortWith, sortBy: sortBy, sum: sum, product: product, mean: mean, average: average, concat: concat, concatMap: concatMap, flatten: flatten, maximum: maximum, minimum: minimum, maximumBy: maximumBy, minimumBy: minimumBy, scan: scan, scan1: scan1, scanl: scanl, scanl1: scanl1, scanr: scanr, scanr1: scanr1, slice: slice, take: take, drop: drop, splitAt: splitAt, takeWhile: takeWhile, dropWhile: dropWhile, span: span, breakList: breakList, zip: zip, zipWith: zipWith, zipAll: zipAll, zipAllWith: zipAllWith, at: at, elemIndex: elemIndex, elemIndices: elemIndices, findIndex: findIndex, findIndices: findIndices }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } function compose$() { var functions = arguments; return function() { var i, result; result = functions[0].apply(this, arguments); for (i = 1; i < functions.length; ++i) { result = functions[i](result); } return result; }; } function not$(x){ return !x; } ================================================ FILE: lib/Num.js ================================================ // Generated by LiveScript 1.6.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; max = curry$(function(x$, y$){ return x$ > y$ ? x$ : y$; }); min = curry$(function(x$, y$){ return x$ < y$ ? x$ : y$; }); negate = function(x){ return -x; }; abs = Math.abs; signum = function(x){ if (x < 0) { return -1; } else if (x > 0) { return 1; } else { return 0; } }; quot = curry$(function(x, y){ return ~~(x / y); }); rem = curry$(function(x$, y$){ return x$ % y$; }); div = curry$(function(x, y){ return Math.floor(x / y); }); mod = curry$(function(x$, y$){ var ref$; return ((x$) % (ref$ = y$) + ref$) % ref$; }); recip = (function(it){ return 1 / it; }); pi = Math.PI; tau = pi * 2; exp = Math.exp; sqrt = Math.sqrt; ln = Math.log; pow = curry$(function(x$, y$){ return Math.pow(x$, y$); }); sin = Math.sin; tan = Math.tan; cos = Math.cos; asin = Math.asin; acos = Math.acos; atan = Math.atan; atan2 = curry$(function(x, y){ return Math.atan2(x, y); }); truncate = function(x){ return ~~x; }; round = Math.round; ceiling = Math.ceil; floor = Math.floor; isItNaN = function(x){ return x !== x; }; even = function(x){ return x % 2 === 0; }; odd = function(x){ return x % 2 !== 0; }; gcd = curry$(function(x, y){ var z; x = Math.abs(x); y = Math.abs(y); while (y !== 0) { z = x % y; x = y; y = z; } return x; }); lcm = curry$(function(x, y){ return Math.abs(Math.floor(x / gcd(x, y) * y)); }); module.exports = { max: max, min: min, negate: negate, abs: abs, signum: signum, quot: quot, rem: rem, div: div, mod: mod, recip: recip, pi: pi, tau: tau, exp: exp, sqrt: sqrt, ln: ln, pow: pow, sin: sin, tan: tan, cos: cos, acos: acos, asin: asin, atan: atan, atan2: atan2, truncate: truncate, round: round, ceiling: ceiling, floor: floor, isItNaN: isItNaN, even: even, odd: odd, gcd: gcd, lcm: lcm }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } ================================================ FILE: lib/Obj.js ================================================ // Generated by LiveScript 1.6.0 var values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty, each, map, compact, filter, reject, partition, find; values = function(object){ var i$, x, results$ = []; for (i$ in object) { x = object[i$]; results$.push(x); } return results$; }; keys = function(object){ var x, results$ = []; for (x in object) { results$.push(x); } return results$; }; pairsToObj = function(object){ var i$, len$, x, resultObj$ = {}; for (i$ = 0, len$ = object.length; i$ < len$; ++i$) { x = object[i$]; resultObj$[x[0]] = x[1]; } return resultObj$; }; objToPairs = function(object){ var key, value, results$ = []; for (key in object) { value = object[key]; results$.push([key, value]); } return results$; }; listsToObj = curry$(function(keys, values){ var i$, len$, i, key, resultObj$ = {}; for (i$ = 0, len$ = keys.length; i$ < len$; ++i$) { i = i$; key = keys[i$]; resultObj$[key] = values[i]; } return resultObj$; }); objToLists = function(object){ var keys, values, key, value; keys = []; values = []; for (key in object) { value = object[key]; keys.push(key); values.push(value); } return [keys, values]; }; empty = function(object){ var x; for (x in object) { return false; } return true; }; each = curry$(function(f, object){ var i$, x; for (i$ in object) { x = object[i$]; f(x); } return object; }); map = curry$(function(f, object){ var k, x, resultObj$ = {}; for (k in object) { x = object[k]; resultObj$[k] = f(x); } return resultObj$; }); compact = function(object){ var k, x, resultObj$ = {}; for (k in object) { x = object[k]; if (x) { resultObj$[k] = x; } } return resultObj$; }; filter = curry$(function(f, object){ var k, x, resultObj$ = {}; for (k in object) { x = object[k]; if (f(x)) { resultObj$[k] = x; } } return resultObj$; }); reject = curry$(function(f, object){ var k, x, resultObj$ = {}; for (k in object) { x = object[k]; if (!f(x)) { resultObj$[k] = x; } } return resultObj$; }); partition = curry$(function(f, object){ var passed, failed, k, x; passed = {}; failed = {}; for (k in object) { x = object[k]; (f(x) ? passed : failed)[k] = x; } return [passed, failed]; }); find = curry$(function(f, object){ var i$, x; for (i$ in object) { x = object[i$]; if (f(x)) { return x; } } }); module.exports = { values: values, keys: keys, pairsToObj: pairsToObj, objToPairs: objToPairs, listsToObj: listsToObj, objToLists: objToLists, empty: empty, each: each, map: map, filter: filter, compact: compact, reject: reject, partition: partition, find: find }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } ================================================ FILE: lib/Str.js ================================================ // Generated by LiveScript 1.6.0 var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capitalize, camelize, dasherize; split = curry$(function(sep, str){ return str.split(sep); }); join = curry$(function(sep, xs){ return xs.join(sep); }); lines = function(str){ if (!str.length) { return []; } return str.split('\n'); }; unlines = function(it){ return it.join('\n'); }; words = function(str){ if (!str.length) { return []; } return str.split(/[ ]+/); }; unwords = function(it){ return it.join(' '); }; chars = function(it){ return it.split(''); }; unchars = function(it){ return it.join(''); }; reverse = function(str){ return str.split('').reverse().join(''); }; repeat = curry$(function(n, str){ var result, i$; result = ''; for (i$ = 0; i$ < n; ++i$) { result += str; } 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 = { split: split, join: join, lines: lines, unlines: unlines, words: words, unwords: unwords, chars: chars, unchars: unchars, reverse: reverse, repeat: repeat, capitalize: capitalize, camelize: camelize, dasherize: dasherize }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } ================================================ FILE: lib/index.js ================================================ // Generated by LiveScript 1.6.0 var Func, List, Obj, Str, Num, id, isType, replicate, prelude, toString$ = {}.toString; Func = require('./Func.js'); List = require('./List.js'); Obj = require('./Obj.js'); Str = require('./Str.js'); Num = require('./Num.js'); id = function(x){ return x; }; isType = curry$(function(type, x){ return toString$.call(x).slice(8, -1) === type; }); replicate = curry$(function(n, x){ var i$, results$ = []; for (i$ = 0; i$ < n; ++i$) { results$.push(x); } return results$; }); Str.empty = List.empty; Str.slice = List.slice; Str.take = List.take; Str.drop = List.drop; Str.splitAt = List.splitAt; Str.takeWhile = List.takeWhile; Str.dropWhile = List.dropWhile; Str.span = List.span; Str.breakStr = List.breakList; prelude = { Func: Func, List: List, Obj: Obj, Str: Str, Num: Num, id: id, isType: isType, replicate: replicate }; prelude.each = List.each; prelude.map = List.map; prelude.filter = List.filter; prelude.compact = List.compact; prelude.reject = List.reject; prelude.partition = List.partition; prelude.find = List.find; prelude.head = List.head; prelude.first = List.first; prelude.tail = List.tail; prelude.last = List.last; prelude.initial = List.initial; prelude.empty = List.empty; prelude.reverse = List.reverse; prelude.difference = List.difference; prelude.intersection = List.intersection; prelude.union = List.union; prelude.countBy = List.countBy; prelude.groupBy = List.groupBy; prelude.fold = List.fold; prelude.foldl = List.foldl; prelude.fold1 = List.fold1; prelude.foldl1 = List.foldl1; prelude.foldr = List.foldr; prelude.foldr1 = List.foldr1; prelude.unfoldr = List.unfoldr; prelude.andList = List.andList; prelude.orList = List.orList; prelude.any = List.any; prelude.all = List.all; prelude.unique = List.unique; prelude.uniqueBy = List.uniqueBy; prelude.sort = List.sort; prelude.sortWith = List.sortWith; prelude.sortBy = List.sortBy; prelude.sum = List.sum; prelude.product = List.product; prelude.mean = List.mean; prelude.average = List.average; prelude.concat = List.concat; prelude.concatMap = List.concatMap; prelude.flatten = List.flatten; prelude.maximum = List.maximum; prelude.minimum = List.minimum; prelude.maximumBy = List.maximumBy; prelude.minimumBy = List.minimumBy; prelude.scan = List.scan; prelude.scanl = List.scanl; prelude.scan1 = List.scan1; prelude.scanl1 = List.scanl1; prelude.scanr = List.scanr; prelude.scanr1 = List.scanr1; prelude.slice = List.slice; prelude.take = List.take; prelude.drop = List.drop; prelude.splitAt = List.splitAt; prelude.takeWhile = List.takeWhile; prelude.dropWhile = List.dropWhile; prelude.span = List.span; prelude.breakList = List.breakList; prelude.zip = List.zip; prelude.zipWith = List.zipWith; prelude.zipAll = List.zipAll; 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; prelude.curry = Func.curry; prelude.flip = Func.flip; prelude.fix = Func.fix; prelude.over = Func.over; prelude.split = Str.split; prelude.join = Str.join; prelude.lines = Str.lines; prelude.unlines = Str.unlines; prelude.words = Str.words; prelude.unwords = Str.unwords; prelude.chars = Str.chars; prelude.unchars = Str.unchars; prelude.repeat = Str.repeat; prelude.capitalize = Str.capitalize; prelude.camelize = Str.camelize; prelude.dasherize = Str.dasherize; prelude.values = Obj.values; prelude.keys = Obj.keys; prelude.pairsToObj = Obj.pairsToObj; prelude.objToPairs = Obj.objToPairs; prelude.listsToObj = Obj.listsToObj; prelude.objToLists = Obj.objToLists; prelude.max = Num.max; prelude.min = Num.min; prelude.negate = Num.negate; prelude.abs = Num.abs; prelude.signum = Num.signum; prelude.quot = Num.quot; prelude.rem = Num.rem; prelude.div = Num.div; prelude.mod = Num.mod; prelude.recip = Num.recip; prelude.pi = Num.pi; prelude.tau = Num.tau; prelude.exp = Num.exp; prelude.sqrt = Num.sqrt; prelude.ln = Num.ln; prelude.pow = Num.pow; prelude.sin = Num.sin; prelude.tan = Num.tan; prelude.cos = Num.cos; prelude.acos = Num.acos; prelude.asin = Num.asin; prelude.atan = Num.atan; prelude.atan2 = Num.atan2; prelude.truncate = Num.truncate; prelude.round = Num.round; prelude.ceiling = Num.ceiling; prelude.floor = Num.floor; prelude.isItNaN = Num.isItNaN; prelude.even = Num.even; prelude.odd = Num.odd; prelude.gcd = Num.gcd; prelude.lcm = Num.lcm; prelude.VERSION = '1.2.1'; module.exports = prelude; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); } ================================================ FILE: package.json ================================================ { "name": "prelude-ls", "version": "1.2.1", "author": "George Zahariev ", "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.", "keywords": [ "prelude", "livescript", "utility", "ls", "coffeescript", "javascript", "library", "functional", "array", "list", "object", "string" ], "main": "lib/", "files": [ "lib/", "README.md", "LICENSE" ], "homepage": "http://preludels.com", "bugs": "https://github.com/gkz/prelude-ls/issues", "license": "MIT", "engines": { "node": ">= 0.8.0" }, "repository": { "type": "git", "url": "git://github.com/gkz/prelude-ls.git" }, "scripts": { "test": "make test" }, "devDependencies": { "livescript": "^1.6.0", "uglify-js": "^3.8.1", "mocha": "^10.2.0", "browserify": "^16.5.1", "sinon": "~8.0.1" } } ================================================ FILE: package.json.ls ================================================ name: 'prelude-ls' version: '1.2.1' author: 'George Zahariev ' 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." keywords: 'prelude' 'livescript' 'utility' 'ls' 'coffeescript' 'javascript' 'library' 'functional' 'array' 'list' 'object' 'string' main: 'lib/' files: 'lib/' 'README.md' 'LICENSE' homepage: 'http://preludels.com' bugs: 'https://github.com/gkz/prelude-ls/issues' license: 'MIT' engines: node: '>= 0.8.0' repository: type: 'git' url: 'git://github.com/gkz/prelude-ls.git' scripts: test: "make test" dev-dependencies: livescript: "^1.6.0", 'uglify-js': "^3.8.1", mocha: "^7.1.1", browserify: "^16.5.1", sinon: "~8.0.1" ================================================ FILE: preroll.ls ================================================ version = require './lib' .VERSION {VERSION: ls-version} = require 'livescript' console.log """ // Generated by LiveScript #ls-version // prelude.ls #version // Copyright (c) George Zahariev // Released under the MIT License // https://raw.githubusercontent.com/gkz/prelude-ls/master/LICENSE """ ================================================ FILE: src/Func.ls ================================================ apply = (f, list) --> f.apply null, list curry = (f) -> curry$ f # using util method curry$ from livescript flip = (f, x, y) --> f y, x fix = (f) -> ( (g) -> -> f(g g) ...arguments ) do (g) -> -> f(g g) ...arguments over = (f, g, x, y) --> f (g x), (g y) memoize = (f) -> memo = {} (...args) -> key = [arg + typeof! arg for arg in args].join '' memo[key] = if key of memo then memo[key] else f ...args #? wrap module.exports = { curry, flip, fix, apply, over, memoize } ================================================ FILE: src/List.ls ================================================ each = (f, xs) --> for x in xs f x xs map = (f, xs) --> [f x for x in xs] compact = (xs) --> [x for x in xs when x] filter = (f, xs) --> [x for x in xs when f x] reject = (f, xs) --> [x for x in xs when not f x] remove = (el, xs) --> i = elem-index el, xs xs.slice! ..splice i, 1 if i? partition = (f, xs) --> passed = [] failed = [] for x in xs (if f x then passed else failed).push x [passed, failed] find = (f, xs) --> for x in xs when f x return x void head = first = (xs) -> xs.0 tail = (xs) -> return void unless xs.length xs.slice 1 last = (xs) -> xs[*-1] initial = (xs) -> return void unless xs.length xs.slice 0, -1 empty = (xs) -> not xs.length reverse = (xs) -> xs.concat!.reverse! unique = (xs) -> result = [] for x in xs when x not in result result.push x result unique-by = (f, xs) --> seen = [] for x in xs val = f x continue if val in seen seen.push val x fold = foldl = (f, memo, xs) --> for x in xs memo = f memo, x memo fold1 = foldl1 = (f, xs) --> fold f, xs.0, xs.slice 1 foldr = (f, memo, xs) --> for x in xs by -1 memo = f x, memo memo foldr1 = (f, xs) --> foldr f, xs[*-1], xs.slice 0, -1 unfoldr = (f, b) --> result = [] x = b while (f x)? result.push that.0 x = that.1 result concat = (xss) -> [].concat.apply [], xss concat-map = (f, xs) --> [].concat.apply [], [f x for x in xs] flatten = (xs) --> [].concat.apply [], [(if typeof! x is 'Array' then flatten x else x) for x in xs] difference = (xs, ...yss) -> results = [] :outer for x in xs for ys in yss continue outer if x in ys results.push x results intersection = (xs, ...yss) -> results = [] :outer for x in xs for ys in yss continue outer unless x in ys results.push x results union = (...xss) -> results = [] for xs in xss for x in xs results.push x unless x in results results count-by = (f, xs) --> results = {} for x in xs key = f x if key of results results[key] += 1 else results[key] = 1 results group-by = (f, xs) --> results = {} for x in xs key = f x if key of results results[key].push x else results[key] = [x] results and-list = (xs) -> for x in xs when not x return false true or-list = (xs) -> for x in xs when x return true false any = (f, xs) --> for x in xs when f x return true false all = (f, xs) --> for x in xs when not f x return false true sort = (xs) -> xs.concat!.sort (x, y) -> if x > y 1 else if x < y -1 else 0 sort-with = (f, xs) --> xs.concat!.sort f sort-by = (f, xs) --> xs.concat!.sort (x, y) -> if (f x) > (f y) 1 else if (f x) < (f y) -1 else 0 sum = (xs) -> result = 0 for x in xs result += x result product = (xs) -> result = 1 for x in xs result *= x result mean = average = (xs) -> sum = 0 for x in xs sum += x sum / xs.length maximum = (xs) -> max = xs.0 for x in xs.slice 1 when x > max max = x max minimum = (xs) -> min = xs.0 for x in xs.slice 1 when x < min min = x min maximum-by = (f, xs) --> max = xs.0 for x in xs.slice 1 when (f x) > (f max) max = x max minimum-by = (f, xs) --> min = xs.0 for x in xs.slice 1 when (f x) < (f min) min = x min scan = scanl = (f, memo, xs) --> last = memo [memo] ++ [last = f last, x for x in xs] scan1 = scanl1 = (f, xs) --> return void unless xs.length scan f, xs.0, xs.slice 1 scanr = (f, memo, xs) --> xs = xs.concat!.reverse! (scan f, memo, xs).reverse! scanr1 = (f, xs) --> return void unless xs.length xs = xs.concat!.reverse! (scan f, xs.0, xs.slice 1).reverse! slice = (x, y, xs) --> xs.slice x, y take = (n, xs) --> if n <= 0 xs.slice 0, 0 else xs.slice 0, n drop = (n, xs) --> if n <= 0 xs else xs.slice n split-at = (n, xs) --> [(take n, xs), (drop n, xs)] take-while = (p, xs) --> len = xs.length return xs unless len i = 0 while i < len and p xs[i] i += 1 xs.slice 0 i drop-while = (p, xs) --> len = xs.length return xs unless len i = 0 while i < len and p xs[i] i += 1 xs.slice i span = (p, xs) --> [(take-while p, xs), (drop-while p, xs)] break-list = (p, xs) --> span (not) << p, xs zip = (xs, ys) --> result = [] len = ys.length for x, i in xs break if i is len result.push [x, ys[i]] result zip-with = (f, xs, ys) --> result = [] len = ys.length for x, i in xs break if i is len result.push f x, ys[i] result zip-all = (...xss) -> min-length = undefined for xs in xss min-length min-length = undefined for xs in xss min-length if n < 0 then xs[xs.length + n] else xs[n] elem-index = (el, xs) --> for x, i in xs when x is el return i void elem-indices = (el, xs) --> [i for x, i in xs when x is el] find-index = (f, xs) --> for x, i in xs when f x return i void find-indices = (f, xs) --> [i for x, i in xs when f x] module.exports = { each, map, filter, compact, reject, remove, partition, find, head, first, tail, last, initial, empty, reverse, difference, intersection, union, count-by, group-by, fold, fold1, foldl, foldl1, foldr, foldr1, unfoldr, and-list, or-list, any, all, unique, unique-by, sort, sort-with, sort-by, sum, product, mean, average, concat, concat-map, flatten, maximum, minimum, maximum-by, minimum-by, scan, scan1, scanl, scanl1, scanr, scanr1, slice, take, drop, split-at, take-while, drop-while, span, break-list, zip, zip-with, zip-all, zip-all-with, at, elem-index, elem-indices, find-index, find-indices, } ================================================ FILE: src/Num.ls ================================================ max = (>?) min = ( -x abs = Math.abs signum = (x) -> if x < 0 -1 else if x > 0 1 else 0 quot = (x, y) --> ~~(x / y) rem = (%) div = (x, y) --> Math.floor x / y mod = (%%) recip = (1 /) pi = Math.PI tau = pi * 2 exp = Math.exp sqrt = Math.sqrt ln = Math.log pow = (^) sin = Math.sin tan = Math.tan cos = Math.cos asin = Math.asin acos = Math.acos atan = Math.atan atan2 = (x, y) --> Math.atan2 x, y truncate = (x) -> ~~x round = Math.round ceiling = Math.ceil floor = Math.floor is-it-NaN = (x) -> x isnt x even = (x) -> x % 2 == 0 odd = (x) -> x % 2 != 0 gcd = (x, y) --> x = Math.abs x y = Math.abs y until y is 0 z = x % y x = y y = z x lcm = (x, y) --> Math.abs Math.floor (x / (gcd x, y) * y) module.exports = { max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, acos, asin, atan, atan2, truncate, round, ceiling, floor, is-it-NaN, even, odd, gcd, lcm, } ================================================ FILE: src/Obj.ls ================================================ values = (object) -> [x for , x of object] keys = (object) -> [x for x of object] pairs-to-obj= (object) -> {[x.0, x.1] for x in object} obj-to-pairs = (object) -> [[key, value] for key, value of object] lists-to-obj = (keys, values) --> {[key, values[i]] for key, i in keys} obj-to-lists = (object) -> keys = [] values = [] for key, value of object keys.push key values.push value [keys, values] empty = (object) -> for x of object then return false true each = (f, object) --> for , x of object then f x object map = (f, object) --> {[k, f x] for k, x of object} compact = (object) --> {[k, x] for k, x of object when x} filter = (f, object) --> {[k, x] for k, x of object when f x} reject = (f, object) --> {[k, x] for k, x of object when not f x} partition = (f, object) --> passed = {} failed = {} for k, x of object (if f x then passed else failed)[k] = x [passed, failed] find = (f, object) --> for , x of object when f x then return x void module.exports = { values, keys, pairs-to-obj, obj-to-pairs, lists-to-obj, obj-to-lists, empty, each, map, filter, compact, reject, partition, find, } ================================================ FILE: src/Str.ls ================================================ split = (sep, str) --> str.split sep join = (sep, xs) --> xs.join sep lines = (str) -> return [] unless str.length str.split '\n' unlines = (.join '\n') words = (str) -> return [] unless str.length str.split /[ ]+/ unwords = (.join ' ') chars = (.split '') unchars = (.join '') reverse = (str) -> str.split '' .reverse!.join '' repeat = (n, str) --> result = '' for til n result += str result capitalize = (str) -> (str.char-at 0).to-upper-case! + str.slice 1 camelize = (.replace /[-_]+(.)?/g, (, c) -> (c ? '').to-upper-case!) # convert camelCase to camel-case, and setJSON to set-JSON dasherize = (str) -> str .replace /([^-A-Z])([A-Z]+)/g, (, lower, upper) -> "#{lower}-#{if upper.length > 1 then upper else upper.to-lower-case!}" .replace /^([A-Z]+)/, (, upper) -> if upper.length > 1 then "#upper-" else upper.to-lower-case! module.exports = { split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capitalize, camelize, dasherize, } ================================================ FILE: src/index.ls ================================================ require! [ './Func.js' './List.js' './Obj.js' './Str.js' './Num.js' ] id = (x) -> x is-type = (type, x) --> typeof! x is type replicate = (n, x) --> [x for til n] Str <<< List{ empty, slice, take, drop, split-at, take-while, drop-while, span, break-str: break-list } prelude = { Func, List, Obj, Str, Num, id, is-type replicate, } prelude <<< List{ each, map, filter, compact, reject, partition, find, head, first, tail, last, initial, empty, reverse, difference, intersection, union, count-by, group-by, fold, foldl, fold1, foldl1, foldr, foldr1, unfoldr, and-list, or-list, any, all, unique, unique-by, sort, sort-with, sort-by, sum, product, mean, average, concat, concat-map, flatten, maximum, minimum, maximum-by, minimum-by, scan, scanl, scan1, scanl1, scanr, scanr1, slice, take, drop, split-at, take-while, drop-while, span, break-list, zip, zip-with, zip-all, zip-all-with, at, elem-index, elem-indices, find-index, find-indices, } prelude <<< Func{ apply, curry, flip, fix, over, } prelude <<< Str{ split, join, lines, unlines, words, unwords, chars, unchars, repeat, capitalize, camelize, dasherize, } # not importing all of Obj's functions prelude <<< Obj{ values, keys, pairs-to-obj, obj-to-pairs, lists-to-obj, obj-to-lists, } prelude <<< Num{ max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, acos, asin, atan, atan2, truncate, round, ceiling, floor, is-it-NaN, even, odd, gcd, lcm, } prelude.VERSION = '1.2.1' module.exports = prelude ================================================ FILE: test/Func.ls ================================================ require! \sinon {apply, curry, flip, fix, over, memoize} = require '..' .Func {strict-equal: eq, not-strict-equal: not-eq, deep-equal: deep-eq, ok} = require 'assert' suite 'apply' -> test 'empty list' -> f = -> 1 eq 1, apply f, [] test 'a couple of args' -> eq 5, apply (+), [2 3] test 'curried' -> f = apply (+) eq 5, f [2 3] suite 'curry' -> test 'simple function' -> add = (x, y) -> x + y add-curried = curry add add-four = add-curried 4 eq 6 add-four 2 suite 'flip' -> test 'minus op' -> eq 10, (flip (-)) 5 15 suite 'fix' -> test 'single arg' -> eq 89, (fix (fib) -> (n) -> | n <= 1 => 1 | otherwise => fib(n-1) + fib(n-2))(10) test 'multi-arg variation' -> eq 89, (fix (fib) -> (n, minus=0) -> | (n - minus) <= 1 => 1 | otherwise => fib(n, minus+1) + fib(n, minus+2))(10) suite 'over' -> test 'basic' -> f = (==) `over` (-> it) ok f 2 2 ok not f 2 3 test 'with accessor function' -> same-length = (==) `over` (.length) ok same-length [1 2 3] [4 5 6] ok not same-length [1 2] [4 5 6] suite 'memoize' -> spy = f = null setup -> spy := sinon.spy -> & f := memoize spy test 'only 1 call when using the same arguments' -> [0 to 10].for-each -> f! ok spy.called-once test 'call again when using different arguments' -> f \mung f \mung f '1,2' f [1 2] ok spy.called-thrice test 'that the correct values are returned' -> eq f(\mung), f(\mung) eq f(\mung \face), f(\mung \face) not-eq f(\mung), f(\mung \face) ================================================ FILE: test/List.ls ================================================ { id Num: {even, odd, floor, is-it-NaN} List: { each, map, filter, compact, reject, remove, partition, find, head, first, tail, last, initial, empty, reverse, difference, intersection, union, count-by, group-by, fold, fold1, foldl, foldl1, foldr, foldr1, unfoldr, and-list, or-list, any, all, unique, unique-by, sort, sort-with, sort-by, sum, product, mean, average, concat, concat-map, flatten, maximum, minimum, maximum-by, minimum-by, scan, scan1, scanl, scanl1, scanr, scanr1, slice, take, drop, split-at, take-while, drop-while, span, break-list, zip, zip-with, zip-all, zip-all-with, at, elem-index, elem-indices, find-index, find-indices, } } = require '..' {strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert' suite 'each' -> test 'empty list as input' -> deep-eq [], each id, [] test 'side effects affect input (and thus result)' -> deep-eq [[1],[2]] each (.pop!), [[1 5] [2 6]] test 'curried' -> f = each (.pop!) deep-eq [[1],[2]], f [[1 5] [2 6]] suite 'map' -> test 'empty list as input' -> deep-eq [], map id, [] test 'mapping over array' -> deep-eq [2 3 4], map (+ 1), [1 2 3] test 'curried' -> f = map (+ 1) deep-eq [2 3 4], f [1 2 3] suite 'compact' -> test 'empty list as input' -> deep-eq [], compact [] test 'compacting array' -> deep-eq [1 true 'ha'], compact [0 1 false true '' 'ha'] suite 'filter' -> test 'empty list as input' -> deep-eq [], filter id, [] test 'filtering array' -> deep-eq [2, 4], filter even, [1 to 5] test 'filter on true returns original list' -> deep-eq [1 2 3], filter (-> true), [1 2 3] test 'filter on false returns empty list' -> deep-eq [], filter (-> false), [1 2 3] test 'curried' -> f = filter even deep-eq [2, 4], f [1 to 5] suite 'reject' -> test 'empty list as input' -> deep-eq [], reject id, [] test 'reject list' -> deep-eq [1 3 5], reject even, [1 to 5] test 'reject on true returns empty list' -> deep-eq [], reject (-> true), [1 2 3] test 'reject on true returns original list' -> deep-eq [1 2 3], reject (-> false), [1 2 3] test 'curried' -> f = reject even deep-eq [1 3 5], f [1 to 5] suite 'remove' -> test 'empty list as input' -> deep-eq [], remove 2, [] test 'basic' -> deep-eq [1 3], remove 2, [1 2 3] test 'multiple' -> deep-eq [1 3 2], remove 2, [1 2 3 2] test 'not there' -> deep-eq [1 2 3], remove 5, [1 2 3] test 'curried' -> f = remove 2 deep-eq [1 3], f [1 2 3] suite 'partition' -> test 'empty list as input' -> deep-eq [[],[]], partition id, [] test 'partition list' -> deep-eq [[76 88 77 90],[49 58 43]], partition (>60), [49 58 76 43 88 77 90] test 'partition on true returns original list as passing, empty list as failing' -> deep-eq [[1 2 3],[]], partition (-> true), [1 2 3] test 'partition on false returns empty list as failing, empty list as passing' -> deep-eq [[], [1 2 3]], partition (-> false), [1 2 3] test 'curried' -> f = partition (>60) deep-eq [[76 88 77 90],[49 58 43]], f [49 58 76 43 88 77 90] suite 'find' -> test 'empty list as input' -> eq void, find id, [] test 'find from list' -> eq 4, find even, [3 1 4 8 6] test 'finding nothing when function always false' -> eq void, find (-> false), [1 2 3] test 'find first item when function always true' -> eq 1, find (-> true), [1 2 3] test 'curried' -> f = find even eq 4, f [3 1 4 8 6] suite 'list portions' -> list = [1 2 3 4 5] suite 'head' -> test 'empty list as input' -> eq void, head [] test 'list' -> eq 1, head list test 'first as alias' -> eq first, head suite 'tail' -> test 'empty list as input' -> eq void, tail [] test 'list' -> deep-eq [2 3 4 5], tail list test 'one element list' -> deep-eq [], tail [1] suite 'last' -> test 'empty list as input' -> eq void, last [] test 'list' -> eq 5, last list test 'one element list' -> eq 1, last [1] suite 'initial' -> test 'empty list as input' -> eq void, initial [] test 'list' -> deep-eq [1 2 3 4], initial list test 'one element list' -> deep-eq [], initial [1] suite 'empty' -> test 'empty list as input' -> ok empty [] test 'non-empty list as input' -> ok not empty [1] suite 'reverse' -> test 'empty list as input' -> deep-eq [], reverse [] test 'reverse list, it is unmodified' -> list = [1 2 3 4 5] deep-eq [5 4 3 2 1], reverse list deep-eq [1 2 3 4 5], list suite 'unique' -> test 'empty list as input' -> deep-eq [], unique [] test 'unique list' -> deep-eq [1,2,3,4,5,6], unique [1 1 2 3 3 4 5 5 5 5 5 6 6 6 6] test 'mixed string/num' -> deep-eq ['1' 1 2 4 5], unique ['1' 1 2 4 5 5] suite 'unique-by' -> test 'empty list as input' -> deep-eq [], unique-by id, [] test 'basic' -> deep-eq [1,2,3,4,5,6], unique-by id, [1 1 2 3 3 4 5 5 5 5 5 6 6 6 6] test 'accessor' -> deep-eq [[] [1 2 3] [4] [5 6]], unique-by (.length), [[], [1 2 3], [4], [5 6], [7], [8 9 10]] test 'curried' -> deep-eq [1,2,3,4,5,6], (unique-by id) [1 1 2 3 3 4 5 5 5 5 5 6 6 6 6] suite 'fold' -> test 'empty list as input' -> eq 0, fold (+), 0, [] test 'list as input' -> eq 12, fold (+), 0, [1 2 3 6] test 'foldl is alias' -> eq fold, foldl test 'curried' -> f = fold (+) eq 12, f 0, [1 2 3 6] g = fold (+), 0 eq 12 g [1 2 3 6] suite 'fold1' -> test 'empty list as input' -> eq void, fold1 (+), [] test 'list as input' -> eq 12, fold1 (+), [1 2 3 6] test 'foldl1 as alais' -> eq fold1, foldl1 test 'curried' -> f = fold1 (+) eq 12, f [1 2 3 6] suite 'foldr' -> test 'empty list as input' -> eq 0, foldr (+), 0, [] test 'list as input' -> eq 7, foldr (-), 9, [1 2 3 4] eq 'abcde', foldr (+), 'e', <[ a b c d ]> test 'curried' -> f = foldr (-) eq 7, f 9, [1 2 3 4] g = foldr (-), 9 eq 7, g [1 2 3 4] suite 'foldr1' -> test 'empty list as input' -> eq void, foldr1 (+), [] test 'list as input' -> eq 7, foldr1 (-), [1 2 3 4 9] eq 'abcde', foldr1 (+), <[ a b c d e ]> test 'curried' -> f = foldr1 (-) eq 7, f [1 2 3 4 9] suite 'unfoldr' -> test 'complex case' -> deep-eq [10,9,8,7,6,5,4,3,2,1], unfoldr (-> if it == 0 then null else [it, it - 1]), 10 test 'returning null right away results in a one item list' -> deep-eq [], unfoldr (-> null), 'a' test 'curried' -> f = unfoldr (-> if it == 0 then null else [it, it - 1]) deep-eq [10,9,8,7,6,5,4,3,2,1], f 10 suite 'concat' -> test 'empty list as input' -> deep-eq [], concat [] test 'multiple lists' -> deep-eq [1,2,3,4,5,6], concat [[1 2] [3 4] [5 6]] suite 'concat-map' -> test 'empty list as input' -> deep-eq [], concat-map id, [] test 'using mapping and concatinating' -> deep-eq [1,1,2,1,2,3], concat-map (-> [1 to it]), [1 2 3] test 'curried' -> f = concat-map (-> [1 to it]) deep-eq [1,1,2,1,2,3], f [1 2 3] suite 'flatten' -> test 'empty list as input' -> deep-eq [], flatten [] test 'nested lists as input' -> deep-eq [1,2,3,4,5], flatten [1, [[2], 3], [4, [[5]]]] test 'lists with strings' -> deep-eq ['a','b','c','d','e'], flatten ['a', [['b'], 'c'], ['d', [['e']]]] suite 'difference' -> test 'empty list(s) as input' -> deep-eq [], difference [] deep-eq [], difference [] [] test 'subtract nothing' -> deep-eq [1 2 3], difference [1 2 3] deep-eq [1 2 3], difference [1 2 3] [] test 'subtract single element' -> deep-eq [2 3], difference [1 2 3] [1] test 'subtract multiple elements' -> deep-eq [1 3 4], difference [1 2 3 4 5] [5 2 10] [9] suite 'intersection' -> test 'empty list(s) as input' -> deep-eq [], intersection [] deep-eq [], intersection [] [] test 'no common elements' -> deep-eq [],intersection [2 3] [9 8] [12 1] [99] test 'some common elements' -> deep-eq [1 2], intersection [1 2 3] [101 2 1 10] [2 1] [-1 0 1 2] test 'all common elements' -> deep-eq [1 2 3], intersection [1 2 3] [2 1 3] [3 1 2] suite 'union' -> test 'empty list(s) as input' -> deep-eq [], union [] deep-eq [], union [] [] test 'list and empty list' -> deep-eq [1 2 3], union [1 2 3] [] test 'with various' -> deep-eq [1 5 7 3], union [1 5 7] [3 5] [] suite 'count-by' -> test 'empty list as input' -> deep-eq {}, count-by id, [] test 'list of numbers' -> deep-eq {4: 1, 6: 2}, count-by floor, [4.2, 6.1, 6.4] test 'list of strings' -> deep-eq {3: 2, 5: 1}, count-by (.length), <[ one two three ]> test 'curried' -> f = count-by floor deep-eq {4: 1, 6: 2}, f [4.2, 6.1, 6.4] suite 'group-by' -> test 'empty list as input' -> deep-eq {}, group-by id, [] test 'list of numbers' -> deep-eq {4: [4.2], 6: [6.1 6.4]}, group-by floor, [4.2, 6.1, 6.4] test 'list of strings' -> deep-eq {3: <[ one two ]>, 5: <[ three ]>}, group-by (.length), <[ one two three ]> test 'curried' -> f = group-by floor deep-eq {4: [4.2], 6: [6.1 6.4]}, f [4.2, 6.1, 6.4] suite 'and-list' -> test 'empty list as input' -> ok and-list [] test 'true' -> ok and-list [true, 2 + 2 == 4] test 'false' -> ok not and-list [true true false true] suite 'or-list' -> test 'empty list as input' -> ok not or-list [] test 'true' -> ok or-list [false false false true false] test 'false' -> ok not or-list [false, 2 + 2 == 3] suite 'any' -> test 'empty list as input' -> ok not any id, [] test 'true' -> ok any even, [1 4 3] test 'false' -> ok not any even, [1 3 7 5] test 'curried' -> f = any even ok f [1 4 3] suite 'all' -> test 'empty list as input' -> ok all even, [] test 'true' -> ok all even, [2 4 6] test 'false' -> ok not all even, [2 5 6] test 'curried' -> f = all even ok f [2 4 6] suite 'sort' -> test 'empty list as input' -> deep-eq [], sort [] test 'single digit numbers' -> deep-eq [1,2,3,4,5,6], sort [3 1 5 2 4 6] test 'multi digit numbers' -> deep-eq [2,5,6,12,334,4999], sort [334 12 5 2 4999 6] test 'same digits' -> deep-eq [1 2 2 2 3], sort [2 3 2 1 2] suite 'sort-with' -> f = (x, y) -> | x.length > y.length => 1 | x.length < y.length => -1 | otherwise => 0 test 'empty list as input' -> deep-eq [], sort-with id, [] test 'complex case' -> deep-eq ['one','two','three'], sort-with f, <[ three one two ]> test 'curried' -> g = sort-with f deep-eq ['one','two','three'], g <[ three one two ]> suite 'sort-by' -> arr = 'hey' 'a' 'there' 'hey' 'ha' test 'empty list as input' -> deep-eq [], sort-by id, [] test 'complex case' -> deep-eq ['a', 'ha', 'hey', 'hey', 'there'], sort-by (.length), arr test 'curried' -> f = sort-by (.length) deep-eq ['a', 'ha', 'hey', 'hey', 'there'], f arr suite 'sum' -> test 'empty list as input' -> eq 0, sum [] test 'list as input' -> eq 10, sum [1 2 3 4] test 'negative numbers' -> eq -2, sum [1 -2 3 -4] suite 'product' -> test 'empty list as input' -> eq 1, product [] test 'list as input' -> eq 24, product [1 2 3 4] test 'negative numbers' -> eq -6, product [1 -2 3] suite 'mean' -> test 'empty list as input' -> ok is-it-NaN mean [] test 'list as input' -> eq 4, mean [2 3 4 5 6] test 'average as alias' -> eq mean, average suite 'maximum' -> test 'empty list as input' -> eq void, maximum [] test 'single element list' -> eq 1, maximum [1] test 'multi element list' -> eq 6, maximum [1 2 6 4 5] suite 'minimum' -> test 'empty list as input' -> eq void, minimum [] test 'single element list' -> eq 1, minimum [1] test 'multi element list' -> eq 2, minimum [4 3 2 6 9] test 'list of strings' -> eq 'a', minimum ['c', 'e', 'a', 'd', 'b'] suite 'maximum-by' -> test 'empty list as input' -> eq void, maximum-by id, [] test 'single element list' -> eq 1, maximum-by id, [1] test 'multi element list' -> eq 'long-string', maximum-by (.length), <[ hi there I am a really long-string ]> test 'curried' -> eq 2, (maximum-by id) [1 2 0] suite 'minimum-by' -> test 'empty list as input' -> eq void, minimum-by id, [] test 'single element list' -> eq 1, minimum-by id, [1] test 'multi element list' -> eq 'I', minimum-by (.length), <[ hi there I am a really long-string ]> test 'curried' -> eq 0, (minimum-by id) [1 2 0] suite 'scan' -> test 'empty list as input' -> deep-eq [null], scan id, null, [] test 'complex case' -> deep-eq [4,9,20,43], scan ((x, y) -> 2 * x + y), 4, [1 2 3] test 'scanl as alias' -> eq scan, scanl test 'curried' -> f = scan ((x, y) -> 2 * x + y) deep-eq [4,9,20,43], f 4, [1 2 3] g = scan ((x, y) -> 2 * x + y), 4 deep-eq [4,9,20,43], g [1 2 3] suite 'scan1' -> test 'empty list as input' -> deep-eq void, scan1 id, [] test 'complex case' -> deep-eq [1,3,6,10], scan1 (+), [1 2 3 4] test 'scanl1 as alias' -> eq scan1, scanl1 test 'curried' -> f = scan1 (+) deep-eq [1,3,6,10], f [1 2 3 4] suite 'scanr' -> test 'empty list as input' -> deep-eq [null], scanr id, null, [] test 'complex case' -> deep-eq [15,14,12,9,5], scanr (+), 5, [1 2 3 4] test 'curried' -> f = scanr (+) deep-eq [15,14,12,9,5], f 5, [1 2 3 4] g = scanr (+), 5 deep-eq [15,14,12,9,5], g [1 2 3 4] suite 'scanr1' -> test 'empty list as input' -> deep-eq void, scanr1 id, [] test 'complex case' -> deep-eq [10,9,7,4], scanr1 (+), [1 2 3 4] test 'curried' -> f = scanr1 (+) deep-eq [10,9,7,4], f [1 2 3 4] suite 'slice' -> test 'zero to zero' -> deep-eq [], slice 0 0 [1 2 3 4 5] test 'empty lsit as input' -> deep-eq [], slice 2 3 [] test 'parts' -> deep-eq [3 4], slice 2 4 [1 2 3 4 5] test 'curried' -> f = slice 2 deep-eq [3 4], f 4 [1 2 3 4 5] g = slice 2 4 deep-eq [3 4], g [1 2 3 4 5] suite 'take' -> test 'empty list as input' -> deep-eq [], take 3 [] test 'zero on list' -> deep-eq [], take 0 [1 2 3 4 5] test 'negative number' -> deep-eq [], take -1 [1 2 3 4 5] test 'too big number' -> deep-eq [1 2 3 4 5], take 9 [1 2 3 4 5] test 'list' -> deep-eq [1 2 3], take 3 [1 2 3 4 5] test 'curried' -> f = take 3 deep-eq [1 2 3], f [1 2 3 4 5] suite 'drop' -> test 'empty list as input' -> deep-eq [], drop 3 [] test 'zero on list' -> deep-eq [1 2 3 4 5], drop 0 [1 2 3 4 5] test 'negative number' -> deep-eq [1 2 3 4 5], drop -1 [1 2 3 4 5] test 'too big number' -> deep-eq [], drop 9 [1 2 3 4 5] test 'list' -> deep-eq [4 5], drop 3 [1 2 3 4 5] test 'curried' -> f = drop 3 deep-eq [4 5], f [1 2 3 4 5] suite 'split-at' -> test 'empty list as input' -> deep-eq [[], []], split-at 3 [] test 'zero on list' -> deep-eq [[], [1 2 3 4 5]], split-at 0 [1 2 3 4 5] test 'negative number' -> deep-eq [[], [1 2 3 4 5]], split-at -1 [1 2 3 4 5] test 'too big number' -> deep-eq [[1 2 3 4 5], []], split-at 9 [1 2 3 4 5] test 'list' -> deep-eq [[1 2 3], [4 5]], split-at 3 [1 2 3 4 5] test 'curried' -> f = split-at 3 deep-eq [[1 2 3], [4 5]], f [1 2 3 4 5] suite 'take-while' -> test 'empty list as input' -> deep-eq [], take-while id, [] test 'list' -> deep-eq [1 3 5], take-while odd, [1 3 5 4 8 7 9] test 'all pass' -> deep-eq [42], take-while (== 42), [42] deep-eq [2 4 8], take-while even, [2 4 8] test 'all fail' -> deep-eq [], take-while (== 7), [42] deep-eq [], take-while odd, [2 4 8] test 'curried' -> f = take-while odd deep-eq [1 3 5], f [1 3 5 4 8 7 9] suite 'drop-while' -> test 'empty list as input' -> deep-eq [], drop-while id, [] test 'list' -> deep-eq [7 9 10], drop-while even, [2 4 6 7 9 10] test 'all pass' -> deep-eq [], drop-while (== 42), [42] deep-eq [], drop-while even, [2 4 8] test 'all-fail' -> deep-eq [42], drop-while (== 7), [42] deep-eq [2 4 8], drop-while odd, [2 4 8] test 'curried' -> f = drop-while even deep-eq [7 9 10], f [2 4 6 7 9 10] suite 'span' -> test 'empty list as input' -> deep-eq [[], []], span id, [] test 'list' -> deep-eq [[2 4 6], [7 9 10]], span even, [2 4 6 7 9 10] test 'curried' -> f = span even deep-eq [[2 4 6], [7 9 10]], f [2 4 6 7 9 10] suite 'break-list' -> test 'empty list as input' -> deep-eq [[], []], break-list id, [] test 'list' -> deep-eq [[1 2], [3 4 5]], break-list (== 3), [1 2 3 4 5] test 'curried' -> f = break-list (== 3) deep-eq [[1 2], [3 4 5]], f [1 2 3 4 5] suite 'zip' -> test 'empty lists as input' -> deep-eq [], zip [] [] test 'equal length lists' -> deep-eq [[1 4], [2 5]], zip [1 2] [4 5] test 'first list shorter' -> deep-eq [[1 4], [2 5]], zip [1 2] [4 5 6] test 'second list shorter' -> deep-eq [[1 4], [2 5]], zip [1 2 3] [4 5] test 'curried' -> f = zip [1 2] deep-eq [[1 4], [2 5]], f [4 5] suite 'zip-with' -> test 'empty lists as input' -> deep-eq [], zip-with id, [], [] test 'equal length lists' -> deep-eq [4 4 4], zip-with (+), [1 2 3], [3 2 1] test 'first list shorter' -> deep-eq [5 7], zip-with (+), [1 2], [4 5 6] test 'second list shorter' -> deep-eq [5 7], zip-with (+), [1 2 3] [4 5] test 'curried' -> f = zip-with (+) deep-eq [4 4 4], f [1 2 3], [3 2 1] g = zip-with (+), [1 2 3] deep-eq [4 4 4], g [3 2 1] suite 'zip-all' -> test 'no lists as input' -> deep-eq [], zip-all! test 'empty lists as input' -> deep-eq [], zip-all [] [] [] test 'equal length lists' -> deep-eq [[1 4 7], [2 5 8], [3 6 9]], zip-all [1 2 3] [4 5 6] [7 8 9] test 'first list shorter' -> deep-eq [[1 4 7], [2 5 8]], zip-all [1 2] [4 5 6] [7 8 9] test 'second list shorter' -> deep-eq [[1 4 7], [2 5 8]], zip-all [1 2 3] [4 5] [7 8 9] test 'third list shorter' -> deep-eq [[1 4 7], [2 5 8]], zip-all [1 2 3] [4 5 6] [7 8] suite 'zip-all-with' -> test 'nothing as input' -> deep-eq [], zip-all-with! test 'no lists as input' -> deep-eq [], zip-all-with id test 'empty lists as input' -> deep-eq [], zip-all-with id, [], [] test 'equal length lists' -> deep-eq [5 5 5], zip-all-with (-> &0 + &1 + &2), [1 2 3], [3 2 1], [1 1 1] test 'first list shorter' -> deep-eq [5 7], zip-all-with (+), [1 2], [4 5 6] test 'second list shorter' -> deep-eq [5 7], zip-all-with (+), [1 2 3] [4 5] suite 'at' -> test 'empty list as input' -> eq void, at 0, [] test 'positive n' -> eq 2, at 1, [1 2 3] test 'negative n' -> eq 3, at -1, [1 2 3] test 'not defined at index' -> eq void, at 10, [1 2 3] test 'curried' -> eq 2, (at 1) [1 2 3] suite 'elem-index' -> test 'empty list as input' -> eq void, elem-index 2, [] test 'basic' -> eq 1, elem-index 2, [1 2 3] test 'multiple' -> eq 1, elem-index 2, [1 2 3 2 1] test 'not there' -> eq void, elem-index 5, [1 2 3] test 'curried' -> eq 1, (elem-index 2) [1 2 3] suite 'elem-indices' -> test 'empty list as input' -> deep-eq [], elem-indices 2, [] test 'single' -> deep-eq [1], elem-indices 2, [1 2 3] test 'multiple' -> deep-eq [1, 3], elem-indices 2, [1 2 3 2 1] test 'not there' -> deep-eq [], elem-indices 5, [1 2 3] test 'curried' -> deep-eq [1], (elem-indices 2) [1 2 3] suite 'find-index' -> test 'empty list as input' -> eq void, find-index id, [] test 'basic' -> eq 1, find-index (== 2), [1 2 3] test 'multiple' -> eq 1, find-index even, [1 2 3 4] test 'not there' -> eq void, find-index odd, [2 4 6] test 'curried' -> eq 1, (find-index (== 2)) [1 2 3] suite 'find-indices' -> test 'empty list as input' -> deep-eq [], find-indices id, [] test 'basic' -> deep-eq [1], find-indices (== 2), [1 2 3] test 'multiple' -> deep-eq [1, 3], find-indices even, [1 2 3 4] test 'not there' -> deep-eq [], find-indices odd, [2 4 6] test 'curried' -> deep-eq [1], (find-indices (== 2)) [1 2 3] ================================================ FILE: test/Num.ls ================================================ { max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, acos, asin, atan, atan2, truncate, round, ceiling, floor, is-it-NaN, even, odd, gcd, lcm, } = require '..' {strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert' suite 'max' -> test 'numbers' -> eq 3, max 3 3 eq 3, max 2 3 eq 3, max 3 2 test 'characters' -> eq \b, max \a \b test 'curried' -> f = max 2 eq 3, f 3 suite 'min' -> test 'numbers' -> eq 0, min 9 0 test 'characters' -> eq \a, min \a \b test 'curried' -> f = min 9 eq 0, f 0 suite 'negate' -> test 'zero' -> eq -0, negate 0 test 'negative number' -> eq -2, negate 2 test 'positive number' -> eq 3, negate -3 suite 'abs' -> test 'zero' -> eq 0, abs 0 test 'negative number' -> eq 4 abs -4 test 'positive number' -> eq 4 abs 4 suite 'signum' -> test 'zero' -> eq 0 signum 0 test 'negative number' -> eq -1 signum -5.3 test 'positive number' -> eq 1 signum 8 suite 'quot' -> test 'simple' -> eq -6, quot -20 3 test 'curried' -> f = quot -20 eq -6, f 3 suite 'rem' -> test 'simple' -> eq -2, rem -20 3 test 'curried' -> f = rem -20 eq -2, f 3 suite 'div' -> test 'simple' -> eq -7, div -20 3 test 'curried' -> f = div -20 eq -7, f 3 suite 'mod' -> test 'simple' -> eq 1, mod -20 3 test 'curried' -> f = mod -20 eq 1, f 3 suite 'recip' -> test 'zero' -> eq Infinity, recip 0 test 'larger than 1' -> eq 0.5, recip 2 test 'between 0 and 1' -> eq 2, recip 0.5 suite 'pi' -> test 'constant' -> eq 3.141592653589793, pi suite 'tau' -> test 'constant' -> eq 6.283185307179586, tau suite 'exp' -> test 'simple' -> eq 2.718281828459045, exp 1 suite 'sqrt' -> test 'negative numbers' -> ok is-it-NaN sqrt -1 test 'simple' -> eq 2 sqrt 4 suite 'ln' -> test 'simple' -> eq 0.6931471805599453, ln 2 suite 'pow' -> test 'simple' -> eq 4, pow 2 2 eq 4, pow -2 2 test 'with negative numbers' -> eq 0.25, pow 2 -2 test 'between one and zero' -> eq 4, pow 16 0.5 test 'curried' -> f = pow 2 eq 4, f 2 suite 'sin' -> test 'zero' -> eq 0, sin 0 test 'pi/2' -> eq 1, sin pi/2 suite 'tan' -> test 'zero' -> eq 0, tan 0 suite 'cos' -> test 'zero' -> eq 1, cos 0 test 'pi' -> eq -1, cos pi suite 'acos' -> test 'number' -> eq 1.4706289056333368, acos 0.1 suite 'asin' -> test 'number' -> eq 1.5707963267948966, asin 1 suite 'atan' -> test 'number' -> eq 0.7853981633974483, atan 1 suite 'atan2' -> test 'number' -> eq 0.4636476090008061, atan2 1 2 test 'curried' -> f = atan2 1 eq 0.4636476090008061, f 2 suite 'truncate' -> test 'zero' -> eq 0, truncate 0 test 'positive number' -> eq 1 truncate 1.5 test 'negative number' -> eq -1 truncate -1.5 suite 'round' -> test 'up' -> eq 1 round 0.6 eq 1 round 0.5 test 'down' -> eq 0 round 0.4 suite 'ceiling' -> test 'zero' -> eq 0, ceiling 0 test 'positive number' -> eq 1, ceiling 0.1 test 'negative number' -> eq -0, ceiling -0.9 suite 'floor' -> test 'zero' -> eq 0, floor 0 test 'positive number' -> eq 0, floor 0.9 test 'negative number' -> eq -1, floor -0.1 suite 'is-it-NaN' -> test 'true' -> ok is-it-NaN Math.sqrt -1 test 'false' -> ok not is-it-NaN '0' suite 'even' -> test 'true' -> ok even 0 ok even -2 test 'false' -> ok not even 7 suite 'odd' -> test 'true' -> ok odd 3 test 'false' -> ok not odd -4 ok not odd 0 suite 'gcd' -> test 'some numbers' -> eq 6, gcd 12 18 test 'curried' -> f = gcd 12 eq 6, f 18 suite 'lcm' -> test 'some numbers' -> eq 36, lcm 12 18 test 'curried' -> f = lcm 12 eq 36, f 18 ================================================ FILE: test/Obj.ls ================================================ { id Obj: { values, keys, pairs-to-obj, obj-to-pairs, lists-to-obj, obj-to-lists, empty, each, map, filter, compact, reject, partition, find, } } = require '..' {strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert' suite 'values' -> test 'empty object as input' -> deep-eq [], values {} test 'object as input' -> deep-eq [1 2 3], values sadf: 1, asdf: 2, fdas: 3 suite 'keys' -> test 'empty object as input' -> deep-eq [], keys {} test 'object as input' -> deep-eq <[ sadf asdf fdas ]>, keys sadf: 1, asdf: 2, fdas: 3 suite 'pairs-to-obj' -> test 'empty list as input' -> deep-eq {}, pairs-to-obj [] test 'pairs as input' -> deep-eq {a: 'b', c: 'd', e: 1}, pairs-to-obj [['a' 'b'] ['c' 'd'] ['e' 1]] suite 'obj-to-pairs' -> test 'empty object as input' -> deep-eq [], obj-to-pairs {} test 'object as input' -> deep-eq [['a' 'b'] ['c' 'd'] ['e' 1]], obj-to-pairs {a: 'b', c: 'd', e: 1} suite 'lists-to-obj' -> test 'empty lists as input' -> deep-eq {}, lists-to-obj [] [] test 'two lists of the same length' -> deep-eq {a: 1, b: 2, c: 3}, lists-to-obj <[ a b c ]> [1 2 3] test 'first list is shorter' -> deep-eq {a: 1, b: 2}, lists-to-obj <[ a b ]> [1 2 3] test 'first list is longer' -> deep-eq {a: 1, b: 2, c: void}, lists-to-obj <[ a b c ]> [1 2] test 'curried' -> f = lists-to-obj <[ a b c ]> deep-eq {a: 1, b: 2, c: 3}, f [1 2 3] suite 'obj-to-lists' -> test 'empty object as input' -> deep-eq [[], []], obj-to-lists {} test 'two lists of the same length' -> deep-eq [<[ a b c ]>, [1 2 3]], obj-to-lists {a: 1, b: 2, c: 3} suite 'empty' -> test 'empty object as input' -> ok empty {} test 'non-empty object as input' -> ok not empty {x: 1} suite 'each' -> test 'empty object as input' -> deep-eq {}, each id, {} test 'iterate over object values' -> count = 4 each (-> count += it), {a: 1, b: 2, c: 3} eq 10 count test 'curried' -> count = 4 f = each (-> count += it) f {a: 1, b: 2, c: 3} eq 10 count suite 'map' -> test 'empty object as input' -> deep-eq {}, map id, {} test 'mapping over object' -> deep-eq {a:2, b:4}, map (* 2), {a:1, b:2} test 'curried' -> f = map (* 2) deep-eq {a:2, b:4}, f {a:1, b:2} suite 'compact' -> test 'empty object as input' -> deep-eq {}, compact {} test 'compacting object' -> deep-eq {b: 1, e: 'ha'}, compact {a: 0, b: 1, c: false, d: '', e: 'ha'} suite 'filter' -> test 'empty object as input' -> deep-eq {}, filter id, {} test 'filtering object' -> deep-eq {b: 2}, filter (== 2), {a:1, b:2} test 'curried' -> f = filter (== 2) deep-eq {b: 2}, f {a:1, b:2} suite 'reject' -> test 'empty object as input' -> deep-eq {}, reject id, {} test 'reject object' -> deep-eq {a: 1}, reject (==2), {a:1, b:2} test 'curried' -> f = reject (== 2) deep-eq {a: 1}, f {a:1, b:2} suite 'partition' -> test 'empty object as input' -> deep-eq [{}, {}], partition id, {} test 'partition object' -> deep-eq [{b: 2}, {a: 1, c: 3}], partition (==2), {a:1, b:2, c:3} test 'curried' -> f = partition (== 2) deep-eq [{b: 2}, {a: 1, c: 3}], f {a:1, b:2, c:3} suite 'find' -> test 'empty object as input' -> eq void, find id, {} test 'find from object' -> eq 2, find (==2), {a:1, b:2} test 'curried' -> f = find (== 2) eq 2, f {a:1, b:2} ================================================ FILE: test/Str.ls ================================================ { id Str: { split, join, lines, unlines, words, unwords, chars, unchars, empty, reverse repeat, capitalize, camelize, dasherize slice, take, drop, split-at, take-while, drop-while, span, break-str } } = require '..' {strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert' suite 'split' -> test 'empty string as input' -> deep-eq [], split '' '' test 'string of some length' -> deep-eq <[ 1 2 3 ]>, split '|' '1|2|3' test 'curried' -> f = split '|' deep-eq <[ 1 2 3 ]>, f '1|2|3' suite 'join' -> test 'empty list as input' -> eq '' join '', [] test 'list as input' -> eq '1,2,3', join ',' [1 2 3] test 'empty string as seperator' -> eq '123', join '' [1 2 3] test 'curried' -> f = join ',' eq '1,2,3', f [1 2 3] suite 'lines' -> test 'empty string as input' -> deep-eq [], lines '' test 'string as input' -> deep-eq <[ one two three ]>, lines 'one\ntwo\nthree' suite 'unlines' -> test 'empty array as input' -> eq '', unlines [] test 'array as input' -> eq 'one\ntwo\nthree', unlines [\one \two \three] suite 'words' -> test 'empty string as input' -> deep-eq [], words '' test 'string as input' -> deep-eq <[ what is this ]>, words 'what is this' suite 'unwords' -> test 'empty array as input' -> eq '', unwords [] test 'array as input' -> eq 'what is this', unwords [\what \is \this] suite 'chars' -> test 'empty string as input' -> deep-eq [], chars '' test 'string as input' -> deep-eq <[ h e l l o ]>, chars 'hello' suite 'unchars' -> test 'empty array as input' -> eq '', unchars [] test 'array as input' -> eq 'there', unchars ['t', 'h', 'e', 'r', 'e'] suite 'empty' -> test 'empty string as input' -> ok empty '' test 'string as input' -> ok not empty 'a' suite 'reverse' -> test 'empty string as input' -> eq '', reverse '' test 'a string' -> eq 'cba', reverse 'abc' eq 'olleh', reverse 'hello' suite 'repeat' -> test 'zero times' -> eq '' repeat 0 'hi' test 'empty string as input' -> eq '', repeat 2 '' test 'a string several times' -> eq 'aa', repeat 2 'a' eq 'hihihi', repeat 3 'hi' eq 'hihihihihihihihihihi', repeat 10 'hi' test 'curried' -> f = repeat 2 eq 'aa', f 'a' suite 'capitalize' -> test 'empty string as input' -> eq '', capitalize '' test 'basic' -> eq 'Foo', capitalize 'foo' suite 'camelize' -> test 'empty string as input' -> eq '', camelize '' test 'no change' -> eq 'fooBar', camelize 'fooBar' test 'dashes' -> eq 'fooBar', camelize 'foo-bar' test 'underscore' -> eq 'fooBar', camelize 'foo_bar' test 'ending dash' -> eq 'fooBar', camelize 'foo-bar-' test 'more than one' -> eq 'fooBar', camelize 'foo--bar' suite 'dasherize' -> test 'empty string as input' -> eq '', dasherize '' test 'no change' -> eq 'foo-bar', dasherize 'foo-bar' test 'basic' -> eq 'foo-bar', dasherize 'fooBar' test 'with numbers' -> eq 'f1-bar', dasherize 'f1Bar' test 'repeated capitals' -> eq 'set-JSON', dasherize 'setJSON' test 'starting with capital' -> eq 'foo-bar', dasherize 'FooBar' test 'starting with repeated capitals' -> eq 'JSON-get', dasherize 'JSONget' suite 'slice' -> test 'zero to zero' -> eq '', slice 0 0 'hello' test 'empty string as input' -> eq '', slice 2 3 '' test 'parts' -> eq 'll', slice 2 4 'hello' test 'curried' -> f = slice 2 eq 'll', f 4 'hello' g = slice 2 4 eq 'll', g 'hello' suite 'take' -> test 'empty string as input' -> eq '', take 3 '' test 'zero on string' -> eq '', take 0 'abcde' test 'string' -> eq 'ab', take 2 'abcde' test 'curried' -> f = take 2 eq 'ab', f 'abcde' suite 'drop' -> test 'empty string as input' -> eq '', drop 3 '' test 'zero on string' -> eq 'abcde', drop 0 'abcde' test 'string' -> eq 'cde', drop 2 'abcde' test 'curried' -> f = drop 2 eq 'cde', f 'abcde' suite 'split-at' -> test 'empty string as input' -> deep-eq ['', ''], split-at 3 '' test 'zero on string' -> deep-eq ['', 'abcde'], split-at 0 'abcde' test 'string' -> deep-eq ['ab', 'cde'], split-at 2 'abcde' test 'curried' -> f = split-at 2 deep-eq ['ab', 'cde'], f 'abcde' suite 'take-while' -> test 'empty string as input' -> eq '', take-while id, '' test 'string' -> eq 'mmmmm', take-while (is 'm'), 'mmmmmhmm' test 'curried' -> f = take-while (is 'm') eq 'mmmmm', f 'mmmmmhmm' suite 'drop-while' -> test 'empty string as input' -> eq '', drop-while id, '' test 'string' -> eq 'hmm', drop-while (is \m), 'mmmmmhmm' test 'curried' -> f = drop-while (is \m) eq 'hmm', f 'mmmmmhmm' suite 'span' -> test 'empty string as input' -> deep-eq ['', ''], span id, '' test 'string' -> deep-eq ['mmmmm', 'hmm'], span (is \m), 'mmmmmhmm' test 'curried' -> f = span (is \m) deep-eq ['mmmmm', 'hmm'], f 'mmmmmhmm' suite 'break-str' -> test 'empty string as input' -> deep-eq ['', ''], break-str id, '' test 'string' -> deep-eq ['mmmmm', 'hmm'], break-str (is \h), 'mmmmmhmm' test 'curried' -> f = break-str (is \h) deep-eq ['mmmmm', 'hmm'], f 'mmmmmhmm' ================================================ FILE: test/browser.html ================================================ ================================================ FILE: test/index.ls ================================================ {id, is-type, replicate, VERSION} = require '..' {strict-equal: eq, deep-equal: deep-eq, ok} = require 'assert' suite 'library' -> test 'version' -> eq VERSION, (require '../package.json').version suite 'id' -> test 'number' -> eq 5, id 5 test 'object is the same' -> obj = {} eq obj, id obj suite 'is-type' -> test 'literals' -> ok is-type 'Undefined' void ok is-type 'Boolean' true ok is-type 'Number' 1 ok is-type 'Number' 1.2 ok is-type 'String' 'asdfa' ok is-type 'Object' {} ok is-type 'Array' [] ok not is-type 'Boolean' 1 test 'constructors' -> ok is-type 'Date' new Date test 'classes' -> class A ok is-type 'Object' new A test 'curried' -> f = is-type 'Boolean' ok f true suite 'replicate' -> test 'zero as input' -> deep-eq [], replicate 0 0 deep-eq [], replicate 0 'a' test 'number as input' -> deep-eq [3,3,3,3], replicate 4 3 test 'string as input' -> deep-eq <[ a a a a ]>, replicate 4 'a' test 'curried' -> f = replicate 4 deep-eq [3,3,3,3], f 3