Skip to content

Commit

Permalink
docs: Fix docs style
Browse files Browse the repository at this point in the history
  • Loading branch information
raon0211 committed Oct 7, 2024
1 parent f914f07 commit 2560219
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 5 deletions.
34 changes: 34 additions & 0 deletions docs/ja/reference/compat/array/slice.md
Original file line number Diff line number Diff line change
@@ -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<T>(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]
```
2 changes: 1 addition & 1 deletion docs/ja/reference/function/before.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ const before3 = before(3, () => {
console.log(before3()); // カウントを増やします... => 1
console.log(before3()); // カウントを増やします... => 2
console.log(before3()); // => 2
```
```
34 changes: 34 additions & 0 deletions docs/ko/reference/compat/array/slice.md
Original file line number Diff line number Diff line change
@@ -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<T>(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]
```
3 changes: 2 additions & 1 deletion docs/ko/reference/function/before.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ afterFn();
// '실행됨'을 로깅해요.
afterFn();
```

## Lodash와의 호환성

`es-toolkit/compat`에서 `before`를 가져오면 lodash와 호환돼요.
Expand All @@ -68,4 +69,4 @@ const before3 = before(3, () => {
console.log(before3()); // 카운트를 증가시켜요... => 1
console.log(before3()); // 카운트를 증가시켜요... => 2
console.log(before3()); // => 2
```
```
34 changes: 34 additions & 0 deletions docs/reference/compat/array/slice.md
Original file line number Diff line number Diff line change
@@ -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<T>(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]
```
4 changes: 2 additions & 2 deletions docs/reference/function/before.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ const before3 = before(3, () => {

console.log(before3()); // Incrementing count... => 1
console.log(before3()); // Incrementing count... => 2
console.log(before3()); // => 2
```
console.log(before3()); // => 2
```
34 changes: 34 additions & 0 deletions docs/zh_hans/reference/compat/array/slice.md
Original file line number Diff line number Diff line change
@@ -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<T>(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]
```
2 changes: 1 addition & 1 deletion docs/zh_hans/reference/function/before.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ const before3 = before(3, () => {
console.log(before3()); // 正在增加计数... => 1
console.log(before3()); // 正在增加计数... => 2
console.log(before3()); // => 2
```
```

0 comments on commit 2560219

Please sign in to comment.