Skip to content

Commit

Permalink
Merge branch 'main' into feat/flip
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon authored Sep 23, 2024
2 parents 0be1c90 + a08c9fe commit 2ad0cb1
Show file tree
Hide file tree
Showing 81 changed files with 656 additions and 208 deletions.
2 changes: 1 addition & 1 deletion benchmarks/performance/ary.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, describe } from 'vitest';
import { ary as aryToolkit } from 'es-toolkit';
import { ary as aryToolkit } from 'es-toolkit/compat';
import { ary as aryLodash } from 'lodash';

describe('ary', () => {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/performance/attempt.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, describe } from 'vitest';
import { attempt as attemptToolkit } from 'es-toolkit';
import { attempt as attemptToolkit } from 'es-toolkit/compat';
import { attempt as attemptLodash } from 'lodash';

describe('attempt', () => {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/performance/bindKey.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, describe } from 'vitest';
import { bindKey as bindKeyToolkit } from 'es-toolkit';
import { bindKey as bindKeyToolkit } from 'es-toolkit/compat';
import { bindKey as bindKeyLodash } from 'lodash';

const object = {
Expand Down
6 changes: 6 additions & 0 deletions benchmarks/performance/clamp.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bench, describe } from 'vitest';
import { clamp as clampToolkit } from 'es-toolkit';
import { clamp as clampCompatToolkit } from 'es-toolkit/compat';
import { clamp as clampLodash } from 'lodash';

describe('clamp', () => {
Expand All @@ -8,6 +9,11 @@ describe('clamp', () => {
clampToolkit(10, 5);
});

bench('es-toolkit/compat/clamp', () => {
clampCompatToolkit(10, 5, 15);
clampCompatToolkit(10, 5);
});

bench('lodash/clamp', () => {
clampLodash(10, 5, 15);
clampLodash(10, 5);
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/performance/cloneDeep.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bench, describe } from 'vitest';
import { cloneDeep } from 'es-toolkit';
import { cloneDeep as cloneDeepCompatToolkit } from 'es-toolkit/compat';
import { cloneDeep as lodashCloneDeep } from 'lodash';

const obj = {
Expand All @@ -19,6 +20,10 @@ describe('cloneDeep', () => {
cloneDeep(obj);
});

bench('es-toolkit/compat/cloneDeep', () => {
cloneDeepCompatToolkit(obj);
});

bench('lodash/cloneDeep', () => {
lodashCloneDeep(obj);
});
Expand Down
9 changes: 1 addition & 8 deletions benchmarks/performance/conforms.bench.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { bench, describe } from 'vitest';
import { conforms as conformsToolkit } from 'es-toolkit';
import { conforms as conformsCompat } from 'es-toolkit/compat';
import { conforms as conformsToolkit } from 'es-toolkit/compat';
import { conforms as conformsLodash } from 'lodash';

describe('conforms', () => {
Expand All @@ -10,12 +9,6 @@ describe('conforms', () => {
});
});

bench('es-toolkit/compat/conforms', () => {
conformsCompat({
b: (n: number) => n > 1,
});
});

bench('lodash/conforms', () => {
conformsLodash({
b: (n: number) => n > 1,
Expand Down
14 changes: 2 additions & 12 deletions benchmarks/performance/conformsTo.bench.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import { bench, describe } from 'vitest';
import { conformsTo as conformsToToolkit } from 'es-toolkit';
import { conformsTo as conformsCompat } from 'es-toolkit/compat';
import { conformsTo as conformsToolkit } from 'es-toolkit/compat';
import { conformsTo as conformsToLodash } from 'lodash';

describe('conformsTo', () => {
bench('es-toolkit/conformsTo', () => {
conformsToToolkit(
{ a: 1, b: 2 },
{
b: (n: number) => n > 1,
}
);
});

bench('es-toolkit/compat/conformsTo', () => {
conformsCompat(
conformsToolkit(
{ a: 1, b: 2 },
{
b: (n: number) => n > 1,
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/performance/debounce.bench.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { bench, describe } from 'vitest';
import { debounce as debounceToolkit } from 'es-toolkit';
import { debounce as debounceCompatToolkit } from 'es-toolkit/compat';
import { debounce as debounceLodash } from 'lodash';

describe('debounce', () => {
bench('es-toolkit/debounce', () => {
debounceToolkit(() => undefined, 1000)();
});

bench('es-toolkit/compat/debounce', () => {
debounceCompatToolkit(() => undefined, 1000)();
});

bench('lodash/debounce', () => {
debounceLodash(() => undefined, 1000)();
});
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/performance/difference.bench.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { bench, describe } from 'vitest';
import { difference as differenceToolkit } from 'es-toolkit';
import { difference as differenceCompatToolkit } from 'es-toolkit/compat';
import { difference as differenceLodash } from 'lodash';

describe('difference', () => {
bench('es-toolkit/difference', () => {
differenceToolkit([1, 2, 3], [2]);
});

bench('es-toolkit/compat/difference', () => {
differenceCompatToolkit([1, 2, 3], [2]);
});

bench('lodash/difference', () => {
differenceLodash([1, 2, 3], [2]);
});
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/performance/drop.bench.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { bench, describe } from 'vitest';
import { drop as dropToolkit } from 'es-toolkit';
import { drop as dropCompatToolkit } from 'es-toolkit/compat';
import { drop as dropLodash } from 'lodash';

describe('drop', () => {
bench('es-toolkit/drop', () => {
dropToolkit([1, 2, 3, 4, 5, 6], 3);
});

bench('es-toolkit/compat/drop', () => {
dropCompatToolkit([1, 2, 3, 4, 5, 6], 3);
});

bench('lodash/drop', () => {
dropLodash([1, 2, 3, 4, 5, 6], 3);
});
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/performance/endsWith.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, describe } from 'vitest';
import { endsWith as endsWithToolkit } from 'es-toolkit';
import { endsWith as endsWithToolkit } from 'es-toolkit/compat';
import { endsWith as endsWithLodash } from 'lodash';

describe('endsWith', () => {
Expand Down
9 changes: 9 additions & 0 deletions benchmarks/performance/fill.bench.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { bench, describe } from 'vitest';
import { fill as fillToolkit } from 'es-toolkit';
import { fill as fillCompatToolkit } from 'es-toolkit/compat';
import { fill as fillLodash } from 'lodash';

describe('fill function performance comparison', () => {
bench('es-toolkit/fill', () => {
fillToolkit([1, 2, 3], 10);
});

bench('es-toolkit/compat/fill', () => {
fillCompatToolkit([1, 2, 3], 10);
});

bench('lodash/fill', () => {
fillLodash([1, 2, 3], 10);
});
Expand All @@ -17,6 +22,10 @@ describe('fill function performance with custom start and end', () => {
fillToolkit([4, 6, 8, 10], '*', 1, 3);
});

bench('es-toolkit/compat/fill', () => {
fillCompatToolkit([4, 6, 8, 10], '*', 1, 3);
});

bench('lodash/fill', () => {
fillLodash([4, 6, 8, 10], '*', 1, 3);
});
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/performance/head.bench.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { bench, describe } from 'vitest';
import { head as headToolkit } from 'es-toolkit';
import { head as headCompatToolkit } from 'es-toolkit/compat';
import { head as headLodash } from 'lodash';

describe('head', () => {
bench('es-toolkit/head', () => {
headToolkit([1, 2, 3, 4]);
});

bench('es-toolkit/compat/head', () => {
headCompatToolkit([1, 2, 3, 4]);
});

bench('lodash/head', () => {
headLodash([1, 2, 3, 4]);
});
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/performance/inRange.bench.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { bench, describe } from 'vitest';
import { inRange as inRangeToolkit } from 'es-toolkit';
import { inRange as inRangeCompatToolkit } from 'es-toolkit/compat';
import { inRange as inRangeLodash } from 'lodash';

describe('inRange', () => {
bench('es-toolkit/inRange', () => {
inRangeToolkit(3, 5);
});

bench('es-toolkit/compat/inRange', () => {
inRangeCompatToolkit(3, 5);
});

bench('lodash/inRange', () => {
inRangeLodash(3, 5);
});
Expand Down
15 changes: 15 additions & 0 deletions benchmarks/performance/isBoolean.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bench, describe } from 'vitest';
import { isBoolean as isBooleanToolkit } from 'es-toolkit';
import { isBoolean as isBooleanToolkitCompat } from 'es-toolkit/compat';
import { isBoolean as isBooleanLodash } from 'lodash';

describe('isBoolean', () => {
Expand All @@ -9,6 +10,18 @@ describe('isBoolean', () => {
isBooleanToolkit(undefined);
isBooleanToolkit('');
isBooleanToolkit(123);
isBooleanToolkit({});
isBooleanToolkit(Boolean());
});

bench('es-toolkit/compat/isBoolean', () => {
isBooleanToolkitCompat(true);
isBooleanToolkitCompat(false);
isBooleanToolkitCompat(undefined);
isBooleanToolkitCompat('');
isBooleanToolkitCompat(123);
isBooleanToolkitCompat({});
isBooleanToolkitCompat(Boolean());
});

bench('lodash/isBoolean', () => {
Expand All @@ -17,5 +30,7 @@ describe('isBoolean', () => {
isBooleanLodash(undefined);
isBooleanLodash('');
isBooleanLodash(123);
isBooleanLodash({});
isBooleanLodash(Boolean());
});
});
19 changes: 19 additions & 0 deletions benchmarks/performance/isError.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { bench, describe } from 'vitest';
import { isError as isErrorToolkit } from 'es-toolkit';
import { isError as isErrorLodash } from 'lodash';

describe('isError', () => {
bench('es-toolkit/isError', () => {
isErrorToolkit(new Error());
isErrorToolkit(1);
isErrorToolkit('Error');
isErrorToolkit({ name: 'Error', message: '' });
});

bench('lodash/isError', () => {
isErrorLodash(new Error());
isErrorLodash(1);
isErrorLodash('Error');
isErrorLodash({ name: 'Error', message: '' });
});
});
2 changes: 1 addition & 1 deletion benchmarks/performance/isNaN.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, describe } from 'vitest';
import { isNaN as isNaNToolkit } from 'es-toolkit';
import { isNaN as isNaNToolkit } from 'es-toolkit/compat';
import { isNaN as isNaNLodash } from 'lodash';

describe('isNaN', () => {
Expand Down
8 changes: 8 additions & 0 deletions benchmarks/performance/isNil.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bench, describe } from 'vitest';
import { isNil as isNilToolkit } from 'es-toolkit';
import { isNil as isNilCompatToolkit } from 'es-toolkit/compat';
import { isNil as isNilLodash } from 'lodash';

describe('isNil', () => {
Expand All @@ -10,6 +11,13 @@ describe('isNil', () => {
isNilToolkit([1, 2, 3]);
});

bench('es-toolkit/compat/isNil', () => {
isNilCompatToolkit(null);
isNilCompatToolkit(undefined);
isNilCompatToolkit(123);
isNilCompatToolkit([1, 2, 3]);
});

bench('lodash/isNil', () => {
isNilLodash(null);
isNilLodash(undefined);
Expand Down
9 changes: 8 additions & 1 deletion benchmarks/performance/isRegExp.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bench, describe } from 'vitest';
import { isRegExp as isRegExpToolkit } from 'es-toolkit';
import { isRegExp as isRegExpToolkit } from 'es-toolkit/predicate';
import { isRegExp as isRegExpToolkitCompat } from 'es-toolkit/compat';
import { isRegExp as isRegExpLodash } from 'lodash';

describe('isRegExp', () => {
Expand All @@ -9,6 +10,12 @@ describe('isRegExp', () => {
isRegExpToolkit('/abc/');
});

bench('es-toolkit/compat/isRegExp', () => {
isRegExpToolkitCompat(new RegExp(''));
isRegExpToolkitCompat(/abc/);
isRegExpToolkitCompat('/abc/');
});

bench('lodash/isRegExp', () => {
isRegExpLodash(new RegExp(''));
isRegExpLodash(/abc/);
Expand Down
16 changes: 15 additions & 1 deletion benchmarks/performance/isString.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bench, describe } from 'vitest';
import { isString as isStringToolkit } from 'es-toolkit';
import { isString as isStringToolkit } from 'es-toolkit/predicate';
import { isString as isStringToolkitCompat } from 'es-toolkit/compat';
import { isString as isStringLodash } from 'lodash';

describe('isString', () => {
Expand All @@ -8,12 +9,25 @@ describe('isString', () => {
isStringToolkit(true);
isStringToolkit(undefined);
isStringToolkit(123);
isStringToolkit(String(''));
isStringToolkit(Object(''));
});

bench('es-toolkit/compat/isString', () => {
isStringToolkitCompat('');
isStringToolkitCompat(true);
isStringToolkitCompat(undefined);
isStringToolkitCompat(123);
isStringToolkitCompat(String(''));
isStringToolkitCompat(Object(''));
});

bench('lodash/isString', () => {
isStringLodash('');
isStringLodash(true);
isStringLodash(undefined);
isStringLodash(123);
isStringLodash(String(''));
isStringLodash(Object(''));
});
});
2 changes: 1 addition & 1 deletion benchmarks/performance/isSymbol.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, describe } from 'vitest';
import { isSymbol as isSymbolToolkit } from 'es-toolkit';
import { isSymbol as isSymbolToolkit } from 'es-toolkit/predicate';
import { isSymbol as isSymbolToolkitCompat } from 'es-toolkit/compat';
import { isSymbol as isSymbolLodash } from 'lodash';

Expand Down
15 changes: 15 additions & 0 deletions benchmarks/performance/isTypedArray.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bench, describe } from 'vitest';
import { isTypedArray as isTypedArrayToolkit } from 'es-toolkit';
import { isTypedArray as isTypedArrayCompatToolkit } from 'es-toolkit/compat';
import { isTypedArray as isTypedArrayLodash } from 'lodash';

describe('isTypedArrayToolkit', () => {
Expand All @@ -17,6 +18,20 @@ describe('isTypedArrayToolkit', () => {
isTypedArrayToolkit(new Float64Array(new ArrayBuffer(8)));
});

bench('es-toolkit/compat/isTypedArray', () => {
isTypedArrayCompatToolkit(new Uint8Array(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new Uint8ClampedArray(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new Uint16Array(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new Uint32Array(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new BigUint64Array(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new Int8Array(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new Int16Array(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new Int32Array(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new BigInt64Array(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new Float32Array(new ArrayBuffer(8)));
isTypedArrayCompatToolkit(new Float64Array(new ArrayBuffer(8)));
});

bench('lodash/isTypedArray', () => {
isTypedArrayLodash(new Uint8Array(new ArrayBuffer(8)));
isTypedArrayLodash(new Uint8ClampedArray(new ArrayBuffer(8)));
Expand Down
Loading

0 comments on commit 2ad0cb1

Please sign in to comment.