Skip to content

Commit

Permalink
fix: lint 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ssi02014 committed Jul 9, 2024
1 parent 96dc002 commit b717d50
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/ko/reference/array/flatten.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

인자로 넣은 중첩 배열을 원하는 깊이까지 평탄화해요.

JS에서 기본적으로 제공하는 [Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) 동일한 동작과 타입을 반환해요.
JavaScript에서 기본적으로 제공하는 [Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) 동일한 동작과 반환 타입을 가져요. 하지만 성능은 더 우수합니다.

## 인터페이스

```typescript
function flatten<T, D extends number = 1>(arr: T[], depth?: D): FlatArray<T[], D>[];
function flatten<T, D extends number = 1>(arr: T[], depth?: D): Array<FlatArray<T[], D>>;
```

### 파라미터
Expand All @@ -17,7 +17,7 @@ function flatten<T, D extends number = 1>(arr: T[], depth?: D): FlatArray<T[], D

### 반환 값

(`FlatArray<T[], D>[]`) 원하는 깊이로 평탄화 된 새로운 배열이에요.
(`Array<FlatArray<T[], D>>`) 원하는 깊이로 평탄화 된 새로운 배열이에요.

## 예시

Expand Down
6 changes: 3 additions & 3 deletions docs/reference/array/flatten.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

Flattens the nested array given as an argument to the desired depth.

It behaves the same as and returns the same type as the built-in [Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) provided by JavaScript, but with superior performance.
It works the same as [Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) provided by default in JavaScript and returns the same type. However, its performance is superior.

## Signature

```typescript
function flatten<T, D extends number = 1>(arr: T[], depth?: D): FlatArray<T[], D>[];
function flatten<T, D extends number = 1>(arr: T[], depth?: D): Array<FlatArray<T[], D>>;
```

### Parameters
Expand All @@ -17,7 +17,7 @@ function flatten<T, D extends number = 1>(arr: T[], depth?: D): FlatArray<T[], D

### Returns

(`FlatArray<T[], D>[]`) A new array that has been flattened.
(`Array<FlatArray<T[], D>>`) A new array that has been flattened.

## Examples

Expand Down
8 changes: 4 additions & 4 deletions src/array/flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @template T - The type of elements within the array.
* @template D - The depth to which the array should be flattened.
* @param {T[]} arr - The array to flatten.
* @param {D} [depth=1] - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns {FlatArray<T[], D>[]} A new array that has been flattened.
* @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns {Array<FlatArray<T[], D>>} A new array that has been flattened.
*
* @example
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);
Expand All @@ -14,8 +14,8 @@
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);
* // Returns: [1, 2, 3, 4, 5, 6]
*/
export function flatten<T, D extends number = 1>(arr: readonly T[], depth = 1 as D): FlatArray<T[], D>[] {
const result: FlatArray<T[], D>[] = [];
export function flatten<T, D extends number = 1>(arr: readonly T[], depth = 1 as D): Array<FlatArray<T[], D>> {
const result: Array<FlatArray<T[], D>> = [];
const flooredDepth = Math.floor(depth);

const recursive = (arr: readonly T[], currentDepth: number) => {
Expand Down

0 comments on commit b717d50

Please sign in to comment.