Skip to content

Commit

Permalink
Merge branch 'main' into tinybench
Browse files Browse the repository at this point in the history
  • Loading branch information
dayongkr authored Oct 15, 2024
2 parents 6637a01 + 8849204 commit a57bfed
Show file tree
Hide file tree
Showing 70 changed files with 1,126 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .scripts/docs/generate-docs.mts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function toDocumentationItems(docs: DocNode[]): DocumentationItems {
})
.map(([name, entries]) => {
const sourcePath = fileURLToPath(entries[0].location.filename);
const docPath: string = path.relative(basePath, sourcePath).replace(/.ts$/g, '.md');
const docPath: string = path.join(path.dirname(path.relative(basePath, sourcePath)), `${name}.md`);

return {
docPath: docPath,
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# es-toolkit Changelog

## Version v1.25.1

Released on October 15th, 2024.
- Resolved an issue in [cloneDeep](https://es-toolkit.slash.page/reference/object/cloneDeep.html) that incorrectly copied properties from the `target` when they were read-only.
- Updated [every](https://es-toolkit.slash.page/reference/compat/array/every.html), [filter](https://es-toolkit.slash.page/reference/compat/array/filter.html), [find](https://es-toolkit.slash.page/reference/compat/array/find.html), [findIndex](https://es-toolkit.slash.page/reference/compat/array/findIndex.html), [findLastIndex](https://es-toolkit.slash.page/reference/compat/array/findLastIndex.html), [indexOf](https://es-toolkit.slash.page/reference/compat/array/indexOf.html), and [join](https://es-toolkit.slash.page/reference/compat/array/join.html) to now accept array-like objects and a `fromIndex` parameter, making them compatible with lodash.

This version includes contributions from @D-Sketon. Thank you for your valuable contributions!

## Version v1.25.0

Released on October 14th, 2024.

- Added support for [isFile](https://es-toolkit.slash.page/reference/predicate/isFile.html).
- Added compatibility functions for [escape](https://es-toolkit.slash.page/reference/string/escape.html), [toSafeInteger](https://es-toolkit.slash.page/reference/compat/util/toSafeInteger.html), [intersection](https://es-toolkit.slash.page/reference/array/intersection.html), [sample](https://es-toolkit.slash.page/reference/array/sample.html), [chunk](https://es-toolkit.slash.page/reference/array/chunk.html), [compact](https://es-toolkit.slash.page/reference/array/compact.html), [head](https://es-toolkit.slash.page/reference/array/head.html), [initial](https://es-toolkit.slash.page/reference/array/initial.html), [last](https://es-toolkit.slash.page/reference/array/last.html), [tail](https://es-toolkit.slash.page/reference/array/tail.html), [take](https://es-toolkit.slash.page/reference/array/take.html), [takeRight](https://es-toolkit.slash.page/reference/array/takeRight.html), [uniq](https://es-toolkit.slash.page/reference/array/uniq.html), and [without](https://es-toolkit.slash.page/reference/array/without.html).
- Enhanced performance for [at](https://es-toolkit.slash.page/reference/array/at.html) and [isPlainObject](https://es-toolkit.slash.page/reference/predicate/isPlainObject.html).
- Resolved an issue in [cloneDeep](https://es-toolkit.slash.page/reference/object/cloneDeep.html) that prevented it from cloning symbol properties and read-only properties of objects.
- Fixed a problem in [pick](https://es-toolkit.slash.page/reference/object/pick.html) within our compatibility library that incorrectly added `undefined` for keys that do not exist.

This version includes contributions from @D-Sketon, @mass2527, @dayongkr, @lukaszkowalik2, @Gyumong, @Dohun-choi, @belgattitude, and @chhw130. Thank you for your valuable contributions!

## Version v1.24.0

Released on October 7th, 2024.
Expand Down
1 change: 1 addition & 0 deletions README-ja_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ es-toolkitは、最先端のJavaScriptユーティリティライブラリであ
- パフォーマンスを重視して設計されており、es-toolkitは最新のJavaScript環境で[2-3倍の性能向上](https://es-toolkit.slash.page/performance.html)を実現します。
- es-toolkitはツリーシェイキングをサポートしており、他のライブラリと比較してJavaScriptコードを最大[97%削減](https://es-toolkit.slash.page/bundle-size.html)します。
- es-toolkitには組み込みのTypeScriptサポートが含まれており、直感的で堅牢な型を提供します。また、[isNotNil](https://es-toolkit.slash.page/reference/predicate/isNotNil.html)などの便利な型ガードも提供します。
- es-toolkitは、[Storybook](https://github.com/storybookjs/storybook/blob/9d862798d666678cc4822e857c00bbd744169ced/code/core/package.json#L358)[ink](https://github.com/vadimdemedes/ink/blob/2090ad9779be59dea71d173eb49785b7bd4495d0/package.json#L55)など、よく使われるオープンソースライブラリで利用されています。
- es-toolkitは100%のテストカバレッジを持ち、信頼性と堅牢性を確保しています。

##
Expand Down
1 change: 1 addition & 0 deletions README-ko_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ es-toolkit은 높은 성능과 작은 번들 사이즈, 강력한 타입을 자
- 설계할 때 퍼포먼스를 중요 원칙으로 두어, es-toolkit은 현대적인 JavaScript 환경에서 [2-3배 빠른 성능](https://es-toolkit.slash.page/ko/performance.html)을 보여요.
- es-toolkit은 트리 셰이킹을 기본으로 지원하며, 함수에 따라서는 다른 라이브러리와 비교했을 때 [최대 97% 작은 JavaScript 번들 사이즈](https://es-toolkit.slash.page/ko/bundle-size.html)를 제공해요.
- es-toolkit은 TypeScript 타입이 내장되어 있고, 직관적이고 정확한 타입을 추구해요. [isNotNil](https://es-toolkit.slash.page/ko/reference/predicate/isNotNil.html) 같은 사용하기 편리한 유틸리티 함수도 제공해요.
- es-toolkit은 [Storybook](https://github.com/storybookjs/storybook/blob/9d862798d666678cc4822e857c00bbd744169ced/code/core/package.json#L358)이나 [ink](https://github.com/vadimdemedes/ink/blob/2090ad9779be59dea71d173eb49785b7bd4495d0/package.json#L55) 같이 자주 사용되는 오픈소스 라이브러리에서 사용돼요.
- es-toolkit은 100% 테스트 커버리지를 유지하면서, 높은 안정성을 자랑해요.

## 기여하기
Expand Down
1 change: 1 addition & 0 deletions README-zh_hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ es-toolkit 是一个先进的、高性能的 JavaScript 实用工具库,具有
- 设计时考虑了性能,es-toolkit 在现代 JavaScript 环境中实现了 [2-3 倍的性能提升](https://es-toolkit.slash.page/zh_hans/performance.html)
- es-toolkit 支持开箱即用,并且与其他库相比,可以将 JavaScript 代码减少高达 [97%](https://es-toolkit.slash.page/zh_hans/bundle-size.html)
- es-toolkit 包含内置的 TypeScript 支持,提供直观且强大的类型。它还提供诸如 [isNotNil](https://es-toolkit.slash.page/zh_hans/reference/predicate/isNotNil.html) 等有用的类型保护。
- es-toolkit 被多个流行的开源库所使用,例如 [Storybook](https://github.com/storybookjs/storybook/blob/9d862798d666678cc4822e857c00bbd744169ced/code/core/package.json#L358)[ink](https://github.com/vadimdemedes/ink/blob/2090ad9779be59dea71d173eb49785b7bd4495d0/package.json#L55)
- es-toolkit 经过了百分之百的测试覆盖率的实战检验,确保其可靠性和稳健性。

## 示例
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ es-toolkit is a state-of-the-art, high-performance JavaScript utility library wi
- Designed with performance in mind, es-toolkit achieves [2-3× better performance](https://es-toolkit.slash.page/performance.html) in modern JavaScript environments.
- es-toolkit supports tree shaking out of the box, and [reduces JavaScript code by up to 97%](https://es-toolkit.slash.page/bundle-size.html) compared to other libraries.
- es-toolkit includes built-in TypeScript support, with straightforward yet robust types. It also provides useful type guards such as [isNotNil](https://es-toolkit.slash.page/reference/predicate/isNotNil.html).
- es-toolkit is utilized by several popular open-source libraries, such as [Storybook](https://github.com/storybookjs/storybook/blob/9d862798d666678cc4822e857c00bbd744169ced/code/core/package.json#L358) and [ink](https://github.com/vadimdemedes/ink/blob/2090ad9779be59dea71d173eb49785b7bd4495d0/package.json#L55).
- es-toolkit is battle-tested with 100% test coverage, ensuring reliability and robustness.

## Examples
Expand Down
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ features:
details: es-toolkit fully leverages modern JavaScript APIs for straightforward and error-free implementation.
- title: Robust types
details: es-toolkit offers simple yet robust types for all functions.
- title: Widely adopted
details: es-toolkit is widely adopted by popular open-source libraries such as Storybook and ink.
- title: Battle-tested
details: es-toolkit has 100% test coverage, ensuring maximum robustness.
- title: Comprehensive runtime support
Expand Down
2 changes: 2 additions & 0 deletions docs/ja/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ features:
details: 最新のJavaScript APIを使用しているため、実装が直感的でシンプルです。
- title: 堅牢な型定義
details: すべての関数に対してシンプルながら堅牢な型定義を提供しています。
- title: 幅広い採用
details: es-toolkitは、Storybookやinkなどの人気のオープンソースライブラリに広く採用されています。
- title: テストカバレッジ100%
details: すべての関数とブランチに対して、綿密なテストが作成されています。
- title: あらゆる環境で使用可能
Expand Down
17 changes: 17 additions & 0 deletions docs/ja/reference/compat/array/every.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ function every<T extends Record<string, unknown>>(object: T, doesMatch: string):

- `arr` (`T[]`) または `object` (`T`): 検索する配列またはオブジェクト。

::: info `arr``ArrayLike<T>``null` または `undefined` である可能性があります

lodash と完全に互換性があるように、`every` 関数は `arr` を次のように処理します:

- `arr``ArrayLike<T>` の場合、`Array.from(...)` を使用して配列に変換されます。
- `arr``null` または `undefined` の場合、空の配列として扱われます。

:::

::: info `object``null` または `undefined` である可能性があります

lodash と完全に互換性があるように、`every` 関数は `object` を次のように処理します:

- `object``null` または `undefined` の場合、空のオブジェクトに変換されます。

:::

- `doesMatch`:

- 配列の場合:
Expand Down
9 changes: 9 additions & 0 deletions docs/ja/reference/compat/array/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ function filter<T extends Record<string, unknown>>(object: T, doesMatch: string)

- `arr` (`T[]`) または `object` (`T`): 繰り返し処理する配列やオブジェクト。

::: info `arr``ArrayLike<T>``null` または `undefined` になります

lodash と完全に互換性を保つため、`filter` 関数は `arr` を次のように処理します。

- `arr``ArrayLike<T>` の場合、`Array.from(...)` を使用して配列に変換します。
- `arr``null` または `undefined` の場合、空の配列として扱います。

:::

- `doesMatch`:

- 配列の場合:
Expand Down
17 changes: 17 additions & 0 deletions docs/ja/reference/compat/array/find.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ function find<T extends Record<string, unknown>>(object: T, doesMatch: string):

- `arr` (`T[]`) または `object` (`T`): 検索する配列またはオブジェクト。

::: info `arr``ArrayLike<T>` であるか、`null` または `undefined` である可能性があります

lodash と完全に互換性があるように、`find` 関数は `arr` を次のように処理します。

- `arr``ArrayLike<T>` の場合、`Array.from(...)` を使用して配列に変換します。
- `arr``null` または `undefined` の場合、空の配列と見なされます。

:::

::: info `object``null` または `undefined` である可能性があります

lodash と完全に互換性があるように、`find` 関数は `object` を次のように処理します。

- `object``null` または `undefined` の場合、空のオブジェクトに変換されます。

:::

- `doesMatch`:

- 配列の場合:
Expand Down
19 changes: 15 additions & 4 deletions docs/ja/reference/compat/array/findIndex.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,34 @@
## インターフェース

```typescript
function findIndex<T>(arr: T[], doesMatch: (item: T, index: number, arr: T[]) => unknown): number;
function findIndex<T>(arr: T[], doesMatch: Partial<T>): number;
function findIndex<T>(arr: T[], doesMatch: [keyof T, unknown]): number;
function findIndex<T>(arr: T[], doesMatch: string): number;
function findIndex<T>(arr: T[], doesMatch: (item: T, index: number, arr: T[]) => unknown, fromIndex?: number): number;
function findIndex<T>(arr: T[], doesMatch: Partial<T>, fromIndex?: number): number;
function findIndex<T>(arr: T[], doesMatch: [keyof T, unknown], fromIndex?: number): number;
function findIndex<T>(arr: T[], doesMatch: string, fromIndex?: number): number;
```

### パラメータ

- `arr` (`T[]`): 検索する配列。

::: info `arr``ArrayLike<T>` であるか、`null` または `undefined` である可能性があります

lodash と完全に互換性があるように、`findIndex` 関数は `arr` を次のように処理します。

- `arr``ArrayLike<T>` の場合、`Array.from(...)` を使用して配列に変換します。
- `arr``null` または `undefined` の場合、空の配列と見なされます。

:::

- `doesMatch`:

- **検査関数** (`(item: T, index: number, arr: T[]) => unknown`): 探している要素かどうかを返す関数。
- **部分オブジェクト** (`Partial<T>`): 一致させるプロパティと値を指定した部分オブジェクト。
- **プロパティ-値ペア** (`[keyof T, unknown]`): 最初が一致させるプロパティ、2番目が一致させる値を表すタプル。
- **プロパティ名** (`string`): 真と評価される値を持っているか確認するプロパティ名。

- `fromIndex` (`number`): 検索を開始するインデックス。デフォルトは `0`

### 戻り値

(`number`): 与えられた条件を満たす最初の要素のインデックス。ない場合は `-1`
Expand Down
9 changes: 9 additions & 0 deletions docs/ja/reference/compat/array/findLastIndex.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ function findLastIndex<T>(arr: T[], doesMatch: string, fromIndex?: number): numb

- `arr` (`T[]`): 検索する配列。

::: info `arr``ArrayLike<T>` であるか、`null` または `undefined` である可能性があります

lodash と完全に互換性があるように、`findLastIndex` 関数は `arr` を次のように処理します。

- `arr``ArrayLike<T>` の場合、`Array.from(...)` を使用して配列に変換します。
- `arr``null` または `undefined` の場合、空の配列と見なされます。

:::

- `doesMatch`:

- **検査関数** (`(item: T, index: number, arr: T[]) => unknown`): 探している要素かどうかを返す関数。
Expand Down
50 changes: 50 additions & 0 deletions docs/ja/reference/compat/array/first.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# first

::: info
この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。

`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。
:::

配列の最初の要素を返します。配列が空の場合は`undefined`を返します。

この関数は配列を受け取り、配列の最初の要素を返します。
配列が空の場合、関数は`undefined`を返します。

## インターフェース

```typescript
function first<T>(arr: ArrayLike<T> | undefined | null): T | undefined;
```

### パラメータ

- `arr` (`ArrayLike<T> | undefined | null`): 最初の要素を取得するための配列です。

### 戻り値

(`T | undefined`): 配列の最初の要素、または配列が空の場合は`undefined`です。

##

```typescript
const arr1 = [1, 2, 3];
const firstElement1 = first(arr1);
// firstElement1は1です。

const arr2: string[] = [];
const firstElement2 = first(arr2);
// firstElement2はundefinedです。

const arr3 = ['a', 'b', 'c'];
const firstElement3 = first(arr3);
// firstElement3は'a'です。

const arr4 = [true, false, true];
const firstElement4 = first(arr4);
// firstElement4はtrueです。

const arr5: [number, string, boolean] = [1, 'a', true];
const firstElement5 = first(arr5);
// firstElement5は1です。
```
14 changes: 12 additions & 2 deletions docs/ja/reference/compat/array/indexOf.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@
## インターフェース

```typescript
function indexOf<T>(array: T[] | null | undefined, searchElement: T, fromIndex?: number): number;
function indexOf<T>(array: T[], searchElement: T, fromIndex?: number): number;
```

### パラメータ

- `array` (`T[] | null | undefined`): 検索対象の配列。
- `array` (`T[]`): 検索対象の配列。

::: info `array``ArrayLike<T>` または `null` または `undefined` である可能性があります

lodash と完全に互換性があるように、`join` 関数は `array` を次のように処理します。

- `array``ArrayLike<T>` の場合、配列に変換するために `Array.from(...)` を使用します。
- `array``null` または `undefined` の場合、空の配列と見なされます。

:::

- `searchElement` (`T`): 検索する値。
- `fromIndex` (`number`, オプション): 検索を開始するインデックス。

Expand Down
21 changes: 13 additions & 8 deletions docs/ja/reference/compat/array/join.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@
## インターフェース

```typescript
function join<T>(array: T[], separator: string): string;
function join<T>(array: T[], separator?: string): string;
```

### パラメータ

- `array` (`T[]`) - 結合する配列です。

::: info `array``ArrayLike<T>` であるか、`null` または `undefined` である可能性があります

lodash と完全に互換性があるように、`join` 関数は `array` を次のように処理します。

- `array``ArrayLike<T>` の場合、`Array.from(...)` を使用して配列に変換します。
- `array``null` または `undefined` の場合、空の配列と見なされます。

:::

- `separator` (`string`) - 要素を結合するために用いるセパレータ、デフォルトは一般的なセパレータ `,` です。

### 戻り値
Expand All @@ -25,13 +35,8 @@ function join<T>(array: T[], separator: string): string;

##

````typescript
```typescript
const arr = ["a","b","c"];
const result = join(arr, "~");
const arr = ['a', 'b', 'c'];
const result = join(arr, '~');
console.log(result); // Output: "a~b~c"
````
```

```
15 changes: 15 additions & 0 deletions docs/ja/reference/object/cloneDeep.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ console.log(clonedNestedObj.d === nestedObj.d); // false
console.log(clonedNestedObj.d[2] === nestedObj.d[2]); // false
```

### 読み取り専用プロパティ

getterとして定義された読み取り専用プロパティを持つオブジェクトを深くコピーすると、新しくコピーされたオブジェクトはgetterの返す値を持ちます。

```tsx
const source = {
get value() {
return 3;
},
};

const cloned = cloneDeep(source);
// cloned is now { value: 3 }
```

## デモ

::: sandpack
Expand Down
2 changes: 2 additions & 0 deletions docs/ko/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ features:
details: 모든 함수에 대해서 간단하지만 견고한 타입을 제공해요.
- title: 테스트 커버리지 100%
details: 모든 함수와 분기에 대해서 꼼꼼하게 테스트가 작성되어 있어요.
- title: 넓은 사용처
details: es-toolkit은 Storybook 및 ink와 같은 인기 있는 오픈 소스 라이브러리에서 널리 사용되고 있어요.
- title: 모든 환경에서 사용 가능
details: Node.js, Deno, Bun, 그리고 브라우저까지 넓은 JavaScript 환경을 지원해요.
---
17 changes: 17 additions & 0 deletions docs/ko/reference/compat/array/every.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ function every<T extends Record<string, unknown>>(object: T, doesMatch: string):

- `arr` (`T[]`) 또는 `object` (`T`): 검색할 배열이나 객체.

::: info `arr``ArrayLike<T>`일 수도 있고, `null` 또는 `undefined`일 수도 있어요

lodash와 완벽하게 호환되도록 `every` 함수는 `arr`을 다음과 같이 처리해요:

- `arr``ArrayLike<T>`인 경우 `Array.from(...)`을 사용하여 배열로 변환해요.
- `arr``null` 또는 `undefined`인 경우 빈 배열로 간주돼요.

:::

::: info `object``null` 또는 `undefined`일 수도 있어요

lodash와 완벽하게 호환되도록 `every` 함수는 `object`를 다음과 같이 처리해요:

- `object``null` 또는 `undefined`인 경우 빈 객체로 변환돼요.

:::

- `doesMatch`:

- 배열의 경우:
Expand Down
Loading

0 comments on commit a57bfed

Please sign in to comment.