mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Rename _.conj, _.disj, and _.juxt to _.overEvery, _.overSome, and _.over.
This commit is contained in:
208
lodash.js
208
lodash.js
@@ -1489,26 +1489,26 @@
|
||||
* The chainable wrapper methods are:
|
||||
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`,
|
||||
* `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`,
|
||||
* `compact`, `concat`, `conforms`, `overEvery`, `constant`, `countBy`, `create`,
|
||||
* `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
|
||||
* `difference`, `differenceBy`, `differenceWith`, `overSome`, `drop`, `dropRight`,
|
||||
* `dropRightWhile`, `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`,
|
||||
* `flip`, `flow`, `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`,
|
||||
* `forOwn`, `forOwnRight`, `functions`, `functionsIn`, `groupBy`, `initial`,
|
||||
* `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
|
||||
* `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
|
||||
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
|
||||
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`,
|
||||
* `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`,
|
||||
* `forOwnRight`, `functions`, `functionsIn`, `groupBy`, `initial`,
|
||||
* `intersection`, `intersectionBy`, `intersectionWith`, invert`, `invoke`,
|
||||
* `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`,
|
||||
* `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`,
|
||||
* `methodOf`, `mixin`, `modArgs`, `modArgsSet', `negate`, `nthArg`, `omit`,
|
||||
* `omitBy`, `once`, `pairs`, `pairsIn`, `partial`, `partialRight`, `partition`,
|
||||
* `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`,
|
||||
* `pullAllBy`, `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`,
|
||||
* `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`,
|
||||
* `sortBy`, `sortByOrder`, `splice`, `spread`, `tail`, `take`, `takeRight`,
|
||||
* `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
|
||||
* `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`,
|
||||
* `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`,
|
||||
* `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`,
|
||||
* `xorWith`, `zip`, `zipObject`, and `zipWith`
|
||||
* `omitBy`, `once`, `over`, `overEvery`, `overSome`, `pairs`, `pairsIn`,
|
||||
* `partial`, `partialRight`, `partition`, `pick`, `pickBy`, `plant`, `property`,
|
||||
* `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`,
|
||||
* `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`, `set`,
|
||||
* `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByOrder`, `splice`,
|
||||
* `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`,
|
||||
* `tap`, `throttle`, `thru`, `toArray`, `toPath`, `toPlainObject`, `transform`,
|
||||
* `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`,
|
||||
* `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, `without`,
|
||||
* `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, and `zipWith`
|
||||
*
|
||||
* The wrapper methods that are **not** chainable by default are:
|
||||
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
|
||||
@@ -4091,25 +4091,6 @@
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function like `_.overEvery`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} arrayFunc The function to iterate over iteratees.
|
||||
* @returns {Function} Returns the new invoker function.
|
||||
*/
|
||||
function createInvoker(arrayFunc) {
|
||||
return rest(function(iteratees) {
|
||||
iteratees = arrayMap(baseFlatten(iteratees), getIteratee());
|
||||
return rest(function(args) {
|
||||
var thisArg = this;
|
||||
return arrayFunc(iteratees, function(iteratee) {
|
||||
return iteratee.apply(thisArg, args);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function like `_.modArgs`.
|
||||
*
|
||||
@@ -4136,6 +4117,25 @@
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function like `_.over`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} arrayFunc The function to iterate over iteratees.
|
||||
* @returns {Function} Returns the new invoker function.
|
||||
*/
|
||||
function createOver(arrayFunc) {
|
||||
return rest(function(iteratees) {
|
||||
iteratees = arrayMap(baseFlatten(iteratees), getIteratee());
|
||||
return rest(function(args) {
|
||||
var thisArg = this;
|
||||
return arrayFunc(iteratees, function(iteratee) {
|
||||
return iteratee.apply(thisArg, args);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the padding for `string` based on `length`. The `chars` string
|
||||
* is truncated if the number of characters exceeds `length`.
|
||||
@@ -12643,30 +12643,6 @@
|
||||
return baseConforms(baseClone(source, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that checks if **all** of the `predicates` return
|
||||
* truthy when invoked with the arguments provided to the created function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {...(Function|Function[])} predicates The predicates to check.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var conjed = _.conj(Boolean, isFinite);
|
||||
*
|
||||
* conjed('1');
|
||||
* // => true
|
||||
*
|
||||
* conjed(null);
|
||||
* // => false
|
||||
*
|
||||
* conjed(NaN);
|
||||
* // => false
|
||||
*/
|
||||
var conj = createInvoker(arrayEvery);
|
||||
|
||||
/**
|
||||
* Creates a function that returns `value`.
|
||||
*
|
||||
@@ -12689,30 +12665,6 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that checks if **any** of the `predicates` return
|
||||
* truthy when invoked with the arguments provided to the created function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {...(Function|Function[])} predicates The predicates to check.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var disjed = _.disj(Boolean, isFinite);
|
||||
*
|
||||
* disjed('1');
|
||||
* // => true
|
||||
*
|
||||
* disjed(null);
|
||||
* // => true
|
||||
*
|
||||
* disjed(NaN);
|
||||
* // => false
|
||||
*/
|
||||
var disj = createInvoker(arraySome);
|
||||
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the provided
|
||||
* functions with the `this` binding of the created function, where each
|
||||
@@ -12815,24 +12767,6 @@
|
||||
: baseIteratee(func);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that invokes `iteratees` with the arguments provided
|
||||
* to the created function and returns their results.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {...(Function|Function[])} iteratees The iteratees to invoke.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var juxted = _.juxt(Math.max, Math.min);
|
||||
*
|
||||
* juxted(1, 2, 3, 4);
|
||||
* // => [4, 1]
|
||||
*/
|
||||
var juxt = createInvoker(arrayMap);
|
||||
|
||||
/**
|
||||
* Creates a function that performs a deep partial comparison between a given
|
||||
* object and `source`, returning `true` if the given object has equivalent
|
||||
@@ -13076,6 +13010,72 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that invokes `iteratees` with the arguments provided
|
||||
* to the created function and returns their results.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {...(Function|Function[])} iteratees The iteratees to invoke.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var func = _.over(Math.max, Math.min);
|
||||
*
|
||||
* func(1, 2, 3, 4);
|
||||
* // => [4, 1]
|
||||
*/
|
||||
var over = createOver(arrayMap);
|
||||
|
||||
/**
|
||||
* Creates a function that checks if **all** of the `predicates` return
|
||||
* truthy when invoked with the arguments provided to the created function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {...(Function|Function[])} predicates The predicates to check.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var func = _.overEvery(Boolean, isFinite);
|
||||
*
|
||||
* func('1');
|
||||
* // => true
|
||||
*
|
||||
* func(null);
|
||||
* // => false
|
||||
*
|
||||
* func(NaN);
|
||||
* // => false
|
||||
*/
|
||||
var overEvery = createOver(arrayEvery);
|
||||
|
||||
/**
|
||||
* Creates a function that checks if **any** of the `predicates` return
|
||||
* truthy when invoked with the arguments provided to the created function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {...(Function|Function[])} predicates The predicates to check.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var func = _.overSome(Boolean, isFinite);
|
||||
*
|
||||
* func('1');
|
||||
* // => true
|
||||
*
|
||||
* func(null);
|
||||
* // => true
|
||||
*
|
||||
* func(NaN);
|
||||
* // => false
|
||||
*/
|
||||
var overSome = createOver(arraySome);
|
||||
|
||||
/**
|
||||
* Creates a function that returns the value at `path` of a given object.
|
||||
*
|
||||
@@ -13610,7 +13610,6 @@
|
||||
lodash.compact = compact;
|
||||
lodash.concat = concat;
|
||||
lodash.conforms = conforms;
|
||||
lodash.conj = conj;
|
||||
lodash.constant = constant;
|
||||
lodash.countBy = countBy;
|
||||
lodash.create = create;
|
||||
@@ -13624,7 +13623,6 @@
|
||||
lodash.difference = difference;
|
||||
lodash.differenceBy = differenceBy;
|
||||
lodash.differenceWith = differenceWith;
|
||||
lodash.disj = disj;
|
||||
lodash.drop = drop;
|
||||
lodash.dropRight = dropRight;
|
||||
lodash.dropRightWhile = dropRightWhile;
|
||||
@@ -13646,7 +13644,6 @@
|
||||
lodash.invert = invert;
|
||||
lodash.invoke = invoke;
|
||||
lodash.iteratee = iteratee;
|
||||
lodash.juxt = juxt;
|
||||
lodash.keyBy = keyBy;
|
||||
lodash.keys = keys;
|
||||
lodash.keysIn = keysIn;
|
||||
@@ -13668,6 +13665,9 @@
|
||||
lodash.omit = omit;
|
||||
lodash.omitBy = omitBy;
|
||||
lodash.once = once;
|
||||
lodash.over = over;
|
||||
lodash.overEvery = overEvery;
|
||||
lodash.overSome = overSome;
|
||||
lodash.pairs = pairs;
|
||||
lodash.pairsIn = pairsIn;
|
||||
lodash.partial = partial;
|
||||
|
||||
498
test/test.js
498
test/test.js
@@ -2757,95 +2757,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.conj');
|
||||
|
||||
(function() {
|
||||
QUnit.test('should create a function that returns `true` if all predicates return truthy', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var conjed = _.conj(lodashStable.constant(true), lodashStable.constant(1), lodashStable.constant('a'));
|
||||
assert.strictEqual(conjed(), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` as soon as a predicate returns falsey', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var count = 0,
|
||||
falsey = function() { count++; return false; },
|
||||
truthy = function() { count++; return true; },
|
||||
conjed = _.conj(truthy, falsey, truthy);
|
||||
|
||||
assert.strictEqual(conjed(), false);
|
||||
assert.strictEqual(count, 2);
|
||||
});
|
||||
|
||||
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var conjed = _.conj(undefined, null);
|
||||
assert.strictEqual(conjed(true), true);
|
||||
assert.strictEqual(conjed(false), false);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.property" style predicate', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
conjed = _.conj('a', 'c');
|
||||
|
||||
assert.strictEqual(conjed(object), false);
|
||||
|
||||
conjed = _.conj('b', 'a');
|
||||
assert.strictEqual(conjed(object), true);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
conjed = _.conj({ 'b': 2 }, { 'a': 1 });
|
||||
|
||||
assert.strictEqual(conjed(object), true);
|
||||
|
||||
conjed = _.conj({ 'a': 1 }, { 'c': 3 });
|
||||
assert.strictEqual(conjed(object), false);
|
||||
});
|
||||
|
||||
QUnit.test('should flatten `predicates`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var conjed = _.conj(lodashStable.constant(true), [lodashStable.constant(false)]);
|
||||
assert.strictEqual(conjed(), false);
|
||||
});
|
||||
|
||||
QUnit.test('should provide multiple arguments to predicates', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var args;
|
||||
|
||||
var conjed = _.conj(function() {
|
||||
args = slice.call(arguments);
|
||||
});
|
||||
|
||||
conjed('a', 'b', 'c');
|
||||
assert.deepEqual(args, ['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
QUnit.test('should not set a `this` binding', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var conjed = _.conj(function() { return this.b; }, function() { return this.a; }),
|
||||
object = { 'conjed': conjed, 'a': 1, 'b': 2 };
|
||||
|
||||
assert.strictEqual(object.conjed(), true);
|
||||
|
||||
object.a = 0;
|
||||
assert.strictEqual(object.conjed(), false);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.constant');
|
||||
|
||||
(function() {
|
||||
@@ -4093,108 +4004,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.disj');
|
||||
|
||||
(function() {
|
||||
QUnit.test('should create a function that returns `true` if any predicates return truthy', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var disjed = _.disj(lodashStable.constant(false), lodashStable.constant(1), lodashStable.constant(''));
|
||||
assert.strictEqual(disjed(), true);
|
||||
|
||||
disjed = _.disj(lodashStable.constant(null), lodashStable.constant('a'), lodashStable.constant(0));
|
||||
assert.strictEqual(disjed(), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `true` as soon as `predicate` returns truthy', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var count = 0,
|
||||
falsey = function() { count++; return false; },
|
||||
truthy = function() { count++; return true; },
|
||||
disjed = _.disj(falsey, truthy, falsey);
|
||||
|
||||
assert.strictEqual(disjed(), true);
|
||||
assert.strictEqual(count, 2);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` if all predicates return falsey', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var disjed = _.disj(lodashStable.constant(false), lodashStable.constant(false), lodashStable.constant(false));
|
||||
assert.strictEqual(disjed(), false);
|
||||
|
||||
disjed = _.disj(lodashStable.constant(null), lodashStable.constant(0), lodashStable.constant(''));
|
||||
assert.strictEqual(disjed(), false);
|
||||
});
|
||||
|
||||
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var disjed = _.disj(undefined, null);
|
||||
assert.strictEqual(disjed(true), true);
|
||||
assert.strictEqual(disjed(false), false);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.property" style predicate', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
disjed = _.disj('c', 'a');
|
||||
|
||||
assert.strictEqual(disjed(object), true);
|
||||
|
||||
disjed = _.disj('d', 'c');
|
||||
assert.strictEqual(disjed(object), false);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
disjed = _.disj({ 'c': 3 }, { 'a': 1 });
|
||||
|
||||
assert.strictEqual(disjed(object), true);
|
||||
|
||||
disjed = _.disj({ 'b': 1 }, { 'a': 2 });
|
||||
assert.strictEqual(disjed(object), false);
|
||||
});
|
||||
|
||||
QUnit.test('should flatten `predicates`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var disjed = _.disj(lodashStable.constant(false), [lodashStable.constant(true)]);
|
||||
assert.strictEqual(disjed(), true);
|
||||
});
|
||||
|
||||
QUnit.test('should provide multiple arguments to predicates', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var args;
|
||||
|
||||
var disjed = _.disj(function() {
|
||||
args = slice.call(arguments);
|
||||
});
|
||||
|
||||
disjed('a', 'b', 'c');
|
||||
assert.deepEqual(args, ['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
QUnit.test('should not set a `this` binding', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var disjed = _.disj(function() { return this.b; }, function() { return this.a; }),
|
||||
object = { 'disjed': disjed, 'a': 1, 'b': 2 };
|
||||
|
||||
assert.strictEqual(object.disjed(), true);
|
||||
|
||||
object.a = object.b = 0;
|
||||
assert.strictEqual(object.disjed(), false);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.drop');
|
||||
|
||||
(function() {
|
||||
@@ -11241,63 +11050,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.juxt');
|
||||
|
||||
(function() {
|
||||
QUnit.test('should create a function that invokes `iteratees`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var juxted = _.juxt(Math.max, Math.min);
|
||||
assert.deepEqual(juxted(1, 2, 3, 4), [4, 1]);
|
||||
});
|
||||
|
||||
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var juxted = _.juxt(undefined, null);
|
||||
assert.deepEqual(juxted('a', 'b', 'c'), ['a', 'a']);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.property" style predicate', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
juxted = _.juxt('b', 'a');
|
||||
|
||||
assert.deepEqual(juxted(object), [2, 1]);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
juxted = _.juxt({ 'c': 3 }, { 'a': 1 });
|
||||
|
||||
assert.deepEqual(juxted(object), [false, true]);
|
||||
});
|
||||
|
||||
QUnit.test('should provide multiple arguments to predicates', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var juxted = _.juxt(function() {
|
||||
return slice.call(arguments);
|
||||
});
|
||||
|
||||
assert.deepEqual(juxted('a', 'b', 'c'), [['a', 'b', 'c']]);
|
||||
});
|
||||
|
||||
QUnit.test('should not set a `this` binding', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var juxted = _.juxt(function() { return this.b; }, function() { return this.a; }),
|
||||
object = { 'juxted': juxted, 'a': 1, 'b': 2 };
|
||||
|
||||
assert.deepEqual(object.juxted(), [2, 1]);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.map');
|
||||
|
||||
(function() {
|
||||
@@ -13996,6 +13748,254 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.over');
|
||||
|
||||
(function() {
|
||||
QUnit.test('should create a function that invokes `iteratees`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var over = _.over(Math.max, Math.min);
|
||||
assert.deepEqual(over(1, 2, 3, 4), [4, 1]);
|
||||
});
|
||||
|
||||
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var over = _.over(undefined, null);
|
||||
assert.deepEqual(over('a', 'b', 'c'), ['a', 'a']);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.property" style predicate', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
over = _.over('b', 'a');
|
||||
|
||||
assert.deepEqual(over(object), [2, 1]);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
over = _.over({ 'c': 3 }, { 'a': 1 });
|
||||
|
||||
assert.deepEqual(over(object), [false, true]);
|
||||
});
|
||||
|
||||
QUnit.test('should provide multiple arguments to predicates', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var over = _.over(function() {
|
||||
return slice.call(arguments);
|
||||
});
|
||||
|
||||
assert.deepEqual(over('a', 'b', 'c'), [['a', 'b', 'c']]);
|
||||
});
|
||||
|
||||
QUnit.test('should not set a `this` binding', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var over = _.over(function() { return this.b; }, function() { return this.a; }),
|
||||
object = { 'over': over, 'a': 1, 'b': 2 };
|
||||
|
||||
assert.deepEqual(object.over(), [2, 1]);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.overEvery');
|
||||
|
||||
(function() {
|
||||
QUnit.test('should create a function that returns `true` if all predicates return truthy', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var over = _.overEvery(lodashStable.constant(true), lodashStable.constant(1), lodashStable.constant('a'));
|
||||
assert.strictEqual(over(), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` as soon as a predicate returns falsey', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var count = 0,
|
||||
falsey = function() { count++; return false; },
|
||||
truthy = function() { count++; return true; },
|
||||
over = _.overEvery(truthy, falsey, truthy);
|
||||
|
||||
assert.strictEqual(over(), false);
|
||||
assert.strictEqual(count, 2);
|
||||
});
|
||||
|
||||
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var over = _.overEvery(undefined, null);
|
||||
assert.strictEqual(over(true), true);
|
||||
assert.strictEqual(over(false), false);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.property" style predicate', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
over = _.overEvery('a', 'c');
|
||||
|
||||
assert.strictEqual(over(object), false);
|
||||
|
||||
over = _.overEvery('b', 'a');
|
||||
assert.strictEqual(over(object), true);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
over = _.overEvery({ 'b': 2 }, { 'a': 1 });
|
||||
|
||||
assert.strictEqual(over(object), true);
|
||||
|
||||
over = _.overEvery({ 'a': 1 }, { 'c': 3 });
|
||||
assert.strictEqual(over(object), false);
|
||||
});
|
||||
|
||||
QUnit.test('should flatten `predicates`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var over = _.overEvery(lodashStable.constant(true), [lodashStable.constant(false)]);
|
||||
assert.strictEqual(over(), false);
|
||||
});
|
||||
|
||||
QUnit.test('should provide multiple arguments to predicates', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var args;
|
||||
|
||||
var over = _.overEvery(function() {
|
||||
args = slice.call(arguments);
|
||||
});
|
||||
|
||||
over('a', 'b', 'c');
|
||||
assert.deepEqual(args, ['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
QUnit.test('should not set a `this` binding', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var over = _.overEvery(function() { return this.b; }, function() { return this.a; }),
|
||||
object = { 'over': over, 'a': 1, 'b': 2 };
|
||||
|
||||
assert.strictEqual(object.over(), true);
|
||||
|
||||
object.a = 0;
|
||||
assert.strictEqual(object.over(), false);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.overSome');
|
||||
|
||||
(function() {
|
||||
QUnit.test('should create a function that returns `true` if any predicates return truthy', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var over = _.overSome(lodashStable.constant(false), lodashStable.constant(1), lodashStable.constant(''));
|
||||
assert.strictEqual(over(), true);
|
||||
|
||||
over = _.overSome(lodashStable.constant(null), lodashStable.constant('a'), lodashStable.constant(0));
|
||||
assert.strictEqual(over(), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `true` as soon as `predicate` returns truthy', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var count = 0,
|
||||
falsey = function() { count++; return false; },
|
||||
truthy = function() { count++; return true; },
|
||||
over = _.overSome(falsey, truthy, falsey);
|
||||
|
||||
assert.strictEqual(over(), true);
|
||||
assert.strictEqual(count, 2);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` if all predicates return falsey', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var over = _.overSome(lodashStable.constant(false), lodashStable.constant(false), lodashStable.constant(false));
|
||||
assert.strictEqual(over(), false);
|
||||
|
||||
over = _.overSome(lodashStable.constant(null), lodashStable.constant(0), lodashStable.constant(''));
|
||||
assert.strictEqual(over(), false);
|
||||
});
|
||||
|
||||
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var over = _.overSome(undefined, null);
|
||||
assert.strictEqual(over(true), true);
|
||||
assert.strictEqual(over(false), false);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.property" style predicate', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
over = _.overSome('c', 'a');
|
||||
|
||||
assert.strictEqual(over(object), true);
|
||||
|
||||
over = _.overSome('d', 'c');
|
||||
assert.strictEqual(over(object), false);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = { 'a': 1, 'b': 2 },
|
||||
over = _.overSome({ 'c': 3 }, { 'a': 1 });
|
||||
|
||||
assert.strictEqual(over(object), true);
|
||||
|
||||
over = _.overSome({ 'b': 1 }, { 'a': 2 });
|
||||
assert.strictEqual(over(object), false);
|
||||
});
|
||||
|
||||
QUnit.test('should flatten `predicates`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var over = _.overSome(lodashStable.constant(false), [lodashStable.constant(true)]);
|
||||
assert.strictEqual(over(), true);
|
||||
});
|
||||
|
||||
QUnit.test('should provide multiple arguments to predicates', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var args;
|
||||
|
||||
var over = _.overSome(function() {
|
||||
args = slice.call(arguments);
|
||||
});
|
||||
|
||||
over('a', 'b', 'c');
|
||||
assert.deepEqual(args, ['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
QUnit.test('should not set a `this` binding', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var over = _.overSome(function() { return this.b; }, function() { return this.a; }),
|
||||
object = { 'over': over, 'a': 1, 'b': 2 };
|
||||
|
||||
assert.strictEqual(object.over(), true);
|
||||
|
||||
object.a = object.b = 0;
|
||||
assert.strictEqual(object.over(), false);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.pad');
|
||||
|
||||
(function() {
|
||||
@@ -22605,7 +22605,7 @@
|
||||
func = _[methodName];
|
||||
|
||||
var actual = lodashStable.map(falsey, function(value, index) {
|
||||
var pass = !index && /^(?:backflow|compose|conj|disj|flow(Right)?)$/.test(methodName);
|
||||
var pass = !index && /^(?:backflow|compose|flow(Right)?|over(?:Every|Some)?)$/.test(methodName);
|
||||
|
||||
try {
|
||||
index ? func(value) : func();
|
||||
|
||||
Reference in New Issue
Block a user