wip: code formatting nits continued

This commit is contained in:
jdalton
2023-09-16 22:59:56 -07:00
parent 0b28b7f7b6
commit b5c59317ea
421 changed files with 7354 additions and 9005 deletions

View File

@@ -1,28 +1,28 @@
import assert from 'node:assert';
import lodashStable from 'lodash';
import { LARGE_ARRAY_SIZE, square, isEven } from './utils';
import { _, LARGE_ARRAY_SIZE, square, isEven } from './utils';
describe('find and findLast', () => {
lodashStable.each(['find', 'findLast'], (methodName) => {
const isFind = methodName === 'find';
it(`\`_.${methodName}\` should support shortcut fusion`, () => {
let findCount = 0,
mapCount = 0,
array = lodashStable.range(1, LARGE_ARRAY_SIZE + 1),
iteratee = function (value) {
mapCount++;
return square(value);
},
predicate = function (value) {
findCount++;
return isEven(value);
},
actual = _(array).map(iteratee)[methodName](predicate);
let findCount = 0;
let mapCount = 0;
const array = lodashStable.range(1, LARGE_ARRAY_SIZE + 1);
assert.strictEqual(findCount, isFind ? 2 : 1);
assert.strictEqual(mapCount, isFind ? 2 : 1);
assert.strictEqual(actual, isFind ? 4 : square(LARGE_ARRAY_SIZE));
const iteratee = function (value) {
mapCount++;
return square(value);
};
const predicate = function (value) {
findCount++;
return isEven(value);
};
const actual = _(array).map(iteratee)[methodName](predicate);
expect(findCount).toBe(isFind ? 2 : 1);
expect(mapCount).toBe(isFind ? 2 : 1);
expect(actual).toBe(isFind ? 4 : square(LARGE_ARRAY_SIZE));
});
});
});