Comparing version 0.6.0 to 0.7.0
@@ -43,2 +43,26 @@ (function (global, factory) { | ||
var all = _curry2(function all (fn, xs) { | ||
var i = 0 | ||
, len = xs.length | ||
for (; i < len; i++) { | ||
if (!fn(xs[i])) { | ||
return false | ||
} | ||
} | ||
return true | ||
}) | ||
var any = _curry2(function any (fn, xs) { | ||
var i = 0 | ||
, len = xs.length | ||
for (; i < len; i++) { | ||
if (fn(xs[i])) { | ||
return true | ||
} | ||
} | ||
return false | ||
}) | ||
var _curry3 = function _curry3 (fn) { | ||
@@ -66,2 +90,8 @@ return function __arity_3__ (a0, a1, a2) { | ||
var _concat = [].concat | ||
var concat = _curry2(function concat (as, bs) { | ||
return _concat.call(as, bs) | ||
}) | ||
var _slice = [].slice | ||
@@ -90,3 +120,11 @@ | ||
/** | ||
* @description something | ||
* @description | ||
* Curries a function to the specified arity. Receives an array of arguments | ||
* to treat as as already-supplied (meaning they count toward fulfilling | ||
* the target arity). The resulting function will combine the existing | ||
* arguments with those from the latest call, and if the resulting length | ||
* is greater than or equal to the target arity, the original function will | ||
* be called with those arguments. If the number of arguments is still | ||
* smaller than the required amount, the function will be curried again. | ||
* | ||
* @param {Number} arity - the target arity | ||
@@ -97,6 +135,14 @@ * @param {Number} applied - the array of already-applied arguments | ||
*/ | ||
function _curryN (arity, applied, fn) { | ||
var _curryN = function _curryN (arity, applied, fn) { | ||
return _arity(arity, function () { | ||
var newApplied = applied.concat(_slice.call(arguments)) | ||
var newApplied = applied | ||
, i | ||
if (arguments.length) { | ||
newApplied = _slice.call(applied) | ||
for (i = 0; i < arguments.length; i++) { | ||
newApplied.push(arguments[i]) | ||
} | ||
} | ||
return newApplied.length >= arity | ||
@@ -108,10 +154,19 @@ ? fn.apply(null, newApplied) | ||
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(fn.length, [], fn) | ||
} | ||
}) | ||
var compose = function compose () { | ||
var fns = arguments | ||
, _i = fns.length - 1 | ||
, fn = fns[_i--] | ||
, i = fns.length - 1 | ||
, fn = fns[i--] | ||
return _curryN(fn.length, [], function __composition__ () { | ||
var i = _i | ||
, y = fn.apply(null, arguments) | ||
return curryN(fn.length, function __composition__ () { | ||
var y = fn.apply(null, arguments) | ||
@@ -135,12 +190,2 @@ for (; i >= 0; i--) { | ||
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(fn.length, [], fn) | ||
} | ||
}) | ||
var dec = function dec (a) { | ||
@@ -150,2 +195,10 @@ return a - 1 | ||
var _equals = function _equals (a, b) { | ||
return a === b | ||
} | ||
var equals = _curry2(function equals (a, b) { | ||
return _equals(a, b) | ||
}) | ||
var filter = _curry2(function filter (fn, xs) { | ||
@@ -256,2 +309,16 @@ var i = 0 | ||
var fromPairs = function fromPairs (xs) { | ||
var y = {} | ||
, i = 0 | ||
, len = xs.length | ||
, x | ||
for (; i < len; i++) { | ||
x = xs[i] | ||
y[x[0]] = x[1] | ||
} | ||
return y | ||
} | ||
var head = function head (xs) { | ||
@@ -342,2 +409,6 @@ return xs[0] | ||
var of = function of (x) { | ||
return [x] | ||
} | ||
var pipe = function pipe () { | ||
@@ -366,2 +437,13 @@ var fns = arguments | ||
var rangeBy = _curry3(function rangeBy (inc, i, end) { | ||
var ys = [] | ||
for (; i < end; i += inc) { | ||
ys.push(i) | ||
} | ||
return ys | ||
}) | ||
var range = rangeBy(1) | ||
var reduce = _curry3(function reduce (fn, y, xs) { | ||
@@ -445,21 +527,46 @@ var i = 0 | ||
var trace = function trace (m) { | ||
return function __trace__ (x) { | ||
console.log(m, x) | ||
return x | ||
var tap = function (fn) { | ||
return function tapped (a) { | ||
fn(a) | ||
return a | ||
} | ||
} | ||
var unzipObj = function unzipObj (a) { | ||
var res = [] | ||
, prop | ||
var toPairs = function toPairs (a) { | ||
var ys = [] | ||
, p | ||
for (prop in a) { | ||
if (a.hasOwnProperty(prop)) { | ||
res.push([prop, a[prop]]) | ||
for (p in a) { | ||
if (a.hasOwnProperty(p)) { | ||
ys.push([p, a[p]]) | ||
} | ||
} | ||
return res | ||
return ys | ||
} | ||
var without = _curry2(function without (as, bs) { | ||
var ys = [] | ||
, bi = 0 | ||
, aslen = as.length | ||
, bslen = bs.length | ||
, ai | ||
, b | ||
, discard | ||
for (; bi < bslen; bi++) { | ||
b = bs[bi] | ||
discard = false | ||
for (ai = 0; ai < aslen; ai++) { | ||
if (b == as[ai]) { | ||
discard = true | ||
break | ||
} | ||
} | ||
if (!discard) { | ||
ys.push(b) | ||
} | ||
} | ||
return ys | ||
}) | ||
var zip = _curry2(function zip (as, bs) { | ||
@@ -488,3 +595,6 @@ var i = 0 | ||
exports.add = add; | ||
exports.all = all; | ||
exports.any = any; | ||
exports.assoc = assoc; | ||
exports.concat = concat; | ||
exports.compose = compose; | ||
@@ -494,2 +604,3 @@ exports.curry = curry; | ||
exports.dec = dec; | ||
exports.equals = equals; | ||
exports.filter = filter; | ||
@@ -502,2 +613,3 @@ exports.find = find; | ||
exports.forEach = forEach; | ||
exports.fromPairs = fromPairs; | ||
exports.head = head; | ||
@@ -512,5 +624,8 @@ exports.identity = identity; | ||
exports.not = not; | ||
exports.of = of; | ||
exports.pipe = pipe; | ||
exports.prop = prop; | ||
exports.propEq = propEq; | ||
exports.range = range; | ||
exports.rangeBy = rangeBy; | ||
exports.reduce = reduce; | ||
@@ -528,4 +643,5 @@ exports.foldl = reduce; | ||
exports.toUpper = toUpper; | ||
exports.trace = trace; | ||
exports.unzipObj = unzipObj; | ||
exports.tap = tap; | ||
exports.toPairs = toPairs; | ||
exports.without = without; | ||
exports.zip = zip; | ||
@@ -532,0 +648,0 @@ exports.zipObj = zipObj; |
{ | ||
"name": "redash", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/redash.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15117
540
0
28