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);