diff --git a/test/test.js b/test/test.js index b8e7a5e37..c23b137e5 100644 --- a/test/test.js +++ b/test/test.js @@ -71,6 +71,28 @@ isEven = function(n) { return n % 2 == 0; }, square = function(n) { return n * n; }; + /** Constant functions. */ + var alwaysA = function() { return 'a'; }, + alwaysB = function() { return 'b'; }, + alwaysC = function() { return 'c'; }; + + var alwaysTrue = function() { return true; }, + alwaysFalse = function() { return false; }; + + var alwaysNaN = function() { return NaN; }, + alwaysNull = function() { return null; }, + alwaysUndefined = function() { return undefined; }; + + var alwaysZero = function() { return 0; }, + alwaysOne = function() { return 1; }, + alwaysTwo = function() { return 2; }, + alwaysThree = function() { return 3; }, + alwaysFour = function() { return 4; }; + + var alwaysEmptyArray = function() { return []; }, + alwaysEmptyObject = function() { return {}; }, + alwaysEmptyString = function() { return ''; }; + /** The file path of the lodash file to test. */ var filePath = (function() { var min = 2, @@ -748,7 +770,7 @@ if (func) { var values = [[0], ['0'], ['1'], [3, 4], [MAX_SAFE_INTEGER - 1]], - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); var actual = lodashStable.map(values, function(args) { return func.apply(undefined, args); @@ -766,7 +788,7 @@ if (func) { var values = [['1abc'], ['07'], ['0001'], [-1], [3, 3], [1.1], [MAX_SAFE_INTEGER]], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); var actual = lodashStable.map(values, function(args) { return func.apply(undefined, args); @@ -854,7 +876,7 @@ (function() { var values = empties.concat(true, 1, 'a'), - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); QUnit.test('should create a new instance when called without the `new` operator', function(assert) { assert.expect(1); @@ -1157,15 +1179,15 @@ }; defineProperty(object, 'a', lodashStable.assign({}, descriptor, { - 'get': lodashStable.constant(1) + 'get': alwaysOne })); defineProperty(object, 'b', lodashStable.assign({}, descriptor, { - 'get': lodashStable.constant(undefined) + 'get': alwaysUndefined })); defineProperty(object, 'c', lodashStable.assign({}, descriptor, { - 'get': lodashStable.constant(NaN) + 'get': alwaysNaN })); defineProperty(object, 'constructor', lodashStable.assign({}, descriptor, { @@ -1213,7 +1235,7 @@ assert.expect(1); var expected = { 'a': undefined }; - assert.deepEqual(func({}, expected, lodashStable.constant(undefined)), expected); + assert.deepEqual(func({}, expected, alwaysUndefined), expected); }); }); @@ -1251,7 +1273,7 @@ result[value] = 1; }, []); - var expected = lodashStable.map(values, lodashStable.constant(1)), + var expected = lodashStable.map(values, alwaysOne), actual = _.at(array, values); assert.deepEqual(actual, expected); @@ -1398,7 +1420,7 @@ QUnit.test('should return the caught error', function(assert) { assert.expect(1); - var expected = lodashStable.map(errors, lodashStable.constant(true)); + var expected = lodashStable.map(errors, alwaysTrue); var actual = lodashStable.map(errors, function(error) { return _.attempt(function() { throw error; }) === error; @@ -1418,7 +1440,7 @@ assert.expect(1); if (realm.errors) { - var expected = lodashStable.map(realm.errors, lodashStable.constant(true)); + var expected = lodashStable.map(realm.errors, alwaysTrue); var actual = lodashStable.map(realm.errors, function(error) { return _.attempt(function() { throw error; }) === error; @@ -1706,7 +1728,7 @@ if (typeof createCtor == 'function') { var bound = _.bind(createCtor()), count = 8, - expected = lodashStable.times(count, lodashStable.constant(true)); + expected = lodashStable.times(count, alwaysTrue); var actual = lodashStable.times(count, function(index) { try { @@ -1903,7 +1925,7 @@ return func(string) === converted; }); - assert.deepEqual(actual, lodashStable.map(strings, lodashStable.constant(true))); + assert.deepEqual(actual, lodashStable.map(strings, alwaysTrue)); }); QUnit.test('`_.' + methodName + '` should handle double-converting strings', function(assert) { @@ -1913,7 +1935,7 @@ return func(func(string)) === converted; }); - assert.deepEqual(actual, lodashStable.map(strings, lodashStable.constant(true))); + assert.deepEqual(actual, lodashStable.map(strings, alwaysTrue)); }); QUnit.test('`_.' + methodName + '` should deburr letters', function(assert) { @@ -1931,7 +1953,7 @@ return func(burred) === letter; }); - assert.deepEqual(actual, lodashStable.map(burredLetters, lodashStable.constant(true))); + assert.deepEqual(actual, lodashStable.map(burredLetters, alwaysTrue)); }); QUnit.test('`_.' + methodName + '` should trim latin-1 mathematical operators', function(assert) { @@ -2159,7 +2181,7 @@ assert.expect(1); var values = falsey.concat(-1, -Infinity), - expected = lodashStable.map(values, lodashStable.constant([])); + expected = lodashStable.map(values, alwaysEmptyArray); var actual = lodashStable.map(values, function(value, index) { return index ? _.chunk(array, value) : _.chunk(array); @@ -2571,7 +2593,7 @@ } }, []); - var expected = lodashStable.map(objects, lodashStable.constant(true)); + var expected = lodashStable.map(objects, alwaysTrue); var actual = lodashStable.map(objects, function(object) { var Ctor = object.constructor, @@ -2920,7 +2942,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); var conforms = _.conforms({ 'a': function(value) { return value > 1; } @@ -2939,7 +2961,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(true)), + expected = lodashStable.map(values, alwaysTrue), conforms = _.conforms({}); var actual = lodashStable.map(values, function(value, index) { @@ -2955,7 +2977,7 @@ assert.expect(1); var object = { 'a': 1 }, - expected = lodashStable.map(empties, lodashStable.constant(true)); + expected = lodashStable.map(empties, alwaysTrue); var actual = lodashStable.map(empties, function(value) { var conforms = _.conforms(value); @@ -3183,7 +3205,7 @@ QUnit.test('should accept a falsey `prototype` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant({})); + var expected = lodashStable.map(falsey, alwaysEmptyObject); var actual = lodashStable.map(falsey, function(prototype, index) { return index ? _.create(prototype) : _.create(); @@ -3196,7 +3218,7 @@ assert.expect(1); var primitives = [true, null, 1, 'a', undefined], - expected = lodashStable.map(primitives, lodashStable.constant(true)); + expected = lodashStable.map(primitives, alwaysTrue); var actual = lodashStable.map(primitives, function(value, index) { return lodashStable.isPlainObject(index ? _.create(value) : _.create()); @@ -3209,7 +3231,7 @@ assert.expect(1); var array = [{ 'a': 1 }, { 'a': 1 }, { 'a': 1 }], - expected = lodashStable.map(array, lodashStable.constant(true)), + expected = lodashStable.map(array, alwaysTrue), objects = lodashStable.map(array, _.create); var actual = lodashStable.map(objects, function(object) { @@ -3255,7 +3277,7 @@ assert.expect(2); var values = ['0', 0.6, 'xyz'], - expected = lodashStable.map(values, lodashStable.constant([])); + expected = lodashStable.map(values, alwaysEmptyArray); var actual = lodashStable.map(values, function(arity) { return _.curry(fn, arity)(); @@ -3387,7 +3409,7 @@ assert.expect(2); var values = ['0', 0.6, 'xyz'], - expected = lodashStable.map(values, lodashStable.constant([])); + expected = lodashStable.map(values, alwaysEmptyArray); var actual = lodashStable.map(values, function(arity) { return _.curryRight(fn, arity)(); @@ -4102,7 +4124,7 @@ QUnit.test('`_.' + methodName + '` should work with large arrays of `NaN`', function(assert) { assert.expect(1); - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(NaN)); + var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysNaN); assert.deepEqual(func([1, NaN, 3], largeArray), [1, 3]); }); @@ -4532,7 +4554,7 @@ QUnit.test('should treat falsey `position` values, except `undefined`, as `0`', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant(true)); + var expected = lodashStable.map(falsey, alwaysTrue); var actual = lodashStable.map(falsey, function(position) { return _.endsWith(string, position === undefined ? 'c' : '', position); @@ -4652,7 +4674,7 @@ assert.expect(1); var values = [, null, undefined, ''], - expected = lodashStable.map(values, lodashStable.constant('')); + expected = lodashStable.map(values, alwaysEmptyString); var actual = lodashStable.map(values, function(value, index) { return index ? _.escapeRegExp(value) : _.escapeRegExp(); @@ -4676,7 +4698,7 @@ QUnit.test('should return `true` for empty collections', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, lodashStable.constant(true)); + var expected = lodashStable.map(empties, alwaysTrue); var actual = lodashStable.map(empties, function(value) { try { @@ -4710,7 +4732,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); var actual = lodashStable.map(values, function(value, index) { var array = [0]; @@ -4719,7 +4741,7 @@ assert.deepEqual(actual, expected); - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); actual = lodashStable.map(values, function(value, index) { var array = [1]; return index ? _.every(array, value) : _.every(array); @@ -4967,7 +4989,7 @@ object = { '1': 'foo', '8': 'bar', '50': 'baz' }; lodashStable.times(1000, function(assert) { - _.filter([], lodashStable.constant(true)); + _.filter([], alwaysTrue); }); _.filter(object, function() { @@ -5858,7 +5880,7 @@ }; var values = [-1, '1', 1.1, Object(1), MAX_SAFE_INTEGER + 1], - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); var actual = lodashStable.map(values, function(length) { return isIteratedAsObject({ 'length': length }); @@ -5947,7 +5969,7 @@ QUnit.test('`_.' + methodName + '` should coerce primitives to objects', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant(true)); + var expected = lodashStable.map(falsey, alwaysTrue); var actual = lodashStable.map(falsey, function(object, index) { var result = index ? func(object) : func(); @@ -5980,7 +6002,7 @@ QUnit.test('`_.' + methodName + '` should not error when `object` is nullish and sources are provided', function(assert) { assert.expect(1); - var expected = lodashStable.times(2, lodashStable.constant(true)); + var expected = lodashStable.times(2, alwaysTrue); var actual = lodashStable.map([null, undefined], function(value) { try { @@ -6214,7 +6236,7 @@ QUnit.test('should accept a falsey `array` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant({})); + var expected = lodashStable.map(falsey, alwaysEmptyObject); var actual = lodashStable.map(falsey, function(array, index) { try { @@ -6522,7 +6544,7 @@ delete string[0]; var values = [Array(3), args, string], - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); var actual = lodashStable.map(values, function(value) { return func(value, 0); @@ -6536,7 +6558,7 @@ assert.expect(2); var values = [null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); lodashStable.each(['constructor', ['constructor']], function(path) { var actual = lodashStable.map(values, function(value) { @@ -6551,7 +6573,7 @@ assert.expect(2); var values = [null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { var actual = lodashStable.map(values, function(value) { @@ -6725,7 +6747,7 @@ QUnit.test('should work with ' + key + ' and treat falsey `fromIndex` values as `0`', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant(true)); + var expected = lodashStable.map(falsey, alwaysTrue); var actual = lodashStable.map(falsey, function(fromIndex) { return _.includes(collection, values[0], fromIndex); @@ -6802,7 +6824,7 @@ QUnit.test('should return `false` for empty collections', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, lodashStable.constant(false)); + var expected = lodashStable.map(empties, alwaysFalse); var actual = lodashStable.map(empties, function(value) { try { @@ -6882,7 +6904,7 @@ assert.expect(1); var values = [-6, -8, -Infinity], - expected = lodashStable.map(values, lodashStable.constant(0)); + expected = lodashStable.map(values, alwaysZero); var actual = lodashStable.map(values, function(fromIndex) { return _.indexOf(array, 1, fromIndex); @@ -6894,7 +6916,7 @@ QUnit.test('should treat falsey `fromIndex` values as `0`', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant(0)); + var expected = lodashStable.map(falsey, alwaysZero); var actual = lodashStable.map(falsey, function(fromIndex) { return _.indexOf(array, 1, fromIndex); @@ -6920,7 +6942,7 @@ QUnit.test('should accept a falsey `array` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant([])); + var expected = lodashStable.map(falsey, alwaysEmptyArray); var actual = lodashStable.map(falsey, function(array, index) { try { @@ -7041,7 +7063,7 @@ assert.expect(1); var actual = [_.inRange(0, '0', 1), _.inRange(0, '1'), _.inRange(0, 0, '1'), _.inRange(0, NaN, 1), _.inRange(-1, -1, NaN)], - expected = lodashStable.map(actual, lodashStable.constant(true)); + expected = lodashStable.map(actual, alwaysTrue); assert.deepEqual(actual, expected); }); @@ -7089,7 +7111,7 @@ QUnit.test('`_.' + methodName + '` should work with large arrays of `NaN`', function(assert) { assert.expect(1); - var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(NaN)); + var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysNaN); assert.deepEqual(func([1, NaN, 3], largeArray), [NaN]); }); @@ -7275,7 +7297,7 @@ assert.expect(1); var values = [null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); var actual = lodashStable.map(values, function(value) { try { @@ -7311,7 +7333,7 @@ assert.expect(1); if (!isNpm) { - var object = { 'a': lodashStable.constant(1) }; + var object = { 'a': alwaysOne }; assert.strictEqual(_(object).invoke('a'), 1); } else { @@ -7323,7 +7345,7 @@ assert.expect(1); if (!isNpm) { - var object = { 'a': lodashStable.constant(1) }; + var object = { 'a': alwaysOne }; assert.ok(_(object).chain().invoke('a') instanceof _); } else { @@ -7397,7 +7419,7 @@ QUnit.test('should not error on elements with missing properties', function(assert) { assert.expect(1); - var objects = lodashStable.map([null, undefined, lodashStable.constant(1)], function(value) { + var objects = lodashStable.map([null, undefined, alwaysOne], function(value) { return { 'a': value }; }); @@ -7485,7 +7507,7 @@ QUnit.test('should return `false` for non `arguments` objects', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isArguments(value) : _.isArguments(); @@ -7534,7 +7556,7 @@ QUnit.test('should return `false` for non-arrays', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isArray(value) : _.isArray(); @@ -7578,7 +7600,7 @@ assert.expect(1); var values = [args, [1, 2, 3], { '0': 1, 'length': 1 }, 'a'], - expected = lodashStable.map(values, lodashStable.constant(true)), + expected = lodashStable.map(values, alwaysTrue), actual = lodashStable.map(values, _.isArrayLike); assert.deepEqual(actual, expected); @@ -7614,7 +7636,7 @@ if (realm.object) { var values = [realm.arguments, realm.array, realm.string], - expected = lodashStable.map(values, lodashStable.constant(true)), + expected = lodashStable.map(values, alwaysTrue), actual = lodashStable.map(values, _.isArrayLike); assert.deepEqual(actual, expected); @@ -7695,7 +7717,7 @@ QUnit.test('should return `false` for non-dates', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isDate(value) : _.isDate(); @@ -7756,7 +7778,7 @@ QUnit.test('should return `false` for non DOM elements', function(assert) { assert.expect(13); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isElement(value) : _.isElement(); @@ -7800,7 +7822,7 @@ QUnit.test('should return `true` for empty values', function(assert) { assert.expect(8); - var expected = lodashStable.map(empties, lodashStable.constant(true)), + var expected = lodashStable.map(empties, alwaysTrue), actual = lodashStable.map(empties, _.isEmpty); assert.deepEqual(actual, expected); @@ -8232,7 +8254,7 @@ var primitive, object = { 'toString': function() { return primitive; } }, values = [true, null, 1, 'a', undefined], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); var actual = lodashStable.map(values, function(value) { primitive = value; @@ -8629,11 +8651,11 @@ QUnit.test('should return a boolean value even if `customizer` does not', function(assert) { assert.expect(2); - var actual = _.isEqualWith('a', 'b', lodashStable.constant('c')); + var actual = _.isEqualWith('a', 'b', alwaysC); assert.strictEqual(actual, true); var values = _.without(falsey, undefined), - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); actual = []; lodashStable.each(values, function(value) { @@ -8713,7 +8735,7 @@ QUnit.test('should return `true` for error objects', function(assert) { assert.expect(1); - var expected = lodashStable.map(errors, lodashStable.constant(true)); + var expected = lodashStable.map(errors, alwaysTrue); var actual = lodashStable.map(errors, function(error) { return _.isError(error) === true; @@ -8725,7 +8747,7 @@ QUnit.test('should return `false` for non error objects', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isError(value) : _.isError(); @@ -8750,7 +8772,7 @@ assert.expect(1); if (realm.errors) { - var expected = lodashStable.map(realm.errors, lodashStable.constant(true)); + var expected = lodashStable.map(realm.errors, alwaysTrue); var actual = lodashStable.map(realm.errors, function(error) { return _.isError(error) === true; @@ -8775,7 +8797,7 @@ assert.expect(1); var values = [0, 1, 3.14, -1], - expected = lodashStable.map(values, lodashStable.constant(true)), + expected = lodashStable.map(values, alwaysTrue), actual = lodashStable.map(values, _.isFinite); assert.deepEqual(actual, expected); @@ -8785,7 +8807,7 @@ assert.expect(1); var values = [NaN, Infinity, -Infinity, Object(1)], - expected = lodashStable.map(values, lodashStable.constant(false)), + expected = lodashStable.map(values, alwaysFalse), actual = lodashStable.map(values, _.isFinite); assert.deepEqual(actual, expected); @@ -8795,7 +8817,7 @@ assert.expect(10); var values = [undefined, [], true, '', ' ', '2px'], - expected = lodashStable.map(values, lodashStable.constant(false)), + expected = lodashStable.map(values, alwaysFalse), actual = lodashStable.map(values, _.isFinite); assert.deepEqual(actual, expected); @@ -8815,7 +8837,7 @@ assert.expect(1); var values = ['2', '0', '08'], - expected = lodashStable.map(values, lodashStable.constant(false)), + expected = lodashStable.map(values, alwaysFalse), actual = lodashStable.map(values, _.isFinite); assert.deepEqual(actual, expected); @@ -8859,7 +8881,7 @@ QUnit.test('should return `false` for non-functions', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isFunction(value) : _.isFunction(); @@ -8926,7 +8948,7 @@ assert.expect(2); var values = [-1, 0, 1], - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); var actual = lodashStable.map(values, function(value) { return func(value); @@ -8940,7 +8962,7 @@ assert.expect(1); var values = [NaN, Infinity, -Infinity, Object(1), 3.14], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); var actual = lodashStable.map(values, function(value) { return func(value); @@ -8983,7 +9005,7 @@ assert.expect(1); var values = [0, 3, MAX_SAFE_INTEGER], - expected = lodashStable.map(values, lodashStable.constant(true)), + expected = lodashStable.map(values, alwaysTrue), actual = lodashStable.map(values, _.isLength); assert.deepEqual(actual, expected); @@ -8993,7 +9015,7 @@ assert.expect(1); var values = [-1, '1', 1.1, MAX_SAFE_INTEGER + 1], - expected = lodashStable.map(values, lodashStable.constant(false)), + expected = lodashStable.map(values, alwaysFalse), actual = lodashStable.map(values, _.isLength); assert.deepEqual(actual, expected); @@ -9035,7 +9057,7 @@ var objects = [{ 'a': 1 }, { 'a': 1, 'b': 2 }], source = new Foo, - expected = lodashStable.map(objects, lodashStable.constant(true)); + expected = lodashStable.map(objects, alwaysTrue); var actual = lodashStable.map(objects, function(object) { return _.isMatch(object, source); @@ -9267,7 +9289,7 @@ assert.expect(1); var values = [null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)), + expected = lodashStable.map(values, alwaysFalse), source = { 'a': 1 }; var actual = lodashStable.map(values, function(value) { @@ -9283,7 +9305,7 @@ assert.expect(1); var values = [null, undefined], - expected = lodashStable.map(values, lodashStable.constant(true)), + expected = lodashStable.map(values, alwaysTrue), source = {}; var actual = lodashStable.map(values, function(value) { @@ -9299,7 +9321,7 @@ assert.expect(1); var object = { 'a': 1 }, - expected = lodashStable.map(empties, lodashStable.constant(true)); + expected = lodashStable.map(empties, alwaysTrue); var actual = lodashStable.map(empties, function(value) { return _.isMatch(object, value); @@ -9391,11 +9413,11 @@ assert.expect(2); var object = { 'a': 1 }, - actual = _.isMatchWith(object, { 'a': 1 }, lodashStable.constant('a')); + actual = _.isMatchWith(object, { 'a': 1 }, alwaysA); assert.strictEqual(actual, true); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); actual = []; lodashStable.each(falsey, function(value) { @@ -9548,7 +9570,7 @@ QUnit.test('should return `false` for non-native methods', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isNative(value) : _.isNative(); @@ -9799,7 +9821,7 @@ assert.expect(1); var values = falsey.concat(true, 1, 'a', symbol), - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); var actual = lodashStable.map(values, function(value, index) { return index ? _.isObject(value) : _.isObject(); @@ -9873,7 +9895,7 @@ assert.expect(1); var values = falsey.concat(true, _, slice, 1, 'a', symbol), - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); var actual = lodashStable.map(values, function(value, index) { return index ? _.isObjectLike(value) : _.isObjectLike(); @@ -9973,7 +9995,7 @@ QUnit.test('should return `false` for non-objects', function(assert) { assert.expect(4); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isPlainObject(value) : _.isPlainObject(); @@ -10015,7 +10037,7 @@ QUnit.test('should return `false` for non-regexes', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isRegExp(value) : _.isRegExp(); @@ -10122,7 +10144,7 @@ QUnit.test('should return `false` for non-symbols', function(assert) { assert.expect(12); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isSymbol(value) : _.isSymbol(); @@ -10180,7 +10202,7 @@ QUnit.test('should return `false` for non typed arrays', function(assert) { assert.expect(13); - var expected = lodashStable.map(falsey, lodashStable.constant(false)); + var expected = lodashStable.map(falsey, alwaysFalse); var actual = lodashStable.map(falsey, function(value, index) { return index ? _.isTypedArray(value) : _.isTypedArray(); @@ -10486,7 +10508,7 @@ var fn = function() { return this instanceof Number; }, array = [fn, fn, fn], iteratees = lodashStable.map(array, _.iteratee), - expected = lodashStable.map(array, lodashStable.constant(false)); + expected = lodashStable.map(array, alwaysFalse); var actual = lodashStable.map(iteratees, function(iteratee) { return iteratee(); @@ -11499,7 +11521,7 @@ assert.expect(1); var values = [-6, -8, -Infinity], - expected = lodashStable.map(values, lodashStable.constant(0)); + expected = lodashStable.map(values, alwaysZero); var actual = lodashStable.map(values, function(fromIndex) { return _.lastIndexOf(array, 1, fromIndex); @@ -11671,7 +11693,7 @@ QUnit.test('should accept a falsey `collection` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant([])); + var expected = lodashStable.map(falsey, alwaysEmptyArray); var actual = lodashStable.map(falsey, function(collection, index) { try { @@ -11844,7 +11866,7 @@ QUnit.test('should accept a falsey `object` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant({})); + var expected = lodashStable.map(falsey, alwaysEmptyObject); var actual = lodashStable.map(falsey, function(object, index) { try { @@ -11917,7 +11939,7 @@ var objects = [{ 'a': 1 }, { 'a': 1, 'b': 2 }], source = new Foo, actual = lodashStable.map(objects, _.matches(source)), - expected = lodashStable.map(objects, lodashStable.constant(true)); + expected = lodashStable.map(objects, alwaysTrue); assert.deepEqual(actual, expected); }); @@ -12133,7 +12155,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)), + expected = lodashStable.map(values, alwaysFalse), matches = _.matches({ 'a': 1 }); var actual = lodashStable.map(values, function(value, index) { @@ -12149,7 +12171,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(true)), + expected = lodashStable.map(values, alwaysTrue), matches = _.matches({}); var actual = lodashStable.map(values, function(value, index) { @@ -12165,7 +12187,7 @@ assert.expect(1); var object = { 'a': 1 }, - expected = lodashStable.map(empties, lodashStable.constant(true)); + expected = lodashStable.map(empties, alwaysTrue); var actual = lodashStable.map(empties, function(value) { var matches = _.matches(value); @@ -12315,7 +12337,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { var matches = _.matchesProperty(path, 1); @@ -12351,7 +12373,7 @@ Foo.prototype.b = 2; var objects = [{ 'a': { 'a': 1 } }, { 'a': { 'a': 1, 'b': 2 } }], - expected = lodashStable.map(objects, lodashStable.constant(true)); + expected = lodashStable.map(objects, alwaysTrue); lodashStable.each(['a', ['a']], function(path) { assert.deepEqual(lodashStable.map(objects, _.matchesProperty(path, new Foo)), expected); @@ -12545,7 +12567,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); lodashStable.each(['constructor', ['constructor']], function(path) { var matches = _.matchesProperty(path, 1); @@ -12612,7 +12634,7 @@ assert.expect(1); var values = falsey.concat([[]]), - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); var actual = lodashStable.map(values, function(value, index) { try { @@ -12692,7 +12714,7 @@ QUnit.test('should not error if `resolver` is falsey', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant(true)); + var expected = lodashStable.map(falsey, alwaysTrue); var actual = lodashStable.map(falsey, function(resolver, index) { try { @@ -13097,7 +13119,7 @@ function Foo() {} var values = [new Foo, new Boolean, new Date, Foo, new Number, new String, new RegExp], - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); var actual = lodashStable.map(values, function(value) { var object = _.merge({}, { 'value': value }); @@ -13111,7 +13133,7 @@ assert.expect(1); var values = [[], new (Uint8Array || Object), {}], - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); var actual = lodashStable.map(values, function(value) { var object = _.merge({}, { 'value': value }); @@ -13214,7 +13236,7 @@ var object1 = { 'el': document && document.createElement('div') }, object2 = { 'el': document && document.createElement('div') }, pairs = [[{}, object1], [object1, object2]], - expected = lodashStable.map(pairs, lodashStable.constant(true)); + expected = lodashStable.map(pairs, alwaysTrue); var actual = lodashStable.map(pairs, function(pair) { try { @@ -13260,7 +13282,7 @@ QUnit.test('should create a function that calls a method of a given object', function(assert) { assert.expect(4); - var object = { 'a': lodashStable.constant(1) }; + var object = { 'a': alwaysOne }; lodashStable.each(['a', ['a']], function(path) { var method = _.method(path); @@ -13272,7 +13294,7 @@ QUnit.test('should work with deep property values', function(assert) { assert.expect(2); - var object = { 'a': { 'b': { 'c': lodashStable.constant(3) } } }; + var object = { 'a': { 'b': { 'c': alwaysThree } } }; lodashStable.each(['a.b.c', ['a', 'b', 'c']], function(path) { var method = _.method(path); @@ -13298,7 +13320,7 @@ fn.toString = lodashStable.constant('fn'); var expected = [1, 1, 2, 2, 3, 3, 4, 4], - objects = [{ 'null': lodashStable.constant(1) }, { 'undefined': lodashStable.constant(2) }, { 'fn': lodashStable.constant(3) }, { '[object Object]': lodashStable.constant(4) }], + objects = [{ 'null': alwaysOne }, { 'undefined': alwaysTwo }, { 'fn': alwaysThree }, { '[object Object]': alwaysFour }], values = [null, undefined, fn, {}]; var actual = lodashStable.transform(objects, function(result, object, index) { @@ -13316,7 +13338,7 @@ assert.expect(2); function Foo() {} - Foo.prototype.a = lodashStable.constant(1); + Foo.prototype.a = alwaysOne; lodashStable.each(['a', ['a']], function(path) { var method = _.method(path); @@ -13327,7 +13349,7 @@ QUnit.test('should use a key over a path', function(assert) { assert.expect(2); - var object = { 'a.b.c': lodashStable.constant(3), 'a': { 'b': { 'c': lodashStable.constant(4) } } }; + var object = { 'a.b.c': alwaysThree, 'a': { 'b': { 'c': alwaysFour } } }; lodashStable.each(['a.b.c', ['a.b.c']], function(path) { var method = _.method(path); @@ -13339,7 +13361,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); lodashStable.each(['constructor', ['constructor']], function(path) { var method = _.method(path); @@ -13356,7 +13378,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { var method = _.method(path); @@ -13415,7 +13437,7 @@ QUnit.test('should create a function that calls a method of a given key', function(assert) { assert.expect(4); - var object = { 'a': lodashStable.constant(1) }; + var object = { 'a': alwaysOne }; lodashStable.each(['a', ['a']], function(path) { var methodOf = _.methodOf(object); @@ -13427,7 +13449,7 @@ QUnit.test('should work with deep property values', function(assert) { assert.expect(2); - var object = { 'a': { 'b': { 'c': lodashStable.constant(3) } } }; + var object = { 'a': { 'b': { 'c': alwaysThree } } }; lodashStable.each(['a.b.c', ['a', 'b', 'c']], function(path) { var methodOf = _.methodOf(object); @@ -13453,7 +13475,7 @@ fn.toString = lodashStable.constant('fn'); var expected = [1, 1, 2, 2, 3, 3, 4, 4], - objects = [{ 'null': lodashStable.constant(1) }, { 'undefined': lodashStable.constant(2) }, { 'fn': lodashStable.constant(3) }, { '[object Object]': lodashStable.constant(4) }], + objects = [{ 'null': alwaysOne }, { 'undefined': alwaysTwo }, { 'fn': alwaysThree }, { '[object Object]': alwaysFour }], values = [null, undefined, fn, {}]; var actual = lodashStable.transform(objects, function(result, object, index) { @@ -13471,7 +13493,7 @@ assert.expect(2); function Foo() {} - Foo.prototype.a = lodashStable.constant(1); + Foo.prototype.a = alwaysOne; lodashStable.each(['a', ['a']], function(path) { var methodOf = _.methodOf(new Foo); @@ -13482,7 +13504,7 @@ QUnit.test('should use a key over a path', function(assert) { assert.expect(2); - var object = { 'a.b.c': lodashStable.constant(3), 'a': { 'b': { 'c': lodashStable.constant(4) } } }; + var object = { 'a.b.c': alwaysThree, 'a': { 'b': { 'c': alwaysFour } } }; lodashStable.each(['a.b.c', ['a.b.c']], function(path) { var methodOf = _.methodOf(object); @@ -13494,7 +13516,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); lodashStable.each(['constructor', ['constructor']], function(path) { var actual = lodashStable.map(values, function(value, index) { @@ -13510,7 +13532,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { var actual = lodashStable.map(values, function(value, index) { @@ -13576,7 +13598,7 @@ assert.expect(1); var values = falsey.concat([[]]), - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); var actual = lodashStable.map(values, function(value, index) { try { @@ -13730,7 +13752,7 @@ if (!isNpm) { _.mixin(source); - _.a = lodashStable.constant('b'); + _.a = alwaysB; assert.strictEqual(_.a(array), 'b'); assert.strictEqual(_(array).a().value(), 'a'); @@ -14068,7 +14090,7 @@ assert.expect(1); var values = empties.concat(true, new Date, _, 1, /x/, 'a'), - expected = lodashStable.map(values, lodashStable.constant()); + expected = lodashStable.map(values, alwaysUndefined); var actual = lodashStable.map(values, function(value, index) { return index ? _.noop(value) : _.noop(); @@ -14161,7 +14183,7 @@ assert.expect(2); var values = falsey, - expected = lodashStable.map(values, lodashStable.constant('a')); + expected = lodashStable.map(values, alwaysA); var actual = lodashStable.map(values, function(n) { var func = n ? _.nthArg(n) : _.nthArg(); @@ -14171,7 +14193,7 @@ assert.deepEqual(actual, expected); values = ['1', 1.6]; - expected = lodashStable.map(values, lodashStable.constant('b')); + expected = lodashStable.map(values, alwaysB); actual = lodashStable.map(values, function(n) { var func = _.nthArg(n); @@ -14408,7 +14430,7 @@ 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')); + var over = _.overEvery(alwaysTrue, alwaysOne, alwaysA); assert.strictEqual(over(), true); }); @@ -14416,9 +14438,9 @@ assert.expect(2); var count = 0, - alwaysFalse = function() { count++; return false; }, - alwaysTrue = function() { count++; return true; }, - over = _.overEvery(alwaysTrue, alwaysFalse, alwaysTrue); + countFalse = function() { count++; return false; }, + countTrue = function() { count++; return true; }, + over = _.overEvery(countTrue, countFalse, countTrue); assert.strictEqual(over(), false); assert.strictEqual(count, 2); @@ -14459,7 +14481,7 @@ QUnit.test('should flatten `predicates`', function(assert) { assert.expect(1); - var over = _.overEvery(lodashStable.constant(true), [lodashStable.constant(false)]); + var over = _.overEvery(alwaysTrue, [alwaysFalse]); assert.strictEqual(over(), false); }); @@ -14497,10 +14519,10 @@ 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('')); + var over = _.overSome(alwaysFalse, alwaysOne, alwaysEmptyString); assert.strictEqual(over(), true); - over = _.overSome(lodashStable.constant(null), lodashStable.constant('a'), lodashStable.constant(0)); + over = _.overSome(alwaysNull, alwaysA, alwaysZero); assert.strictEqual(over(), true); }); @@ -14508,9 +14530,9 @@ assert.expect(2); var count = 0, - falsey = function() { count++; return false; }, - truthy = function() { count++; return true; }, - over = _.overSome(falsey, truthy, falsey); + countFalse = function() { count++; return false; }, + countTrue = function() { count++; return true; }, + over = _.overSome(countFalse, countTrue, countFalse); assert.strictEqual(over(), true); assert.strictEqual(count, 2); @@ -14519,10 +14541,10 @@ 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)); + var over = _.overSome(alwaysFalse, alwaysFalse, alwaysFalse); assert.strictEqual(over(), false); - over = _.overSome(lodashStable.constant(null), lodashStable.constant(0), lodashStable.constant('')); + over = _.overSome(alwaysNull, alwaysZero, alwaysEmptyString); assert.strictEqual(over(), false); }); @@ -14561,7 +14583,7 @@ QUnit.test('should flatten `predicates`', function(assert) { assert.expect(1); - var over = _.overSome(lodashStable.constant(false), [lodashStable.constant(true)]); + var over = _.overSome(alwaysFalse, [alwaysTrue]); assert.strictEqual(over(), true); }); @@ -14800,7 +14822,7 @@ QUnit.test('should coerce `radix` to a number', function(assert) { assert.expect(2); - var object = { 'valueOf': lodashStable.constant(0) }; + var object = { 'valueOf': alwaysZero }; assert.strictEqual(_.parseInt('08', object), 8); assert.strictEqual(_.parseInt('0x20', object), 32); }); @@ -15177,8 +15199,8 @@ assert.expect(3); assert.deepEqual(_.partition([], identity), [[], []]); - assert.deepEqual(_.partition(array, lodashStable.constant(true)), [array, []]); - assert.deepEqual(_.partition(array, lodashStable.constant(false)), [[], array]); + assert.deepEqual(_.partition(array, alwaysTrue), [array, []]); + assert.deepEqual(_.partition(array, alwaysFalse), [[], array]); }); QUnit.test('should use `_.identity` when `predicate` is nullish', function(assert) { @@ -15417,7 +15439,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); lodashStable.each(['constructor', ['constructor']], function(path) { var prop = _.property(path); @@ -15434,7 +15456,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { var prop = _.property(path); @@ -15547,7 +15569,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); lodashStable.each(['constructor', ['constructor']], function(path) { var actual = lodashStable.map(values, function(value, index) { @@ -15563,7 +15585,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)); + expected = lodashStable.map(values, alwaysUndefined); lodashStable.each(['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']], function(path) { var actual = lodashStable.map(values, function(value, index) { @@ -15756,12 +15778,12 @@ result[value] = 1; }, []); - var expected = lodashStable.map(values, lodashStable.constant(1)), + var expected = lodashStable.map(values, alwaysOne), actual = _.pullAt(array, values); assert.deepEqual(actual, expected); - expected = lodashStable.map(values, lodashStable.constant(undefined)), + expected = lodashStable.map(values, alwaysUndefined), actual = _.at(array, values); assert.deepEqual(actual, expected); @@ -15907,7 +15929,7 @@ assert.expect(1); var array = [1, 2, 3], - expected = lodashStable.map(array, lodashStable.constant(true)), + expected = lodashStable.map(array, alwaysTrue), randoms = lodashStable.map(array, _.random); var actual = lodashStable.map(randoms, function(result, index) { @@ -16247,7 +16269,7 @@ assert.expect(1); var actual = [], - expected = lodashStable.map(empties, lodashStable.constant()); + expected = lodashStable.map(empties, alwaysUndefined); lodashStable.each(empties, function(value) { try { @@ -16573,7 +16595,7 @@ assert.strictEqual(_.repeat('abc'), ''); assert.strictEqual(_.repeat('abc', '2'), 'abcabc'); assert.strictEqual(_.repeat('abc', 2.6), 'abcabc'); - assert.strictEqual(_.repeat('*', { 'valueOf': lodashStable.constant(3) }), '***'); + assert.strictEqual(_.repeat('*', { 'valueOf': alwaysThree }), '***'); }); QUnit.test('should coerce `string` to a string', function(assert) { @@ -16720,7 +16742,7 @@ assert.expect(2); var values = [null, undefined], - expected = lodashStable.map(values, lodashStable.constant(undefined)), + expected = lodashStable.map(values, alwaysUndefined), paths = ['constructor.prototype.valueOf', ['constructor', 'prototype', 'valueOf']]; lodashStable.each(paths, function(path) { @@ -17135,7 +17157,7 @@ QUnit.test('should return `undefined` when sampling empty collections', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, lodashStable.constant(undefined)); + var expected = lodashStable.map(empties, alwaysUndefined); var actual = lodashStable.transform(empties, function(result, value) { try { @@ -17181,7 +17203,7 @@ QUnit.test('should treat falsey `n` values as `0`', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant([])); + var expected = lodashStable.map(falsey, alwaysEmptyArray); var actual = lodashStable.map(falsey, function(n, index) { return index ? _.sampleSize([1], n) : _.sampleSize([1]); @@ -17216,7 +17238,7 @@ QUnit.test('should return an empty array for empty collections', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, lodashStable.constant([])); + var expected = lodashStable.map(empties, alwaysEmptyArray); var actual = lodashStable.transform(empties, function(result, value) { try { @@ -17258,7 +17280,7 @@ QUnit.test('should work with a `customizer` that returns `undefined`', function(assert) { assert.expect(1); - var actual = _.setWith({}, 'a[0].b.c', 4, lodashStable.constant(undefined)); + var actual = _.setWith({}, 'a[0].b.c', 4, alwaysUndefined); assert.deepEqual(actual, { 'a': [{ 'b': { 'c': 4 } }] }); }); }()); @@ -17531,7 +17553,7 @@ QUnit.test('should accept a falsey `object` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant(0)); + var expected = lodashStable.map(falsey, alwaysZero); var actual = lodashStable.map(falsey, function(object, index) { try { @@ -17759,7 +17781,7 @@ QUnit.test('should return `false` for empty collections', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, lodashStable.constant(false)); + var expected = lodashStable.map(empties, alwaysFalse); var actual = lodashStable.map(empties, function(value) { try { @@ -17794,7 +17816,7 @@ assert.expect(2); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); var actual = lodashStable.map(values, function(value, index) { var array = [0, 0]; @@ -17803,7 +17825,7 @@ assert.deepEqual(actual, expected); - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); actual = lodashStable.map(values, function(value, index) { var array = [0, 1]; return index ? _.some(array, value) : _.some(array); @@ -18006,9 +18028,10 @@ var funcs = [func, lodashStable.partialRight(func, 'bogus')]; lodashStable.each(['a', 0, [0]], function(props, index) { - var expected = lodashStable.map(funcs, lodashStable.constant(index - ? [objects[2], objects[3], objects[0], objects[1]] - : [objects[0], objects[2], objects[1], objects[3]] + var expected = lodashStable.map(funcs, lodashStable.constant( + index + ? [objects[2], objects[3], objects[0], objects[1]] + : [objects[0], objects[2], objects[1], objects[3]] )); var actual = lodashStable.map(funcs, function(func) { @@ -18223,8 +18246,7 @@ QUnit.test('should accept a falsey `array` argument', function(assert) { assert.expect(1); - var alwaysTrue = lodashStable.constant(true), - spread = _.spread(alwaysTrue), + var spread = _.spread(alwaysTrue), expected = lodashStable.map(falsey, alwaysTrue); var actual = lodashStable.map(falsey, function(array, index) { @@ -18286,7 +18308,7 @@ QUnit.test('should treat falsey `position` values as `0`', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant(true)); + var expected = lodashStable.map(falsey, alwaysTrue); var actual = lodashStable.map(falsey, function(position) { return _.startsWith(string, 'a', position); @@ -18420,7 +18442,7 @@ QUnit.test('should return `undefined` when passing empty `array` values', function(assert) { assert.expect(1); - var expected = lodashStable.map(empties, lodashStable.constant(undefined)), + var expected = lodashStable.map(empties, alwaysUndefined), actual = lodashStable.map(empties, _.sum); assert.deepEqual(actual, expected); @@ -18494,7 +18516,7 @@ QUnit.test('should accept a falsey `array` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant([])); + var expected = lodashStable.map(falsey, alwaysEmptyArray); var actual = lodashStable.map(falsey, function(array, index) { try { @@ -19459,7 +19481,7 @@ assert.expect(1); var values = [, null, undefined, ''], - expected = lodashStable.map(values, lodashStable.constant('')), + expected = lodashStable.map(values, alwaysEmptyString), data = { 'a': 1 }; var actual = lodashStable.map(values, function(value, index) { @@ -19545,7 +19567,7 @@ var compiled = _.template('x'), values = [String(compiled), compiled.source], - expected = lodashStable.map(values, lodashStable.constant(true)); + expected = lodashStable.map(values, alwaysTrue); var actual = lodashStable.map(values, function(value) { return lodashStable.includes(value, '__p'); @@ -19577,7 +19599,7 @@ } catch (e) { values[1] = e.source; } - var expected = lodashStable.map(values, lodashStable.constant(false)); + var expected = lodashStable.map(values, alwaysFalse); var actual = lodashStable.map(values, function(value) { return lodashStable.includes(value, 'sourceURL'); @@ -20151,7 +20173,7 @@ assert.expect(1); var values = falsey.concat(-1, -Infinity), - expected = lodashStable.map(values, lodashStable.constant([])); + expected = lodashStable.map(values, alwaysEmptyArray); var actual = lodashStable.map(values, function(value, index) { return index ? _.times(value) : _.times(); @@ -20713,7 +20735,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant('')); + expected = lodashStable.map(values, alwaysEmptyString); var actual = lodashStable.map(values, function(value, index) { return index ? _.toString(value) : _.toString(); @@ -20775,7 +20797,7 @@ assert.expect(4); var accumulators = [, null, undefined], - expected = lodashStable.map(accumulators, lodashStable.constant(true)), + expected = lodashStable.map(accumulators, alwaysTrue), object = new Foo; var iteratee = function(result, value, key) { @@ -20814,7 +20836,7 @@ QUnit.test('should create regular arrays from typed arrays', function(assert) { assert.expect(1); - var expected = lodashStable.map(typedArrays, lodashStable.constant(true)); + var expected = lodashStable.map(typedArrays, alwaysTrue); var actual = lodashStable.map(typedArrays, function(type) { var Ctor = root[type], @@ -20885,7 +20907,7 @@ var Ctors = [Boolean, Boolean, Number, Number, Number, String, String], values = [true, false, 0, 1, NaN, '', 'a'], - expected = lodashStable.map(values, lodashStable.constant({})); + expected = lodashStable.map(values, alwaysEmptyObject); var results = lodashStable.map(values, function(value) { return _.transform(value); @@ -20893,7 +20915,7 @@ assert.deepEqual(results, expected); - expected = lodashStable.map(values, lodashStable.constant(false)); + expected = lodashStable.map(values, alwaysFalse); var actual = lodashStable.map(results, function(value, index) { return value instanceof Ctors[index]; @@ -20913,7 +20935,7 @@ QUnit.test('should create an empty object when provided a falsey `object` argument', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant({})); + var expected = lodashStable.map(falsey, alwaysEmptyObject); var actual = lodashStable.map(falsey, function(object, index) { return index ? _.transform(object) : _.transform(); @@ -20954,7 +20976,7 @@ return lodashStable.isObject(value) && !lodashStable.isElement(value); }); - var expected = lodashStable.map(objects, lodashStable.constant(true)); + var expected = lodashStable.map(objects, alwaysTrue); var actual = lodashStable.map(objects, function(object) { var Ctor = object.constructor, @@ -21910,7 +21932,7 @@ assert.expect(1); var operators = ['\xac', '\xb1', '\xd7', '\xf7'], - expected = lodashStable.map(operators, lodashStable.constant([])), + expected = lodashStable.map(operators, alwaysEmptyArray), actual = lodashStable.map(operators, _.words); assert.deepEqual(actual, expected); @@ -21985,7 +22007,7 @@ assert.expect(1); var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant('a')); + expected = lodashStable.map(values, alwaysA); var actual = lodashStable.map(values, function(value, index) { var wrapped = index ? _.wrap('a', value) : _.wrap('a'); @@ -22283,7 +22305,7 @@ QUnit.test('`_.' + methodName + '` should treat falsey values as empty arrays', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, lodashStable.constant([])); + var expected = lodashStable.map(falsey, alwaysEmptyArray); var actual = lodashStable.map(falsey, function(value) { return func([value, value, value]); @@ -23005,7 +23027,7 @@ assert.expect(1); var values = [, null, undefined, ''], - expected = lodashStable.map(values, lodashStable.constant('')); + expected = lodashStable.map(values, alwaysEmptyString); var actual = lodashStable.map(values, function(value, index) { return index ? func(value) : func(); @@ -23111,7 +23133,7 @@ QUnit.test('should accept falsey arguments', function(assert) { assert.expect(287); - var emptyArrays = lodashStable.map(falsey, lodashStable.constant([])); + var emptyArrays = lodashStable.map(falsey, alwaysEmptyArray); lodashStable.each(acceptFalsey, function(methodName) { var expected = emptyArrays, @@ -23176,7 +23198,7 @@ assert.expect(24); lodashStable.each(rejectFalsey, function(methodName) { - var expected = lodashStable.map(falsey, lodashStable.constant(true)), + var expected = lodashStable.map(falsey, alwaysTrue), func = _[methodName]; var actual = lodashStable.map(falsey, function(value, index) {