From 25602192d87d92a0c5392bd022643df37c87f739 Mon Sep 17 00:00:00 2001 From: raon0211 Date: Mon, 7 Oct 2024 22:25:31 +0900 Subject: [PATCH] docs: Fix docs style --- docs/ja/reference/compat/array/slice.md | 34 ++++++++++++++++++++ docs/ja/reference/function/before.md | 2 +- docs/ko/reference/compat/array/slice.md | 34 ++++++++++++++++++++ docs/ko/reference/function/before.md | 3 +- docs/reference/compat/array/slice.md | 34 ++++++++++++++++++++ docs/reference/function/before.md | 4 +-- docs/zh_hans/reference/compat/array/slice.md | 34 ++++++++++++++++++++ docs/zh_hans/reference/function/before.md | 2 +- 8 files changed, 142 insertions(+), 5 deletions(-) create mode 100644 docs/ja/reference/compat/array/slice.md create mode 100644 docs/ko/reference/compat/array/slice.md create mode 100644 docs/reference/compat/array/slice.md create mode 100644 docs/zh_hans/reference/compat/array/slice.md diff --git a/docs/ja/reference/compat/array/slice.md b/docs/ja/reference/compat/array/slice.md new file mode 100644 index 000000000..ce79aea40 --- /dev/null +++ b/docs/ja/reference/compat/array/slice.md @@ -0,0 +1,34 @@ +# slice + +::: info +この関数は互換性のために `es-toolkit/compat` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。 + +`es-toolkit/compat` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。 +::: + +インデックス `start` からインデックス `end` までの `array` の部分配列を作成します。部分配列には `end` は含まれません。 + +基本の `Array.prototype.slice` と異なり、スパース配列に対して密な配列を返しません。 + +## インターフェース + +```typescript +function slice(array: T[], start?: number, end?: number): T[]; +``` + +### パラメータ + +- `array` (`T[]`): 部分配列を作成する配列。 +- `start` (`number`): 開始位置。デフォルトは `0` です。 +- `end` (`number`): 終了位置。デフォルトは `array.length` です。 + +### 戻り値 + +(`T[]`): `array` の `start` から `end` までの部分配列。 + +## 例 + +```typescript +slice([1, 2, 3], 1, 2); // => [2] +slice(new Array(3)); // => [undefined, undefined, undefined] +``` diff --git a/docs/ja/reference/function/before.md b/docs/ja/reference/function/before.md index d7ebeb97a..c66a840ce 100644 --- a/docs/ja/reference/function/before.md +++ b/docs/ja/reference/function/before.md @@ -69,4 +69,4 @@ const before3 = before(3, () => { console.log(before3()); // カウントを増やします... => 1 console.log(before3()); // カウントを増やします... => 2 console.log(before3()); // => 2 -``` \ No newline at end of file +``` diff --git a/docs/ko/reference/compat/array/slice.md b/docs/ko/reference/compat/array/slice.md new file mode 100644 index 000000000..6b8785488 --- /dev/null +++ b/docs/ko/reference/compat/array/slice.md @@ -0,0 +1,34 @@ +# slice + +::: info +이 함수는 호환성을 위한 `es-toolkit/compat` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요. + +`es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요. +::: + +인덱스 `start`부터 인덱스 `end`까지 `array`의 부분 배열을 만들어요. 부분 배열에서 `end`는 포함하지 않아요. + +기본 `Array.prototype.slice`와 다르게, 희소 배열(Sparse array)에 대해 밀집 배열(Dense array)을 반환하지 않아요. + +## 인터페이스 + +```typescript +function slice(array: T[], start?: number, end?: number): T[]; +``` + +### 파라미터 + +- `array` (`T[]`): 부분 배열을 만들 배열. +- `start` (`number`): 시작 위치. 기본값은 `0`이에요. +- `end` (`number`): 끝 위치. 기본값은 `array.length`예요. + +### 반환 값 + +(`T[]`): `array`의 `start`부터 `end`까지의 부분 배열. + +## 예시 + +```typescript +slice([1, 2, 3], 1, 2); // => [2] +slice(new Array(3)); // => [undefined, undefined, undefined] +``` diff --git a/docs/ko/reference/function/before.md b/docs/ko/reference/function/before.md index ed472a98f..d4ce61192 100644 --- a/docs/ko/reference/function/before.md +++ b/docs/ko/reference/function/before.md @@ -47,6 +47,7 @@ afterFn(); // '실행됨'을 로깅해요. afterFn(); ``` + ## Lodash와의 호환성 `es-toolkit/compat`에서 `before`를 가져오면 lodash와 호환돼요. @@ -68,4 +69,4 @@ const before3 = before(3, () => { console.log(before3()); // 카운트를 증가시켜요... => 1 console.log(before3()); // 카운트를 증가시켜요... => 2 console.log(before3()); // => 2 -``` \ No newline at end of file +``` diff --git a/docs/reference/compat/array/slice.md b/docs/reference/compat/array/slice.md new file mode 100644 index 000000000..45aa54541 --- /dev/null +++ b/docs/reference/compat/array/slice.md @@ -0,0 +1,34 @@ +# slice + +::: info +This function is only available in `es-toolkit/compat` for compatibility reasons. It either has alternative native JavaScript APIs or isn’t fully optimized yet. + +When imported from `es-toolkit/compat`, it behaves exactly like lodash and provides the same functionalities, as detailed [here](../../../compatibility.md). +::: + +Create a slice of `array` from `start` up to, but not including, `end`. + +It does not return a dense array for sparse arrays unlike the native `Array.prototype.slice`. + +## Signature + +```typescript +function slice(array: T[], start?: number, end?: number): T[]; +``` + +### Parameters + +- `array` (`T[]`): The array to slice. +- `start` (`number`): The start position. Defaults to `0`. +- `end` (`number`): The end position. Defaults to `array.length`. + +### Returns + +(`T[]`): The slice of `array`. + +## Examples + +```typescript +slice([1, 2, 3], 1, 2); // => [2] +slice(new Array(3)); // => [undefined, undefined, undefined] +``` diff --git a/docs/reference/function/before.md b/docs/reference/function/before.md index 88026583f..7d0c07071 100644 --- a/docs/reference/function/before.md +++ b/docs/reference/function/before.md @@ -69,5 +69,5 @@ const before3 = before(3, () => { console.log(before3()); // Incrementing count... => 1 console.log(before3()); // Incrementing count... => 2 -console.log(before3()); // => 2 -``` \ No newline at end of file +console.log(before3()); // => 2 +``` diff --git a/docs/zh_hans/reference/compat/array/slice.md b/docs/zh_hans/reference/compat/array/slice.md new file mode 100644 index 000000000..8de7b8659 --- /dev/null +++ b/docs/zh_hans/reference/compat/array/slice.md @@ -0,0 +1,34 @@ +# slice + +::: info +出于兼容性原因,此函数仅在 `es-toolkit/compat` 中提供。它可能具有替代的原生 JavaScript API,或者尚未完全优化。 + +从 `es-toolkit/compat` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。 +::: + +从索引 `start` 到索引 `end` 创建 `array` 的部分数组。部分数组不包含 `end`。 + +与基本的 `Array.prototype.slice` 不同,它不会对稀疏数组返回密集数组。 + +## 签名 + +```typescript +function slice(array: T[], start?: number, end?: number): T[]; +``` + +### 参数 + +- `array` (`T[]`): 用于创建部分数组的数组。 +- `start` (`number`): 开始位置。默认值为 `0`。 +- `end` (`number`): 结束位置。默认值为 `array.length`。 + +### 返回值 + +(`T[]`): 从 `array` 的 `start` 到 `end` 的部分数组。 + +## 示例 + +```typescript +slice([1, 2, 3], 1, 2); // => [2] +slice(new Array(3)); // => [undefined, undefined, undefined] +``` diff --git a/docs/zh_hans/reference/function/before.md b/docs/zh_hans/reference/function/before.md index 607f269c2..88b12af6d 100644 --- a/docs/zh_hans/reference/function/before.md +++ b/docs/zh_hans/reference/function/before.md @@ -70,4 +70,4 @@ const before3 = before(3, () => { console.log(before3()); // 正在增加计数... => 1 console.log(before3()); // 正在增加计数... => 2 console.log(before3()); // => 2 -``` \ No newline at end of file +```