Skip to content

Commit

Permalink
wip: code formatting nits continued
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Sep 17, 2023
1 parent b5c5931 commit 5308be3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,19 @@ function debounce(func, wait, options) {
return result;
}

function startTimer(pendingFunc, wait) {
function startTimer(pendingFunc, milliseconds) {
if (useRAF) {
root.cancelAnimationFrame(timerId);
return root.requestAnimationFrame(pendingFunc);
}
return setTimeout(pendingFunc, wait);
// eslint-disable-next-line @typescript-eslint/no-implied-eval
return setTimeout(pendingFunc, milliseconds);
}

function cancelTimer(id) {
if (useRAF) {
return root.cancelAnimationFrame(id);
root.cancelAnimationFrame(id);
return;
}
clearTimeout(id);
}
Expand Down Expand Up @@ -152,6 +154,7 @@ function debounce(func, wait, options) {
}
// Restart the timer.
timerId = startTimer(timerExpired, remainingWait(time));
return undefined;
}

function trailingEdge(time) {
Expand Down
4 changes: 2 additions & 2 deletions test/conforms-methods.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('conforms methods', () => {
});

let actual = lodashStable.filter(objects, par);
expect(actual, [objects[0]).toEqual(objects[2]]);
expect(actual).toEqual([objects[0], objects[2]]);

par = conforms({
b: function (value) {
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('conforms methods', () => {
const par = conforms(new Foo());
const actual = lodashStable.filter(objects, par);

expect(actual, [objects[1]).toEqual(objects[2]]);
expect(actual).toEqual([objects[1], objects[2]]);
});

it(`\`_.${methodName}\` should not invoke \`source\` predicates for missing \`object\` properties`, () => {
Expand Down
6 changes: 3 additions & 3 deletions test/flatMapDepth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('flatMapDepth', () => {
const array = [1, [2, [3, [4]], 5]];

it('should use a default `depth` of `1`', () => {
expect(flatMapDepth(array, identity), [1, 2, [3, [4]]).toEqual(5]);
expect(flatMapDepth(array, identity)).toEqual([1, 2, [3, [4]], 5]);
});

it('should use `_.identity` when `iteratee` is nullish', () => {
Expand All @@ -22,11 +22,11 @@ describe('flatMapDepth', () => {

it('should treat a `depth` of < `1` as a shallow clone', () => {
lodashStable.each([-1, 0], (depth) => {
expect(flatMapDepth(array, identity, depth), [1, [2, [3, [4]]).toEqual(5]]);
expect(flatMapDepth(array, identity, depth)).toEqual([1, [2, [3, [4]], 5]]);
});
});

it('should coerce `depth` to an integer', () => {
expect(flatMapDepth(array, identity, 2.2), [1, 2, 3, [4]).toEqual(5]);
expect(flatMapDepth(array, identity, 2.2)).toEqual([1, 2, 3, [4], 5]);
});
});
6 changes: 3 additions & 3 deletions test/omit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe('omit', () => {
const nested = { a: 1, b: { c: 2, d: 3 } };

it('should flatten `paths`', () => {
expect(omit(object, 'a', 'c'), { b: 2).toEqual(d: 4 });
expect(omit(object, 'a', 'c')).toEqual({ b: 2, d: 4 });
expect(omit(object, ['a', 'd'], 'c')).toEqual({ b: 2 });
});

it('should support deep paths', () => {
expect(omit(nested, 'b.c'), { a: 1).toEqual(b: { d: 3 } });
expect(omit(nested, 'b.c')).toEqual({ a: 1, b: { d: 3 } });
});

it('should support path arrays', () => {
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('omit', () => {
});

it('should work with `arguments` object `paths`', () => {
expect(omit(object, args), { b: 2).toEqual(d: 4 });
expect(omit(object, args)).toEqual({ b: 2, d: 4 });
});

it('should not mutate `object`', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/overEvery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('overEvery', () => {
});

over('a', 'b', 'c');
expect(args, ['a', 'b').toEqual('c']);
expect(args).toEqual(['a', 'b', 'c']);
});

it('should use `this` binding of function for `predicates`', () => {
Expand Down

0 comments on commit 5308be3

Please sign in to comment.