wip: code formatting nits

This commit is contained in:
jdalton
2023-09-16 16:18:43 -07:00
parent 97d4a2fe19
commit 0b28b7f7b6
107 changed files with 166 additions and 164 deletions

View File

@@ -45,7 +45,7 @@ class ListCache {
return false
}
const lastIndex = data.length - 1
if (index == lastIndex) {
if (index === lastIndex) {
data.pop()
} else {
data.splice(index, 1)

View File

@@ -112,7 +112,7 @@ class MapCache {
const size = data.size
data.set(key, value)
this.size += data.size == size ? 0 : 1
this.size += data.size === size ? 0 : 1
return this
}
}

View File

@@ -8,7 +8,7 @@
* @param {*} value The value to assign.
*/
function baseAssignValue(object, key, value) {
if (key == '__proto__') {
if (key === '__proto__') {
Object.defineProperty(object, key, {
'configurable': true,
'enumerable': true,

View File

@@ -182,7 +182,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
if (isBuffer(value)) {
return cloneBuffer(value, isDeep)
}
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
if (tag === objectTag || tag === argsTag || (isFunc && !object)) {
result = (isFlat || isFunc) ? {} : initCloneObject(value)
if (!isDeep) {
return isFlat
@@ -204,14 +204,14 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
}
stack.set(value, result)
if (tag == mapTag) {
if (tag === mapTag) {
value.forEach((subValue, key) => {
result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack))
})
return result
}
if (tag == setTag) {
if (tag === setTag) {
value.forEach((subValue) => {
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack))
})

View File

@@ -18,7 +18,7 @@ function baseGet(object, path) {
while (object != null && index < length) {
object = object[toKey(path[index++])]
}
return (index && index == length) ? object : undefined
return (index && index === length) ? object : undefined
}
export default baseGet

View File

@@ -37,12 +37,12 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
let objTag = objIsArr ? arrayTag : getTag(object)
let othTag = othIsArr ? arrayTag : getTag(other)
objTag = objTag == argsTag ? objectTag : objTag
othTag = othTag == argsTag ? objectTag : othTag
objTag = objTag === argsTag ? objectTag : objTag
othTag = othTag === argsTag ? objectTag : othTag
let objIsObj = objTag == objectTag
const othIsObj = othTag == objectTag
const isSameTag = objTag == othTag
let objIsObj = objTag === objectTag
const othIsObj = othTag === objectTag
const isSameTag = objTag === othTag
if (isSameTag && isBuffer(object)) {
if (!isBuffer(other)) {

View File

@@ -30,7 +30,7 @@ function baseSet(object, path, value, customizer) {
const key = toKey(path[index])
let newValue = value
if (index != lastIndex) {
if (index !== lastIndex) {
const objValue = nested[key]
newValue = customizer ? customizer(objValue, key, nested) : undefined
if (newValue === undefined) {

View File

@@ -20,7 +20,7 @@ const MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1
function baseSortedIndexBy(array, value, iteratee, retHighest) {
let low = 0
let high = array == null ? 0 : array.length
if (high == 0) {
if (high === 0) {
return 0
}

View File

@@ -25,7 +25,7 @@ function baseXor(arrays, iteratee, comparator) {
let othIndex = -1
while (++othIndex < length) {
if (othIndex != index) {
if (othIndex !== index) {
result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator)
}
}

View File

@@ -27,7 +27,7 @@ function compareMultiple(object, other, orders) {
const result = cmpFn(objCriteria[index], othCriteria[index])
if (result) {
if (order && typeof order !== 'function') {
return result * (order == 'desc' ? -1 : 1)
return result * (order === 'desc' ? -1 : 1)
}
return result
}

View File

@@ -10,7 +10,7 @@ const INFINITY = 1 / 0
* @param {Array} values The values to add to the set.
* @returns {Object} Returns the new set.
*/
const createSet = (Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY)
const createSet = (Set && (1 / setToArray(new Set([,-0]))[1]) === INFINITY)
? (values) => new Set(values)
: () => {}

View File

@@ -24,13 +24,13 @@ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
const arrLength = array.length
const othLength = other.length
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
if (arrLength !== othLength && !(isPartial && othLength > arrLength)) {
return false
}
// Assume cyclic values are equal.
const stacked = stack.get(array)
if (stacked && stack.get(other)) {
return stacked == other
return stacked === other
}
let index = -1
let result = true

View File

@@ -44,15 +44,15 @@ const symbolValueOf = Symbol.prototype.valueOf
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
switch (tag) {
case dataViewTag:
if ((object.byteLength != other.byteLength) ||
(object.byteOffset != other.byteOffset)) {
if ((object.byteLength !== other.byteLength) ||
(object.byteOffset !== other.byteOffset)) {
return false
}
object = object.buffer
other = other.buffer
case arrayBufferTag:
if ((object.byteLength != other.byteLength) ||
if ((object.byteLength !== other.byteLength) ||
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
return false
}
@@ -66,14 +66,14 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
return eq(+object, +other)
case errorTag:
return object.name == other.name && object.message == other.message
return object.name === other.name && object.message === other.message
case regexpTag:
case stringTag:
// Coerce regexes to strings and treat strings, primitives and objects,
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
// for more details.
return object == `${other}`
return object === `${other}`
case mapTag:
let convert = mapToArray
@@ -82,13 +82,13 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
const isPartial = bitmask & COMPARE_PARTIAL_FLAG
convert || (convert = setToArray)
if (object.size != other.size && !isPartial) {
if (object.size !== other.size && !isPartial) {
return false
}
// Assume cyclic values are equal.
const stacked = stack.get(object)
if (stacked) {
return stacked == other
return stacked === other
}
bitmask |= COMPARE_UNORDERED_FLAG
@@ -100,7 +100,7 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
case symbolTag:
if (symbolValueOf) {
return symbolValueOf.call(object) == symbolValueOf.call(other)
return symbolValueOf.call(object) === symbolValueOf.call(other)
}
}
return false

View File

@@ -26,7 +26,7 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
const othProps = getAllKeys(other)
const othLength = othProps.length
if (objLength != othLength && !isPartial) {
if (objLength !== othLength && !isPartial) {
return false
}
let key
@@ -40,7 +40,7 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
// Assume cyclic values are equal.
const stacked = stack.get(object)
if (stacked && stack.get(other)) {
return stacked == other
return stacked === other
}
let result = true
stack.set(object, other)
@@ -66,14 +66,14 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
result = false
break
}
skipCtor || (skipCtor = key == 'constructor')
skipCtor || (skipCtor = key === 'constructor')
}
if (result && !skipCtor) {
const objCtor = object.constructor
const othCtor = other.constructor
// Non `Object` object instances with different constructors are not equal.
if (objCtor != othCtor &&
if (objCtor !== othCtor &&
('constructor' in object && 'constructor' in other) &&
!(typeof objCtor === 'function' && objCtor instanceof objCtor &&
typeof othCtor === 'function' && othCtor instanceof othCtor)) {

View File

@@ -19,7 +19,7 @@ function isIndex(value, length) {
return !!length &&
(type === 'number' ||
(type !== 'symbol' && reIsUint.test(value))) &&
(value > -1 && value % 1 == 0 && value < length)
(value > -1 && value % 1 === 0 && value < length)
}
export default isIndex

View File

@@ -2,7 +2,7 @@
import freeGlobal from './freeGlobal.js'
/** Detect free variable `globalThis` */
const freeGlobalThis = typeof globalThis === 'object' && globalThis !== null && globalThis.Object == Object && globalThis
const freeGlobalThis = typeof globalThis === 'object' && globalThis !== null && globalThis.Object === Object && globalThis
/** Detect free variable `self`. */
const freeSelf = typeof self === 'object' && self !== null && self.Object === Object && self

View File

@@ -15,7 +15,7 @@ function toKey(value) {
return value
}
const result = `${value}`
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result
return (result === '0' && (1 / value) === -INFINITY) ? '-0' : result
}
export default toKey

View File

@@ -23,14 +23,14 @@
function endsWith(string, target, position) {
const { length } = string;
position = position === undefined ? length : +position;
if (position < 0 || position != position) {
if (position < 0 || position !== position) {
position = 0;
} else if (position > length) {
position = length;
}
const end = position;
position -= target.length;
return position >= 0 && string.slice(position, end) == target;
return position >= 0 && string.slice(position, end) === target;
}
export default endsWith;

View File

@@ -14,7 +14,7 @@ import isArrayLike from './isArrayLike.js';
* @see find, findIndex, findKey, findLastIndex, findLastKey
* @example
*
* findLast([1, 2, 3, 4], n => n % 2 == 1)
* findLast([1, 2, 3, 4], n => n % 2 === 1)
* // => 3
*/
function findLast(collection, predicate, fromIndex) {

View File

@@ -20,7 +20,7 @@ import toInteger from './toInteger.js';
* { 'user': 'pebbles', 'active': false }
* ]
*
* findLastIndex(users, ({ user }) => user == 'pebbles')
* findLastIndex(users, ({ user }) => user === 'pebbles')
* // => 2
*/
function findLastIndex(array, predicate, fromIndex) {

View File

@@ -42,7 +42,7 @@ function hasPath(object, path) {
}
object = object[key];
}
if (result || ++index != length) {
if (result || ++index !== length) {
return result;
}
length = object == null ? 0 : object.length;

View File

@@ -39,7 +39,7 @@ function hasPathIn(object, path) {
}
object = object[key];
}
if (result || ++index != length) {
if (result || ++index !== length) {
return result;
}
length = object == null ? 0 : object.length;

View File

@@ -17,7 +17,7 @@ import isObjectLike from './isObjectLike.js';
* // => false
*/
function isArguments(value) {
return isObjectLike(value) && getTag(value) == '[object Arguments]';
return isObjectLike(value) && getTag(value) === '[object Arguments]';
}
export default isArguments;

View File

@@ -22,6 +22,6 @@ const nodeIsArrayBuffer = nodeTypes && nodeTypes.isArrayBuffer;
*/
const isArrayBuffer = nodeIsArrayBuffer
? (value) => nodeIsArrayBuffer(value)
: (value) => isObjectLike(value) && getTag(value) == '[object ArrayBuffer]';
: (value) => isObjectLike(value) && getTag(value) === '[object ArrayBuffer]';
export default isArrayBuffer;

View File

@@ -20,7 +20,7 @@ function isBoolean(value) {
return (
value === true ||
value === false ||
(isObjectLike(value) && getTag(value) == '[object Boolean]')
(isObjectLike(value) && getTag(value) === '[object Boolean]')
);
}

View File

@@ -22,6 +22,6 @@ const nodeIsDate = nodeTypes && nodeTypes.isDate;
*/
const isDate = nodeIsDate
? (value) => nodeIsDate(value)
: (value) => isObjectLike(value) && getTag(value) == '[object Date]';
: (value) => isObjectLike(value) && getTag(value) === '[object Date]';
export default isDate;

View File

@@ -58,7 +58,7 @@ function isEmpty(value) {
return !value.length;
}
const tag = getTag(value);
if (tag == '[object Map]' || tag == '[object Set]') {
if (tag === '[object Map]' || tag === '[object Set]') {
return !value.size;
}
if (isPrototype(value)) {

View File

@@ -24,8 +24,8 @@ function isError(value) {
}
const tag = getTag(value);
return (
tag == '[object Error]' ||
tag == '[object DOMException]' ||
tag === '[object Error]' ||
tag === '[object DOMException]' ||
(typeof value.message === 'string' &&
typeof value.name === 'string' &&
!isPlainObject(value))

View File

@@ -26,7 +26,7 @@ const MAX_SAFE_INTEGER = 9007199254740991;
* // => false
*/
function isLength(value) {
return typeof value === 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
return typeof value === 'number' && value > -1 && value % 1 === 0 && value <= MAX_SAFE_INTEGER;
}
export default isLength;

View File

@@ -22,6 +22,6 @@ const nodeIsMap = nodeTypes && nodeTypes.isMap;
*/
const isMap = nodeIsMap
? (value) => nodeIsMap(value)
: (value) => isObjectLike(value) && getTag(value) == '[object Map]';
: (value) => isObjectLike(value) && getTag(value) === '[object Map]';
export default isMap;

View File

@@ -27,7 +27,9 @@ import isObjectLike from './isObjectLike.js';
* // => false
*/
function isNumber(value) {
return typeof value === 'number' || (isObjectLike(value) && getTag(value) == '[object Number]');
return (
typeof value === 'number' || (isObjectLike(value) && getTag(value) === '[object Number]')
);
}
export default isNumber;

View File

@@ -28,7 +28,7 @@ import isObjectLike from './isObjectLike.js';
* // => true
*/
function isPlainObject(value) {
if (!isObjectLike(value) || getTag(value) != '[object Object]') {
if (!isObjectLike(value) || getTag(value) !== '[object Object]') {
return false;
}
if (Object.getPrototypeOf(value) === null) {

View File

@@ -22,6 +22,6 @@ const nodeIsRegExp = nodeTypes && nodeTypes.isRegExp;
*/
const isRegExp = nodeIsRegExp
? (value) => nodeIsRegExp(value)
: (value) => isObjectLike(value) && getTag(value) == '[object RegExp]';
: (value) => isObjectLike(value) && getTag(value) === '[object RegExp]';
export default isRegExp;

View File

@@ -22,6 +22,6 @@ const nodeIsSet = nodeTypes && nodeTypes.isSet;
*/
const isSet = nodeIsSet
? (value) => nodeIsSet(value)
: (value) => isObjectLike(value) && getTag(value) == '[object Set]';
: (value) => isObjectLike(value) && getTag(value) === '[object Set]';
export default isSet;

View File

@@ -22,7 +22,7 @@ function isString(value) {
(type === 'object' &&
value != null &&
!Array.isArray(value) &&
getTag(value) == '[object String]')
getTag(value) === '[object String]')
);
}

View File

@@ -18,8 +18,8 @@ import getTag from './.internal/getTag.js';
function isSymbol(value) {
const type = typeof value;
return (
type == 'symbol' ||
(type === 'object' && value != null && getTag(value) == '[object Symbol]')
type === 'symbol' ||
(type === 'object' && value != null && getTag(value) === '[object Symbol]')
);
}

View File

@@ -17,7 +17,7 @@ import isObjectLike from './isObjectLike.js';
* // => false
*/
function isWeakMap(value) {
return isObjectLike(value) && getTag(value) == '[object WeakMap]';
return isObjectLike(value) && getTag(value) === '[object WeakMap]';
}
export default isWeakMap;

View File

@@ -17,7 +17,7 @@ import isObjectLike from './isObjectLike.js';
* // => false
*/
function isWeakSet(value) {
return isObjectLike(value) && getTag(value) == '[object WeakSet]';
return isObjectLike(value) && getTag(value) === '[object WeakSet]';
}
export default isWeakSet;

View File

@@ -10,7 +10,7 @@
* @example
*
* function isEven(n) {
* return n % 2 == 0
* return n % 2 === 0
* }
*
* filter([1, 2, 3, 4, 5, 6], negate(isEven))

View File

@@ -17,7 +17,7 @@ import basePullAt from './.internal/basePullAt.js';
* @example
*
* const array = [1, 2, 3, 4]
* const evens = remove(array, n => n % 2 == 0)
* const evens = remove(array, n => n % 2 === 0)
*
* console.log(array)
* // => [1, 3]

View File

@@ -34,7 +34,7 @@ function size(collection) {
return isString(collection) ? stringSize(collection) : collection.length;
}
const tag = getTag(collection);
if (tag == mapTag || tag == setTag) {
if (tag === mapTag || tag === setTag) {
return collection.size;
}
return Object.keys(collection).length;

View File

@@ -29,7 +29,7 @@ function startsWith(string, target, position) {
position = length;
}
target = `${target}`;
return string.slice(position, position + target.length) == target;
return string.slice(position, position + target.length) === target;
}
export default startsWith;

View File

@@ -47,7 +47,7 @@ function toArray(value) {
return iteratorToArray(value[symIterator]());
}
const tag = getTag(value);
const func = tag == mapTag ? mapToArray : tag == setTag ? setToArray : values;
const func = tag === mapTag ? mapToArray : tag === setTag ? setToArray : values;
return func(value);
}

View File

@@ -38,7 +38,7 @@ function toString(value) {
return value.toString();
}
const result = `${value}`;
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
return result === '0' && 1 / value === -INFINITY ? '-0' : result;
}
export default toString;

View File

@@ -24,7 +24,7 @@ import isTypedArray from './isTypedArray.js';
*
* transform([2, 3, 4], (result, n) => {
* result.push(n *= n)
* return n % 2 == 0
* return n % 2 === 0
* }, [])
* // => [4, 9]
*

View File

@@ -99,7 +99,7 @@ function truncate(string, options) {
}
result = result.slice(0, newEnd === undefined ? end : newEnd);
}
} else if (string.indexOf(baseToString(separator), end) != end) {
} else if (string.indexOf(baseToString(separator), end) !== end) {
const index = result.lastIndexOf(separator);
if (index > -1) {
result = result.slice(0, index);

View File

@@ -113,7 +113,7 @@ describe('at', () => {
assert.strictEqual(count, expected);
expected = index == 3 ? [] : [index == 2 ? undefined : square(lastIndex)];
expected = index === 3 ? [] : [index === 2 ? undefined : square(lastIndex)];
assert.deepEqual(actual, expected);
});
});

View File

@@ -52,7 +52,7 @@ describe('case methods', () => {
it(`\`_.${methodName}\` should convert \`string\` to ${caseName} case`, () => {
const actual = lodashStable.map(strings, (string) => {
const expected = caseName == 'start' && string == 'FOO BAR' ? string : converted;
const expected = caseName === 'start' && string === 'FOO BAR' ? string : converted;
return func(string) === expected;
});
@@ -61,7 +61,7 @@ describe('case methods', () => {
it(`\`_.${methodName}\` should handle double-converting strings`, () => {
const actual = lodashStable.map(strings, (string) => {
const expected = caseName == 'start' && string == 'FOO BAR' ? string : converted;
const expected = caseName === 'start' && string === 'FOO BAR' ? string : converted;
return func(func(string)) === expected;
});

View File

@@ -69,7 +69,7 @@ describe('chain', () => {
actual = wrapped
.chain()
.filter((n) => n % 2 != 0)
.reject((n) => n % 3 == 0)
.reject((n) => n % 3 === 0)
.sortBy((n) => -n)
.value();

View File

@@ -125,12 +125,12 @@ xdescribe('clone methods', function () {
actual = last(arguments);
});
assert.ok(isNpm ? actual.constructor.name == 'Stack' : actual instanceof mapCaches.Stack);
assert.ok(isNpm ? actual.constructor.name === 'Stack' : actual instanceof mapCaches.Stack);
});
lodashStable.each(['clone', 'cloneDeep'], (methodName) => {
const func = _[methodName],
isDeep = methodName == 'cloneDeep';
isDeep = methodName === 'cloneDeep';
lodashStable.forOwn(objects, (object, kind) => {
it(`\`_.${methodName}\` should clone ${kind}`, () => {
@@ -405,7 +405,7 @@ xdescribe('clone methods', function () {
lodashStable.each(['cloneWith', 'cloneDeepWith'], (methodName) => {
const func = _[methodName],
isDeep = methodName == 'cloneDeepWith';
isDeep = methodName === 'cloneDeepWith';
it(`\`_.${methodName}\` should provide correct \`customizer\` arguments`, () => {
const argsList = [],

View File

@@ -5,7 +5,7 @@ import conformsTo from '../src/conformsTo';
describe('conforms methods', () => {
lodashStable.each(['conforms', 'conformsTo'], (methodName) => {
const isConforms = methodName == 'conforms';
const isConforms = methodName === 'conforms';
function conforms(source) {
return isConforms

View File

@@ -9,7 +9,7 @@ describe('curry methods', () => {
fn = function (a, b) {
return slice.call(arguments);
},
isCurry = methodName == 'curry';
isCurry = methodName === 'curry';
it(`\`_.${methodName}\` should not error on functions with the same name as lodash methods`, () => {
function run(a, b) {

View File

@@ -6,7 +6,7 @@ import runInContext from '../src/runInContext';
describe('debounce and throttle', () => {
lodashStable.each(['debounce', 'throttle'], (methodName) => {
const func = _[methodName],
isDebounce = methodName == 'debounce';
isDebounce = methodName === 'debounce';
it(`\`_.${methodName}\` should not error for non-object \`options\` values`, () => {
func(noop, 32, 1);
@@ -82,7 +82,7 @@ describe('debounce and throttle', () => {
const lodash = runInContext({
Date: {
now: function () {
return ++dateCount == 4
return ++dateCount === 4
? +new Date(2012, 3, 23, 23, 27, 18)
: +new Date();
},

View File

@@ -57,9 +57,9 @@ describe('dropWhile', () => {
const array = lodashStable.range(1, LARGE_ARRAY_SIZE + 3);
const actual = _(array)
.dropWhile((n) => n == 1)
.dropWhile((n) => n === 1)
.drop()
.dropWhile((n) => n == 3)
.dropWhile((n) => n === 3)
.value();
assert.deepEqual(actual, array.slice(3));

View File

@@ -28,7 +28,7 @@ describe('extremum methods', () => {
lodashStable.each(['maxBy', 'minBy'], (methodName) => {
const array = [1, 2, 3],
func = _[methodName],
isMax = methodName == 'maxBy';
isMax = methodName === 'maxBy';
it(`\`_.${methodName}\` should work with an \`iteratee\``, () => {
const actual = func(array, (n) => -n);

View File

@@ -6,7 +6,7 @@ describe('filter methods', () => {
lodashStable.each(['filter', 'reject'], (methodName) => {
const array = [1, 2, 3, 4],
func = _[methodName],
isFilter = methodName == 'filter',
isFilter = methodName === 'filter',
objects = [{ a: 0 }, { a: 1 }];
it(`\`_.${methodName}\` should not modify the resulting value from within \`predicate\``, () => {

View File

@@ -4,7 +4,7 @@ import { LARGE_ARRAY_SIZE, square, isEven } from './utils';
describe('find and findLast', () => {
lodashStable.each(['find', 'findLast'], (methodName) => {
const isFind = methodName == 'find';
const isFind = methodName === 'find';
it(`\`_.${methodName}\` should support shortcut fusion`, () => {
let findCount = 0,

View File

@@ -5,8 +5,8 @@ import { _, identity, args, falsey } from './utils';
describe('find and includes', () => {
lodashStable.each(['includes', 'find'], (methodName) => {
const func = _[methodName],
isIncludes = methodName == 'includes',
resolve = methodName == 'find' ? lodashStable.curry(lodashStable.eq) : identity;
isIncludes = methodName === 'includes',
resolve = methodName === 'find' ? lodashStable.curry(lodashStable.eq) : identity;
lodashStable.each(
{

View File

@@ -14,7 +14,7 @@ describe('findLastIndex and lastIndexOf', () => {
const array = [1, 2, 3, 1, 2, 3],
func = methods[methodName],
resolve =
methodName == 'findLastIndex' ? lodashStable.curry(lodashStable.eq) : identity;
methodName === 'findLastIndex' ? lodashStable.curry(lodashStable.eq) : identity;
it(`\`_.${methodName}\` should return the index of the last matched value`, () => {
assert.strictEqual(func(array, resolve(3)), 5);

View File

@@ -49,9 +49,9 @@ describe('flatten methods', () => {
const expected = Array(5e5);
try {
let func = flatten;
if (index == 1) {
if (index === 1) {
func = flattenDeep;
} else if (index == 2) {
} else if (index === 2) {
func = flattenDepth;
}
assert.deepStrictEqual(func([expected]), expected);

View File

@@ -15,7 +15,7 @@ const methods = {
describe('flow methods', () => {
lodashStable.each(['flow', 'flowRight'], (methodName) => {
const func = methods[methodName],
isFlow = methodName == 'flow';
isFlow = methodName === 'flow';
it(`\`_.${methodName}\` should supply each function with the return value of the previous`, () => {
const fixed = function (n) {

View File

@@ -5,7 +5,7 @@ import { _, toArgs, stubTrue, args, symbol, defineProperty, stubFalse } from './
describe('has methods', () => {
lodashStable.each(['has', 'hasIn'], (methodName) => {
const func = _[methodName],
isHas = methodName == 'has',
isHas = methodName === 'has',
sparseArgs = toArgs([1]),
sparseArray = Array(1),
sparseString = Object('a');

View File

@@ -65,7 +65,7 @@ describe('includes', () => {
length = string.length,
indexes = [4, 6, 2 ** 32, Infinity];
const expected = lodashStable.map(indexes, (index) => [false, false, index == length]);
const expected = lodashStable.map(indexes, (index) => [false, false, index === length]);
const actual = lodashStable.map(indexes, (fromIndex) => [
includes(string, 1, fromIndex),

View File

@@ -40,7 +40,7 @@ describe('isFunction', () => {
it('should return `true` for array view constructors', () => {
const expected = lodashStable.map(
arrayViews,
(type) => objToString.call(root[type]) == funcTag,
(type) => objToString.call(root[type]) === funcTag,
);
const actual = lodashStable.map(arrayViews, (type) => isFunction(root[type]));

View File

@@ -5,7 +5,7 @@ import { _, stubTrue, MAX_INTEGER, stubFalse, falsey, args, symbol } from './uti
describe('isInteger methods', () => {
lodashStable.each(['isInteger', 'isSafeInteger'], (methodName) => {
const func = _[methodName],
isSafe = methodName == 'isSafeInteger';
isSafe = methodName === 'isSafeInteger';
it(`\`_.${methodName}\` should return \`true\` for integer values`, () => {
const values = [-1, 0, 1],

View File

@@ -78,7 +78,7 @@ describe('isMatchWith', () => {
actual = last(arguments);
});
assert.ok(isNpm ? actual.constructor.name == 'Stack' : actual instanceof mapCaches.Stack);
assert.ok(isNpm ? actual.constructor.name === 'Stack' : actual instanceof mapCaches.Stack);
});
it('should ensure `customizer` is a function', () => {

View File

@@ -11,7 +11,7 @@ describe('isNil', () => {
});
it('should return `false` for non-nullish values', () => {
const expected = lodashStable.map(falsey, (value) => value == null);
const expected = lodashStable.map(falsey, (value) => value === null);
const actual = lodashStable.map(falsey, (value, index) => (index ? isNil(value) : isNil()));

View File

@@ -19,7 +19,7 @@ describe('isType checks', () => {
Foo.prototype = root[methodName.slice(2)].prototype;
const object = new Foo();
if (objToString.call(object) == objectTag) {
if (objToString.call(object) === objectTag) {
assert.strictEqual(
_[methodName](object),
false,

View File

@@ -118,7 +118,7 @@ describe('iteration methods', () => {
isBy = /(^partition|By)$/.test(methodName),
isFind = /^find/.test(methodName),
isOmitPick = /^(?:omit|pick)By$/.test(methodName),
isSome = methodName == 'some';
isSome = methodName === 'some';
it(`\`_.${methodName}\` should provide correct iteratee arguments`, () => {
if (func) {
@@ -187,7 +187,7 @@ describe('iteration methods', () => {
lodashStable.each(lodashStable.difference(methods, objectMethods), (methodName) => {
const array = [1, 2, 3],
func = _[methodName],
isEvery = methodName == 'every';
isEvery = methodName === 'every';
array.a = 1;
@@ -206,7 +206,7 @@ describe('iteration methods', () => {
lodashStable.each(lodashStable.difference(methods, unwrappedMethods), (methodName) => {
const array = [1, 2, 3],
isBaseEach = methodName == '_baseEach';
isBaseEach = methodName === '_baseEach';
it(`\`_.${methodName}\` should return a wrapped value when implicitly chaining`, () => {
if (!(isBaseEach || isNpm)) {
@@ -303,7 +303,7 @@ describe('iteration methods', () => {
lodashStable.each(methods, (methodName) => {
const func = _[methodName],
isFind = /^find/.test(methodName),
isSome = methodName == 'some',
isSome = methodName === 'some',
isReduce = /^reduce/.test(methodName);
it(`\`_.${methodName}\` should ignore changes to \`length\``, () => {
@@ -314,7 +314,7 @@ describe('iteration methods', () => {
func(
array,
() => {
if (++count == 1) {
if (++count === 1) {
array.push(2);
}
return !(isFind || isSome);
@@ -332,7 +332,7 @@ describe('iteration methods', () => {
(methodName) => {
const func = _[methodName],
isFind = /^find/.test(methodName),
isSome = methodName == 'some',
isSome = methodName === 'some',
isReduce = /^reduce/.test(methodName);
it(`\`_.${methodName}\` should ignore added \`object\` properties`, () => {
@@ -343,7 +343,7 @@ describe('iteration methods', () => {
func(
object,
() => {
if (++count == 1) {
if (++count === 1) {
object.b = 2;
}
return !(isFind || isSome);

View File

@@ -16,7 +16,7 @@ import {
describe('keys methods', () => {
lodashStable.each(['keys', 'keysIn'], (methodName) => {
const func = _[methodName],
isKeys = methodName == 'keys';
isKeys = methodName === 'keys';
it(`\`_.${methodName}\` should return the string keyed property names of \`object\``, () => {
const actual = func({ a: 1, b: 1 }).sort();

View File

@@ -34,7 +34,7 @@ describe('lodash(...) methods that return new wrapped values', () => {
lodashStable.each(funcs, (methodName) => {
it(`\`_(...).${methodName}\` should return a new wrapped value`, () => {
const value = methodName == 'split' ? 'abc' : [1, 2, 3],
const value = methodName === 'split' ? 'abc' : [1, 2, 3],
wrapped = _(value),
actual = wrapped[methodName]();

View File

@@ -100,9 +100,9 @@ describe('lodash methods', () => {
index ? func(value) : func(),
);
if (methodName == 'noConflict') {
if (methodName === 'noConflict') {
root._ = oldDash;
} else if (methodName == 'pull' || methodName == 'pullAll') {
} else if (methodName === 'pull' || methodName === 'pullAll') {
expected = falsey;
}
if (lodashStable.includes(returnArrays, methodName) && methodName != 'sample') {
@@ -137,7 +137,7 @@ describe('lodash methods', () => {
}
assert.ok(lodashStable.isArray(actual), `_.${methodName} returns an array`);
const isPull = methodName == 'pull' || methodName == 'pullAll';
const isPull = methodName === 'pull' || methodName === 'pullAll';
assert.strictEqual(
actual === array,
isPull,
@@ -163,7 +163,7 @@ describe('lodash methods', () => {
!pass &&
e instanceof TypeError &&
(!lodashStable.includes(checkFuncs, methodName) ||
e.message == FUNC_ERROR_TEXT);
e.message === FUNC_ERROR_TEXT);
}
return pass;
});
@@ -182,7 +182,7 @@ describe('lodash methods', () => {
return this.a;
},
func = _[methodName],
isNegate = methodName == 'negate',
isNegate = methodName === 'negate',
object = { a: 1 },
expected = isNegate ? false : 1;

View File

@@ -5,7 +5,7 @@ import isMatch from '../src/isMatch';
describe('matches methods', () => {
lodashStable.each(['matches', 'isMatch'], (methodName) => {
const isMatches = methodName == 'matches';
const isMatches = methodName === 'matches';
function matches(source) {
return isMatches

View File

@@ -5,7 +5,7 @@ import { _, symbol } from './utils';
describe('math operator methods', () => {
lodashStable.each(['add', 'divide', 'multiply', 'subtract'], (methodName) => {
const func = _[methodName],
isAddSub = methodName == 'add' || methodName == 'subtract';
isAddSub = methodName === 'add' || methodName === 'subtract';
it(`\`_.${methodName}\` should return \`${
isAddSub ? 0 : 1

View File

@@ -36,7 +36,7 @@ describe('mergeWith', () => {
actual = last(arguments);
});
assert.ok(isNpm ? actual.constructor.name == 'Stack' : actual instanceof mapCaches.Stack);
assert.ok(isNpm ? actual.constructor.name === 'Stack' : actual instanceof mapCaches.Stack);
});
it('should overwrite primitives with source object clones', () => {

View File

@@ -42,7 +42,7 @@ describe('negate', () => {
case 4:
negate(1, 2, 3, 4);
}
return argCount == index;
return argCount === index;
});
assert.deepStrictEqual(actual, expected);

View File

@@ -42,10 +42,10 @@ describe('number coercion methods', () => {
['toFinite', 'toInteger', 'toLength', 'toNumber', 'toSafeInteger'],
(methodName) => {
const func = _[methodName],
isToFinite = methodName == 'toFinite',
isToLength = methodName == 'toLength',
isToNumber = methodName == 'toNumber',
isToSafeInteger = methodName == 'toSafeInteger';
isToFinite = methodName === 'toFinite',
isToLength = methodName === 'toLength',
isToNumber = methodName === 'toNumber',
isToSafeInteger = methodName === 'toSafeInteger';
function negative(string) {
return `-${string}`;
@@ -76,9 +76,9 @@ describe('number coercion methods', () => {
const expected = lodashStable.map(values, (value) => {
if (!isToNumber) {
if (!isToFinite && value == 1.2) {
if (!isToFinite && value === 1.2) {
value = 1;
} else if (value == Infinity) {
} else if (value === Infinity) {
value = MAX_INTEGER;
} else if (value !== value) {
value = 0;
@@ -124,11 +124,11 @@ describe('number coercion methods', () => {
const expected = lodashStable.map(values, (value) => {
let n = +value;
if (!isToNumber) {
if (!isToFinite && n == 1.23456789) {
if (!isToFinite && n === 1.23456789) {
n = 1;
} else if (n == Infinity) {
} else if (n === Infinity) {
n = MAX_INTEGER;
} else if ((!isToFinite && n == Number.MIN_VALUE) || n !== n) {
} else if ((!isToFinite && n === Number.MIN_VALUE) || n !== n) {
n = 0;
}
if (isToLength || isToSafeInteger) {

View File

@@ -6,7 +6,7 @@ import has from '../src/has';
describe('object assignments', () => {
lodashStable.each(['assign', 'assignIn', 'defaults', 'defaultsDeep', 'merge'], (methodName) => {
const func = _[methodName],
isAssign = methodName == 'assign',
isAssign = methodName === 'assign',
isDefaults = /^defaults/.test(methodName);
it(`\`_.${methodName}\` should coerce primitives to objects`, () => {
@@ -135,7 +135,7 @@ describe('object assignments', () => {
lodashStable.each(['assignWith', 'assignInWith', 'mergeWith'], (methodName) => {
const func = _[methodName],
isMergeWith = methodName == 'mergeWith';
isMergeWith = methodName === 'mergeWith';
it(`\`_.${methodName}\` should provide correct \`customizer\` arguments`, () => {
let args,

View File

@@ -9,7 +9,7 @@ describe('omit methods', () => {
object = { a: 1, b: 2, c: 3, d: 4 },
resolve = lodashStable.nthArg(1);
if (methodName == 'omitBy') {
if (methodName === 'omitBy') {
resolve = function (object, props) {
props = lodashStable.castArray(props);
return function (value) {

View File

@@ -6,8 +6,8 @@ import pad from '../src/pad';
describe('pad methods', () => {
lodashStable.each(['pad', 'padStart', 'padEnd'], (methodName) => {
const func = _[methodName],
isPad = methodName == 'pad',
isStart = methodName == 'padStart',
isPad = methodName === 'pad',
isStart = methodName === 'padStart',
string = 'abc';
it(`\`_.${methodName}\` should not pad if string is >= \`length\``, () => {

View File

@@ -7,7 +7,7 @@ import curry from '../src/curry';
describe('partial methods', () => {
lodashStable.each(['partial', 'partialRight'], (methodName) => {
const func = _[methodName],
isPartial = methodName == 'partial',
isPartial = methodName === 'partial',
ph = func.placeholder;
it(`\`_.${methodName}\` partially applies arguments`, () => {

View File

@@ -6,11 +6,11 @@ describe('pick methods', () => {
lodashStable.each(['pick', 'pickBy'], (methodName) => {
let expected = { a: 1, c: 3 },
func = _[methodName],
isPick = methodName == 'pick',
isPick = methodName === 'pick',
object = { a: 1, b: 2, c: 3, d: 4 },
resolve = lodashStable.nthArg(1);
if (methodName == 'pickBy') {
if (methodName === 'pickBy') {
resolve = function (object, props) {
props = lodashStable.castArray(props);
return function (value) {

View File

@@ -6,7 +6,7 @@ describe('pickBy', () => {
it('should work with a predicate argument', () => {
const object = { a: 1, b: 2, c: 3, d: 4 };
const actual = pickBy(object, (n) => n == 1 || n == 3);
const actual = pickBy(object, (n) => n === 1 || n === 3);
assert.deepStrictEqual(actual, { a: 1, c: 3 });
});

View File

@@ -5,7 +5,7 @@ import { _ } from './utils';
describe('pull methods', () => {
lodashStable.each(['pull', 'pullAll', 'pullAllWith'], (methodName) => {
const func = _[methodName],
isPull = methodName == 'pull';
isPull = methodName === 'pull';
function pull(array, values) {
return isPull ? func.apply(undefined, [array].concat(values)) : func(array, values);

View File

@@ -93,7 +93,7 @@ describe('random', () => {
const actual = lodashStable.map(
randoms,
(result, index) => result >= 0 && result <= array[index] && result % 1 == 0,
(result, index) => result >= 0 && result <= array[index] && result % 1 === 0,
);
assert.deepStrictEqual(actual, expected);

View File

@@ -5,7 +5,7 @@ import { _, falsey } from './utils';
describe('range methods', () => {
lodashStable.each(['range', 'rangeRight'], (methodName) => {
const func = _[methodName],
isRange = methodName == 'range';
isRange = methodName === 'range';
function resolve(range) {
return isRange ? range : range.reverse();

View File

@@ -6,7 +6,7 @@ describe('reduce methods', () => {
lodashStable.each(['reduce', 'reduceRight'], (methodName) => {
const func = _[methodName],
array = [1, 2, 3],
isReduce = methodName == 'reduce';
isReduce = methodName === 'reduce';
it(`\`_.${methodName}\` should reduce a collection to a single value`, () => {
const actual = func(['a', 'b', 'c'], (accumulator, value) => accumulator + value, '');

View File

@@ -37,7 +37,7 @@ describe('reduce', () => {
object = { a: 1, b: 2 },
firstKey = head(keys(object));
let expected = firstKey == 'a' ? [0, 1, 'a', object] : [0, 2, 'b', object];
let expected = firstKey === 'a' ? [0, 1, 'a', object] : [0, 2, 'b', object];
reduce(
object,
@@ -50,7 +50,7 @@ describe('reduce', () => {
assert.deepStrictEqual(args, expected);
args = undefined;
expected = firstKey == 'a' ? [1, 2, 'b', object] : [2, 1, 'a', object];
expected = firstKey === 'a' ? [1, 2, 'b', object] : [2, 1, 'a', object];
reduce(object, function () {
args || (args = slice.call(arguments));

View File

@@ -34,7 +34,7 @@ describe('reduceRight', () => {
it('should provide correct `iteratee` arguments when iterating an object', () => {
let args,
object = { a: 1, b: 2 },
isFIFO = lodashStable.keys(object)[0] == 'a';
isFIFO = lodashStable.keys(object)[0] === 'a';
let expected = isFIFO ? [0, 2, 'b', object] : [0, 1, 'a', object];

View File

@@ -69,7 +69,7 @@ describe('remove', () => {
const array = [1, 2, 3];
delete array[1];
remove(array, (n) => n == null);
remove(array, (n) => n === null);
assert.deepStrictEqual(array, [1, 3]);
});

View File

@@ -6,8 +6,8 @@ import round from '../src/round';
describe('round methods', () => {
lodashStable.each(['ceil', 'floor', 'round'], (methodName) => {
const func = _[methodName],
isCeil = methodName == 'ceil',
isFloor = methodName == 'floor';
isCeil = methodName === 'ceil',
isFloor = methodName === 'floor';
it(`\`_.${methodName}\` should return a rounded number without a precision`, () => {
const actual = func(4.006);

View File

@@ -6,7 +6,7 @@ import sortBy from '../src/sortBy';
describe('sortedIndex methods', () => {
lodashStable.each(['sortedIndex', 'sortedLastIndex'], (methodName) => {
const func = _[methodName],
isSortedIndex = methodName == 'sortedIndex';
isSortedIndex = methodName === 'sortedIndex';
it(`\`_.${methodName}\` should return the insert index`, () => {
const array = [30, 50],

View File

@@ -5,7 +5,7 @@ import { _, slice, MAX_ARRAY_LENGTH, MAX_ARRAY_INDEX } from './utils';
describe('sortedIndexBy methods', () => {
lodashStable.each(['sortedIndexBy', 'sortedLastIndexBy'], (methodName) => {
const func = _[methodName],
isSortedIndexBy = methodName == 'sortedIndexBy';
isSortedIndexBy = methodName === 'sortedIndexBy';
it(`\`_.${methodName}\` should provide correct \`iteratee\` arguments`, () => {
let args;
@@ -52,7 +52,7 @@ describe('sortedIndexBy methods', () => {
? 0
: Math.min(length, MAX_ARRAY_INDEX);
assert.ok(steps == 32 || steps == 33);
assert.ok(steps === 32 || steps === 33);
assert.strictEqual(actual, expected);
});
});

View File

@@ -5,7 +5,7 @@ import { _ } from './utils';
describe('sortedIndexOf methods', () => {
lodashStable.each(['sortedIndexOf', 'sortedLastIndexOf'], (methodName) => {
const func = _[methodName],
isSortedIndexOf = methodName == 'sortedIndexOf';
isSortedIndexOf = methodName === 'sortedIndexOf';
it(`\`_.${methodName}\` should perform a binary search`, () => {
const sorted = [4, 4, 5, 5, 6, 6];

View File

@@ -5,7 +5,7 @@ import { _, MAX_SAFE_INTEGER } from './utils';
describe('startsWith and endsWith', () => {
lodashStable.each(['startsWith', 'endsWith'], (methodName) => {
const func = _[methodName],
isStartsWith = methodName == 'startsWith';
isStartsWith = methodName === 'startsWith';
const string = 'abc',
chr = isStartsWith ? 'a' : 'c';

View File

@@ -7,7 +7,7 @@ describe('strict mode checks', () => {
['assign', 'assignIn', 'bindAll', 'defaults', 'defaultsDeep', 'merge'],
(methodName) => {
const func = _[methodName],
isBindAll = methodName == 'bindAll';
isBindAll = methodName === 'bindAll';
it(`\`_.${methodName}\` should ${
isStrict ? '' : 'not '

View File

@@ -58,7 +58,7 @@ describe('takeWhile', () => {
const actual = _(array)
.takeWhile((n) => n < 4)
.take(2)
.takeWhile((n) => n == 0)
.takeWhile((n) => n === 0)
.value();
assert.deepEqual(actual, [0]);

View File

@@ -297,7 +297,7 @@ describe('template', () => {
it('should work with statements containing quotes', () => {
const compiled = template(
'<%\
if (a == \'A\' || a == "a") {\
if (a === \'A\' || a === "a") {\
%>\'a\',"A"<%\
} %>',
);

View File

@@ -49,7 +49,7 @@ describe('throttle', () => {
const lodash = runInContext({
Date: {
now: function () {
return ++dateCount == 5 ? Infinity : +new Date();
return ++dateCount === 5 ? Infinity : +new Date();
},
},
});

View File

@@ -5,7 +5,7 @@ import { _, MAX_SAFE_INTEGER, MAX_INTEGER } from './utils';
describe('toInteger methods', () => {
lodashStable.each(['toInteger', 'toSafeInteger'], (methodName) => {
const func = _[methodName],
isSafe = methodName == 'toSafeInteger';
isSafe = methodName === 'toSafeInteger';
it(`\`_.${methodName}\` should convert values to integers`, () => {
assert.strictEqual(func(-5.6), -5);

Some files were not shown because too many files have changed in this diff Show More