Comparing version 0.11.1 to 0.11.2
@@ -8,4 +8,4 @@ (function (global, factory) { | ||
function _curry1 (fn) { | ||
return function __curried_unary__ (a0) { | ||
return arguments.length ? fn(a0) : __curried_unary__ | ||
return function curriedUnaryFunction (a0) { | ||
return arguments.length ? fn(a0) : curriedUnaryFunction | ||
} | ||
@@ -15,6 +15,6 @@ } | ||
function _curry2 (fn) { | ||
return function __curried_binary__ (a0, a1) { | ||
return function curriedBinaryFunction (a0, a1) { | ||
switch (arguments.length) { | ||
case 0: return __curried_binary__ | ||
case 1: return _curry1(function __curried_unary__ (b0) { | ||
case 0: return curriedBinaryFunction | ||
case 1: return _curry1(function curriedUnaryFunction (b0) { | ||
return fn(a0, b0) | ||
@@ -91,10 +91,10 @@ }) | ||
var any = _curry2(function any (fn, xs) { | ||
var found = false | ||
var res = false | ||
_arrayEach(function (x) { | ||
if (fn(x)) { | ||
return found = true | ||
return (res = true) | ||
} | ||
}, xs) | ||
return found | ||
return res | ||
}) | ||
@@ -114,9 +114,9 @@ | ||
function _curry3 (fn) { | ||
return function _curried_ternary__ (a0, a1, a2) { | ||
return function curriedTernaryFunction (a0, a1, a2) { | ||
switch (arguments.length) { | ||
case 0: return _curried_ternary__ | ||
case 1: return _curry2(function __curried_binary__ (_a1, _a2) { | ||
case 0: return curriedTernaryFunction | ||
case 1: return _curry2(function curriedBinaryFunction (_a1, _a2) { | ||
return fn(a0, _a1, _a2) | ||
}) | ||
case 2: return _curry1(function __curried_unary__ (_a2) { | ||
case 2: return _curry1(function curriedUnaryFunction (_a2) { | ||
return fn(a0, a1, _a2) | ||
@@ -154,2 +154,23 @@ }) | ||
/** | ||
* cond : [[(a -> Boolean), (a -> *)]] -> a -> (a -> *) | ||
*/ | ||
var cond = _curry2(function cond (conditions, x) { | ||
var _this = this | ||
, _res | ||
_arrayEach(function (condition) { | ||
var pred = condition[0] | ||
, fn = condition[1] | ||
if (pred.apply(_this, [x])) { | ||
_res = fn.apply(_this, [x]) | ||
return true | ||
} | ||
}, conditions) | ||
return _res | ||
}) | ||
var _reverse = [].reverse | ||
var _arraySlice = [].slice | ||
@@ -207,30 +228,2 @@ | ||
/** | ||
* curryN : Number n -> (a, b, ..., n -> v) -> a -> b -> ... -> n -> v | ||
* | ||
* @since v0.1.0 | ||
*/ | ||
var curryN = _curry2(function curryN (arity, fn) { | ||
switch (arity) { | ||
case 0: return fn | ||
case 1: return _curry1(fn) | ||
case 2: return _curry2(fn) | ||
case 3: return _curry3(fn) | ||
default: return _curryN(arity, [], fn) | ||
} | ||
}) | ||
/** | ||
* complement : (*... -> Boolean) -> (*... -> Boolean) | ||
* | ||
* @since v0.9.0 | ||
*/ | ||
function complement (fn) { | ||
return curryN(fn.length, function () { | ||
return !fn.apply(this, arguments) | ||
}) | ||
} | ||
var _reverse = [].reverse | ||
/** | ||
* pipe : ((a, b, ..., f -> g), (g -> h), ..., (y -> z)) -> ((a, b, ..., f) -> z | ||
@@ -265,2 +258,17 @@ * | ||
/** | ||
* curryN : Number n -> (a, b, ..., n -> v) -> a -> b -> ... -> n -> v | ||
* | ||
* @since v0.1.0 | ||
*/ | ||
var curryN = _curry2(function curryN (arity, fn) { | ||
switch (arity) { | ||
case 0: return fn | ||
case 1: return _curry1(fn) | ||
case 2: return _curry2(fn) | ||
case 3: return _curry3(fn) | ||
default: return _curryN(arity, [], fn) | ||
} | ||
}) | ||
/** | ||
* curry : (a, b, ..., j -> v) -> a -> b -> ... -> j -> v | ||
@@ -499,2 +507,17 @@ * | ||
/** | ||
* ifElse : (a -> Boolean) -> (a -> *) -> (a -> *) -> (a -> *) | ||
* | ||
* TODO: Should this curry the returned function to `cond` arity? | ||
* | ||
* @param {Function} cond | ||
* @param {Function} ifTrue | ||
* @param {Function} ifElse | ||
*/ | ||
var ifElse = _curry3(function ifElse (cond, whenTrue, whenElse) { | ||
return function (x) { | ||
return cond(x) ? whenTrue(x) : whenElse(x) | ||
} | ||
}) | ||
/** | ||
* inc : Number -> Number | ||
@@ -538,2 +561,12 @@ * | ||
/** | ||
* isNil : * -> Boolean | ||
* | ||
* @param {*} x | ||
* @returns Boolean | ||
*/ | ||
function isNil (x) { | ||
return x == null | ||
} | ||
/** | ||
* keys : {k:v} -> [k] | ||
@@ -564,4 +597,4 @@ * | ||
return { | ||
get: getter, | ||
set: setter, | ||
get: getter | ||
, set: setter | ||
} | ||
@@ -631,7 +664,14 @@ }) | ||
* not : Boolean -> Boolean | ||
* not : (*... -> Boolean) -> (*... -> Boolean) | ||
* | ||
* @since v0.6.0 | ||
*/ | ||
function not (a) { | ||
return !a | ||
function not (x) { | ||
if (typeof x !== 'function') { | ||
return !x | ||
} | ||
return curryN(x.length, function () { | ||
return !x.apply(this, arguments) | ||
}) | ||
} | ||
@@ -650,2 +690,12 @@ | ||
* @param {Lens} lens | ||
* @param {*} value | ||
* @param {Object|*} target | ||
* @returns {*} | ||
*/ | ||
var set = _curry3(function set (lens, value, target) { | ||
return lens.set(value, target) | ||
}) | ||
/** | ||
* @param {Lens} lens | ||
* @param {Function} fn | ||
@@ -685,6 +735,7 @@ * @param {Object|*} target | ||
, times | ||
, i | ||
// TODO: should (some of) these throw? | ||
// TODO: should (some of) these throw? | ||
if ( | ||
inc === 0 || | ||
inc === 0 || | ||
inc > 0 && start > end || | ||
@@ -697,3 +748,3 @@ inc < 0 && start < end | ||
times = Math.abs(Math.ceil((end - start) / inc)) | ||
for (var i = 0; i < times; i++) { | ||
for (i = 0; i < times; i++) { | ||
ys.push(start + (inc * i)) | ||
@@ -726,3 +777,3 @@ } | ||
var reject = _curry2(function reject (fn, xs) { | ||
return filter(complement(fn), xs) | ||
return filter(not(fn), xs) | ||
}) | ||
@@ -740,12 +791,2 @@ | ||
/** | ||
* @param {Lens} lens | ||
* @param {*} value | ||
* @param {Object|*} target | ||
* @returns {*} | ||
*/ | ||
var set$1 = _curry3(function set (lens, value, target) { | ||
return lens.set(value, target) | ||
}) | ||
/** | ||
* sum : [Number] -> Number | ||
@@ -848,3 +889,3 @@ * | ||
}, o) | ||
return ys | ||
return kvs | ||
} | ||
@@ -871,5 +912,6 @@ | ||
var discard = false | ||
_arrayEach(function (a) { | ||
if (b === a) { | ||
return discard = true | ||
return (discard = true) | ||
} | ||
@@ -924,3 +966,3 @@ }, as) | ||
exports.concat = concat; | ||
exports.complement = complement; | ||
exports.cond = cond; | ||
exports.compose = compose; | ||
@@ -945,5 +987,7 @@ exports.curry = curry; | ||
exports.identity = identity; | ||
exports.ifElse = ifElse; | ||
exports.inc = inc; | ||
exports.indexOf = indexOf; | ||
exports.insert = insert; | ||
exports.isNil = isNil; | ||
exports.keys = keys; | ||
@@ -968,3 +1012,3 @@ exports.last = last; | ||
exports.reverse = reverse; | ||
exports.set = set$1; | ||
exports.set = set; | ||
exports.sum = sum; | ||
@@ -971,0 +1015,0 @@ exports.tail = tail; |
{ | ||
"name": "redash", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "Compact library for writing performant functional JavaScript", | ||
@@ -13,3 +13,3 @@ "main": "dist/redash.js", | ||
"scripts": { | ||
"lint": "eslint src/**/*.js", | ||
"lint": "eslint src", | ||
"bundle": "rollup --format umd --name Redash -i src/redash.js -o dist/redash.js", | ||
@@ -24,5 +24,3 @@ "minify": "uglifyjs dist/redash.js --compress --mangle -o dist/redash.min.js", | ||
"devDependencies": { | ||
"eslint": "^1.9.0", | ||
"eslint-config-standard": "^4.4.0", | ||
"eslint-plugin-standard": "^1.3.1", | ||
"eslint": "^2.13.1", | ||
"karma": "^0.13.15", | ||
@@ -29,0 +27,0 @@ "karma-chai": "^0.1.0", |
20758
13
896