Skip to content

Commit

Permalink
Merge branch 'main' into feat/range
Browse files Browse the repository at this point in the history
  • Loading branch information
raon0211 authored Jun 27, 2024
2 parents 1c3c4aa + cc6b4ac commit 4a6ab65
Show file tree
Hide file tree
Showing 137 changed files with 1,475 additions and 196 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @raon0211
2 changes: 1 addition & 1 deletion .github/workflows/broken-link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
cache-dependency-path: 'yarn.lock'
node-version-file: '.nvmrc'
- run: yarn install
- run: yarn blc ${{ github.event.inputs.url }} --ro
- run: yarn blc ${{ github.event.inputs.url || 'https://es-toolkit.slash.page' }} --ro
25 changes: 25 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: codspeed-benchmarks

on:
push:
branches:
- 'main'
pull_request:

jobs:
benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'yarn'
name: Install dependencies
- run: yarn install
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
run: yarn vitest bench
token: ${{ secrets.CODSPEED_TOKEN }}
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# es-toolkit Changelog

## Version v1.4.0

Released on June 15th, 2024.

### Features

- Add support for [random](https://es-toolkit.slash.page/reference/math/random.html). (https://github.com/toss/es-toolkit/pull/53)
- Add support for [randomInt](https://es-toolkit.slash.page/reference/math/randomInt.html). ([99a34e4](https://github.com/toss/es-toolkit/commit/99a34e4e9944c1b843e9d97dff0b5ff4e5eec260))
- Add support for using AbortSignals to cancel the `Promise` returned by `delay`. (https://github.com/toss/es-toolkit/pull/52)

### Performance Optimizations

- Optimized `uniqBy`. ([60e7974](https://github.com/toss/es-toolkit/commit/60e79741271e645bfa551f708466e43b136f69b1))

## Version v1.3.1

Released on June 15th, 2024.

- Fixed a bug in `dropWhile` where it incorrectly returned the entire array when no elements matched the predicate. (https://github.com/toss/es-toolkit/pull/49)

## Version v1.3.0

Released on June 14th, 2024.

### Features

- Add support for using AbortSignals to cancel `debounce`d functions. (https://github.com/toss/es-toolkit/pull/45)

### Performance Optimizations

- Optimize the time complexity of `intersection`. (https://github.com/toss/es-toolkit/pull/47)

## Version v1.2.2

Released on June 13th, 2024.

- Add support for `readonly` arrays in array utilities. (https://github.com/toss/es-toolkit/pull/32, [e595e5e](https://github.com/toss/es-toolkit/commit/e595e5e017e1f2cb138b1ad3d708635efc5e289e))
- Optimize the time complexity of `uniq`. (https://github.com/toss/es-toolkit/pull/40)
- Optimize the time complexity of `intersectionBy`. (https://github.com/toss/es-toolkit/pull/44)

## Version v1.2.1

Released on June 13th, 2024.
Expand Down
2 changes: 1 addition & 1 deletion README-ko_kr.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![](./docs/public/og.png)

# es-toolkit · [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toss/slash/blob/main/LICENSE)
# es-toolkit · [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toss/slash/blob/main/LICENSE) [![codecov](https://codecov.io/gh/toss/es-toolkit/graph/badge.svg?token=8N5S3AR3C7)](https://codecov.io/gh/toss/es-toolkit)

[English](https://github.com/toss/es-toolkit/blob/main/README.md) | 한국어

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![](./docs/public/og.png)

# es-toolkit · [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toss/slash/blob/main/LICENSE)
# es-toolkit · [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toss/slash/blob/main/LICENSE) [![codecov](https://codecov.io/gh/toss/es-toolkit/graph/badge.svg?token=8N5S3AR3C7)](https://codecov.io/gh/toss/es-toolkit)

English | [한국어](https://github.com/toss/es-toolkit/blob/main/README-ko_kr.md)

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/chunk.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { chunk as chunkToolkit } from 'es-toolkit';
import { chunk as chunkLodash } from 'lodash';

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

bench('lodash', () => {
bench('lodash/chunk', () => {
chunkLodash([1, 2, 3, 4, 5, 6], 3);
});
});
4 changes: 2 additions & 2 deletions benchmarks/clamp.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { clamp as clampToolkit } from 'es-toolkit';
import { clamp as clampLodash } from 'lodash';

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

bench('lodash', () => {
bench('lodash/clamp', () => {
clampLodash(10, 5, 15);
clampLodash(10, 5);
});
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/difference.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { difference as differenceToolkit } from 'es-toolkit';
import { difference as differenceLodash } from 'lodash';

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

bench('lodash', () => {
bench('lodash/difference', () => {
differenceLodash([1, 2, 3], [2]);
});
});
4 changes: 2 additions & 2 deletions benchmarks/differenceBy.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { differenceBy as differenceByToolkit } from 'es-toolkit';
import { differenceBy as differenceByLodash } from 'lodash';

describe('differenceBy', () => {
bench('es-toolkit', () => {
bench('es-toolkit/differenceBy', () => {
differenceByToolkit([1.2, 2.3, 3.4], [1.2], Math.floor);
});

bench('lodash', () => {
bench('lodash/differenceBy', () => {
differenceByLodash([1.2, 2.3, 3.4], [1.2], Math.floor);
});
});
4 changes: 2 additions & 2 deletions benchmarks/differenceWith.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { differenceWith as differenceWithToolkit } from 'es-toolkit';
import { differenceWith as differenceWithLodash } from 'lodash';

describe('differenceWith', () => {
bench('es-toolkit', () => {
bench('es-toolkit/differenceWith', () => {
differenceWithToolkit([1.2, 2.3, 3.4], [1.2], (x, y) => Math.floor(x) === Math.floor(y));
});

bench('lodash', () => {
bench('lodash/differenceWith', () => {
differenceWithLodash([1.2, 2.3, 3.4], [1.2], (x, y) => Math.floor(x) === Math.floor(y));
});
});
4 changes: 2 additions & 2 deletions benchmarks/drop.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { drop as dropToolkit } from 'es-toolkit';
import { drop as dropLodash } from 'lodash';

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

bench('lodash', () => {
bench('lodash/drop', () => {
dropLodash([1, 2, 3, 4, 5, 6], 3);
});
});
4 changes: 2 additions & 2 deletions benchmarks/dropRight.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { dropRight as dropRightToolkit } from 'es-toolkit';
import { dropRight as dropRightLodash } from 'lodash';

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

bench('lodash', () => {
bench('lodash/dropRight', () => {
dropRightLodash([1, 2, 3, 4, 5, 6], 3);
});
});
4 changes: 2 additions & 2 deletions benchmarks/dropRightWhile.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { dropRightWhile as dropRightWhileToolkit } from 'es-toolkit';
import { dropRightWhile as dropRightWhileLodash } from 'lodash';

describe('dropRightWhile', () => {
bench('es-toolkit', () => {
bench('es-toolkit/dropRightWhile', () => {
dropRightWhileToolkit([1.2, 2.3, 3.4], x => x < 2);
});

bench('lodash', () => {
bench('lodash/dropRightWhile', () => {
dropRightWhileLodash([1.2, 2.3, 3.4], x => x < 2);
});
});
4 changes: 2 additions & 2 deletions benchmarks/dropWhile.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { dropWhile as dropWhileToolkit } from 'es-toolkit';
import { dropWhile as dropWhileLodash } from 'lodash';

describe('dropWhile', () => {
bench('es-toolkit', () => {
bench('es-toolkit/dropWhile', () => {
dropWhileToolkit([1.2, 2.3, 3.4], x => x < 2);
});

bench('lodash', () => {
bench('lodash/dropWhile', () => {
dropWhileLodash([1.2, 2.3, 3.4], x => x < 2);
});
});
4 changes: 2 additions & 2 deletions benchmarks/groupBy.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { groupBy as groupByToolkit } from 'es-toolkit';
import { groupBy as groupByLodash } from 'lodash';

describe('groupBy', () => {
bench('es-toolkit', () => {
bench('es-toolkit/groupBy', () => {
const array = [
{ category: 'fruit', name: 'apple' },
{ category: 'fruit', name: 'banana' },
Expand All @@ -15,7 +15,7 @@ describe('groupBy', () => {
groupByToolkit(array, item => item.category);
});

bench('lodash', () => {
bench('lodash/groupBy', () => {
const array = [
{ category: 'fruit', name: 'apple' },
{ category: 'fruit', name: 'banana' },
Expand Down
26 changes: 21 additions & 5 deletions benchmarks/intersection.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@ import { bench, describe } from 'vitest';
import { intersection as intersectionToolkit } from 'es-toolkit';
import { intersection as intersectionLodash } from 'lodash';

describe('intersection', () => {
bench('es-toolkit', () => {
intersectionToolkit([1, 2, 3], [2, 4]);
describe('intersection, small arrays', () => {
const array1 = [1, 2, 3];
const array2 = [2, 4];

bench('es-toolkit/intersection', () => {
intersectionToolkit(array1, array2);
});

bench('lodash/intersection', () => {
intersectionLodash(array1, array2);
});
});

describe('intersection, large arrays', () => {
const array1 = Array.from({ length: 10000 }, () => Math.floor(Math.random() * 1000));
const array2 = Array.from({ length: 10000 }, () => Math.floor(Math.random() * 1000));

bench('es-toolkit/intersection', () => {
intersectionToolkit(array1, array2);
});

bench('lodash', () => {
intersectionLodash([1, 2, 3], [2, 4]);
bench('lodash/intersection', () => {
intersectionLodash(array1, array2);
});
});
4 changes: 2 additions & 2 deletions benchmarks/intersectionBy.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { intersectionBy as intersectionByToolkit } from 'es-toolkit';
import { intersectionBy as intersectionByLodash } from 'lodash';

describe('intersectionBy', () => {
bench('es-toolkit', () => {
bench('es-toolkit/intersectionBy', () => {
const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
const array2 = [{ id: 2 }, { id: 4 }];
const mapper = item => item.id;
intersectionByToolkit(array1, array2, mapper);
});

bench('lodash', () => {
bench('lodash/intersectionBy', () => {
const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
const array2 = [{ id: 2 }, { id: 4 }];
const mapper = item => item.id;
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/intersectionWith.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { intersectionWith as intersectionWithToolkit } from 'es-toolkit';
import { intersectionWith as intersectionWithLodash } from 'lodash';

describe('intersectionWith', () => {
bench('es-toolkit', () => {
bench('es-toolkit/intersectionWith', () => {
const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
const array2 = [{ id: 2 }, { id: 4 }];
const areItemsEqual = (a, b) => a.id === b.id;
intersectionWithToolkit(array1, array2, areItemsEqual);
});

bench('lodash', () => {
bench('lodash/intersectionWith', () => {
const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
const array2 = [{ id: 2 }, { id: 4 }];
const areItemsEqual = (a, b) => a.id === b.id;
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/isNil.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { isNil as isNilToolkit } from 'es-toolkit';
import { isNil as isNilLodash } from 'lodash';

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

bench('lodash', () => {
bench('lodash/isNil', () => {
isNilLodash(null);
isNilLodash(undefined);
isNilLodash(123);
Expand Down
23 changes: 23 additions & 0 deletions benchmarks/maxBy.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { bench, describe } from 'vitest';
import { maxBy as maxByToolkit } from 'es-toolkit';
import { maxBy as maxByLodash } from 'lodash';

describe('maxBy', () => {
bench('es-toolkit/maxBy', () => {
const people = [
{ name: 'Mark', age: 25 },
{ name: 'Nunu', age: 30 },
{ name: 'Overmars', age: 20 },
];
maxByToolkit(people, person => person.age);
});

bench('lodash/maxBy', () => {
const people = [
{ name: 'Mark', age: 25 },
{ name: 'Nunu', age: 30 },
{ name: 'Overmars', age: 20 },
];
maxByLodash(people, person => person.age);
});
});
23 changes: 23 additions & 0 deletions benchmarks/minBy.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { bench, describe } from 'vitest';
import { minBy as minByToolkit } from 'es-toolkit';
import { minBy as minByLodash } from 'lodash';

describe('minBy', () => {
bench('es-toolkit/minBy', () => {
const people = [
{ name: 'Mark', age: 30 },
{ name: 'Nunu', age: 20 },
{ name: 'Overmars', age: 35 },
];
minByToolkit(people, person => person.age);
});

bench('lodash/minBy', () => {
const people = [
{ name: 'Mark', age: 30 },
{ name: 'Nunu', age: 20 },
{ name: 'Overmars', age: 35 },
];
minByLodash(people, person => person.age);
});
});
4 changes: 2 additions & 2 deletions benchmarks/omit.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { omit as omitToolkit } from 'es-toolkit';
import { omit as omitLodash } from 'lodash';

describe('omit', () => {
bench('es-toolkit', () => {
bench('es-toolkit/omit', () => {
omitToolkit({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar']);
});

bench('lodash', () => {
bench('lodash/omit', () => {
omitLodash({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar']);
});
});
Loading

0 comments on commit 4a6ab65

Please sign in to comment.