Skip to content

Commit

Permalink
Merge branch 'main' into feature/combat-take
Browse files Browse the repository at this point in the history
  • Loading branch information
choi2021 committed Jul 19, 2024
2 parents 1d70fb1 + 1d9d0da commit eaac995
Show file tree
Hide file tree
Showing 26 changed files with 705 additions and 9 deletions.
7 changes: 5 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ jobs:
- checkout
- setup
- run:
name: Lint
command: yarn eslint -c .eslintrc.js $(git diff --name-only --diff-filter=ACMRUXB origin/main | grep -E "(.js$|.ts$|.tsx$)")
name: ESLint
command: yarn eslint -c .eslintrc.js $(git diff --name-only --diff-filter=ACMRUXB origin/main | grep -E "(.js$|.ts$)")
- run:
name: Prettier
command: modifiedFiles=$(git diff --name-only --diff-filter=ACMRUXB origin/main | grep -E "(.js$|.ts$)") && [ -n "$modifiedFiles" ] && yarn prettier -c $modifiedFiles || echo "No modified files."
typecheck:
docker:
- image: cimg/node:20.12
Expand Down
4 changes: 3 additions & 1 deletion docs/.vitepress/en.mts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function sidebar(): DefaultTheme.Sidebar {
text: 'Array Utilities',
items: [
{ text: 'chunk', link: '/reference/array/chunk' },
{ text: 'concat (compat)', link: '/reference/array/concat' },
{ text: 'concat (compat)', link: '/reference/compat/array/concat' },
{ text: 'countBy', link: '/reference/array/countBy' },
{ text: 'compact', link: '/reference/array/compact' },
{ text: 'difference', link: '/reference/array/difference' },
Expand Down Expand Up @@ -138,6 +138,7 @@ function sidebar(): DefaultTheme.Sidebar {
items: [
{ text: 'clone', link: '/reference/object/clone' },
{ text: 'invert', link: '/reference/object/invert' },
{ text: 'flattenObject', link: '/reference/object/flattenObject' },
{ text: 'omit', link: '/reference/object/omit' },
{ text: 'omitBy', link: '/reference/object/omitBy' },
{ text: 'pick', link: '/reference/object/pick' },
Expand All @@ -150,6 +151,7 @@ function sidebar(): DefaultTheme.Sidebar {
text: 'Predicates',
items: [
{ text: 'isEqual', link: '/reference/predicate/isEqual' },
{ text: 'isPlainObject', link: '/reference/predicate/isPlainObject' },
{ text: 'isNil', link: '/reference/predicate/isNil' },
{ text: 'isNotNil', link: '/reference/predicate/isNotNil' },
{ text: 'isNull', link: '/reference/predicate/isNull' },
Expand Down
4 changes: 3 additions & 1 deletion docs/.vitepress/ko.mts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function sidebar(): DefaultTheme.Sidebar {
text: '배열',
items: [
{ text: 'chunk', link: '/ko/reference/array/chunk' },
{ text: 'concat (호환성)', link: '/ko/reference/array/concat' },
{ text: 'concat (호환성)', link: '/ko/reference/compat/array/concat' },
{ text: 'countBy', link: '/ko/reference/array/countBy' },
{ text: 'compact', link: '/ko/reference/array/compact' },
{ text: 'difference', link: '/ko/reference/array/difference' },
Expand Down Expand Up @@ -149,6 +149,7 @@ function sidebar(): DefaultTheme.Sidebar {
items: [
{ text: 'clone', link: '/ko/reference/object/clone' },
{ text: 'invert', link: '/ko/reference/object/invert' },
{ text: 'flattenObject', link: '/ko/reference/object/flattenObject' },
{ text: 'omit', link: '/ko/reference/object/omit' },
{ text: 'omitBy', link: '/ko/reference/object/omitBy' },
{ text: 'pick', link: '/ko/reference/object/pick' },
Expand All @@ -161,6 +162,7 @@ function sidebar(): DefaultTheme.Sidebar {
text: '타입 가드',
items: [
{ text: 'isEqual', link: '/ko/reference/predicate/isEqual' },
{ text: 'isPlainObject', link: '/ko/reference/predicate/isPlainObject' },
{ text: 'isNil', link: '/ko/reference/predicate/isNil' },
{ text: 'isNotNil', link: '/ko/reference/predicate/isNotNil' },
{ text: 'isNull', link: '/ko/reference/predicate/isNull' },
Expand Down
4 changes: 3 additions & 1 deletion docs/.vitepress/zh_hans.mts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function sidebar(): DefaultTheme.Sidebar {
text: '数组工具',
items: [
{ text: 'chunk', link: '/zh_hans/reference/array/chunk' },
{ text: 'concat (兼容性)', link: '/zh_hans/reference/array/concat' },
{ text: 'concat (兼容性)', link: '/zh_hans/reference/compat/array/concat' },
{ text: 'countBy', link: '/zh_hans/reference/array/countBy' },
{ text: 'compact', link: '/zh_hans/reference/array/compact' },
{ text: 'difference', link: '/zh_hans/reference/array/difference' },
Expand Down Expand Up @@ -134,6 +134,7 @@ function sidebar(): DefaultTheme.Sidebar {
items: [
{ text: 'clone', link: '/zh_hans/reference/object/clone' },
{ text: 'invert', link: '/zh_hans/reference/object/invert' },
{ text: 'flattenObject', link: '/zh_hans/reference/object/flattenObject' },
{ text: 'omit', link: '/zh_hans/reference/object/omit' },
{ text: 'omitBy', link: '/zh_hans/reference/object/omitBy' },
{ text: 'pick', link: '/zh_hans/reference/object/pick' },
Expand All @@ -146,6 +147,7 @@ function sidebar(): DefaultTheme.Sidebar {
text: '谓词',
items: [
{ text: 'isEqual', link: '/zh_hans/reference/predicate/isEqual' },
{ text: 'isPlainObject', link: '/zh_hans/reference/predicate/isPlainObject' },
{ text: 'isNil', link: '/zh_hans/reference/predicate/isNil' },
{ text: 'isNotNil', link: '/zh_hans/reference/predicate/isNotNil' },
{ text: 'isNull', link: '/zh_hans/reference/predicate/isNull' },
Expand Down
7 changes: 4 additions & 3 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ However, the following are out of scope for `es-toolkit/compat`:

- Implicit type conversions, such as converting an empty string to zero or false.
- Functions that have specialized implementations for specific types of arrays, like [sortedUniq](https://lodash.com/docs/4.17.15#sortedUniq).
- Handling cases where internal object prototypes, like `Array.prototype`, have been modified.
- Method chaining support through "Seq" methods.

## Implementation Status
Expand Down Expand Up @@ -66,7 +67,7 @@ Even if a feature is marked "in review," it might already be under review to ens
| [flattenDeep](https://lodash.com/docs/4.17.15#flattenDeep) | 📝 |
| [flattenDepth](https://lodash.com/docs/4.17.15#flattenDepth) | 📝 |
| [fromPairs](https://lodash.com/docs/4.17.15#fromPairs) ||
| [head](https://lodash.com/docs/4.17.15#head) | 📝 |
| [head](https://lodash.com/docs/4.17.15#head) | |
| [indexOf](https://lodash.com/docs/4.17.15#indexOf) ||
| [initial](https://lodash.com/docs/4.17.15#initial) | 📝 |
| [intersection](https://lodash.com/docs/4.17.15#intersection) | 📝 |
Expand All @@ -92,7 +93,7 @@ Even if a feature is marked "in review," it might already be under review to ens
| [sortedLastIndexOf](https://lodash.com/docs/4.17.15#sortedLastIndexOf) | No support |
| [sortedUniq](https://lodash.com/docs/4.17.15#sortedUniq) | No support |
| [sortedUniqBy](https://lodash.com/docs/4.17.15#sortedUniqBy) | No support |
| [tail](https://lodash.com/docs/4.17.15#tail) | 📝 |
| [tail](https://lodash.com/docs/4.17.15#tail) | |
| [take](https://lodash.com/docs/4.17.15#take) ||
| [takeRight](https://lodash.com/docs/4.17.15#takeRight) | 📝 |
| [takeRightWhile](https://lodash.com/docs/4.17.15#takeRightWhile) | 📝 |
Expand Down Expand Up @@ -219,7 +220,7 @@ Even if a feature is marked "in review," it might already be under review to ens
| [isNumber](https://lodash.com/docs/4.17.15#isNumber) ||
| [isObject](https://lodash.com/docs/4.17.15#isObject) ||
| [isObjectLike](https://lodash.com/docs/4.17.15#isObjectLike) ||
| [isPlainObject](https://lodash.com/docs/4.17.15#isPlainObject) | |
| [isPlainObject](https://lodash.com/docs/4.17.15#isPlainObject) | |
| [isRegExp](https://lodash.com/docs/4.17.15#isRegExp) ||
| [isSafeInteger](https://lodash.com/docs/4.17.15#isSafeInteger) ||
| [isSet](https://lodash.com/docs/4.17.15#isSet) ||
Expand Down
1 change: 1 addition & 0 deletions docs/ko/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ chunk([1, 2, 3, 4], 0);

- 암시적 타입 변환: 빈 문자열을 0 또는 false로 변환하는 것과 같은 동작
- 어떤 경우에 특화된 구현: [sortedUniq](https://lodash.com/docs/4.17.15#sortedUniq)와 같이 정렬된 배열만 받는 함수
- JavaScript 내장 객체의 프로토타입이 바뀐 경우에 대응하는 코드
- 메서드 체이닝: `_(arr).map(...).filter(...)`와 같은 메서드 체이닝

## 구현 상태
Expand Down
42 changes: 42 additions & 0 deletions docs/ko/reference/object/flattenObject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# flattenObject

중첩된 객체를 단순한 객체로 평탄화해요.

- `Array`는 평탄화돼요.
- 순수 객체가 아닌 `Buffer``TypedArray`는 평탄화되지 않아요.

## 인터페이스

```typescript
function flattenObject(object: object): Record<string, any>;
```

### 파라미터

- `object` (`object`): 평탄화할 객체.

### 반환 값

(`T`): 평탄화된 객체.

## 예시

```typescript
const nestedObject = {
a: {
b: {
c: 1
}
},
d: [2, 3]
};

const flattened = flattenObject(nestedObject);
console.log(flattened);
// Output:
// {
// 'a.b.c': 1,
// 'd.0': 2,
// 'd.1': 3
// }
```
27 changes: 27 additions & 0 deletions docs/ko/reference/predicate/isPlainObject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# isPlainObject

주어진 값이 순수 객체(Plain object)인지 확인해요.

## 인터페이스

```typescript
function isPlainObject(object: object): boolean;
```

### 파라미터

- `object` (`object`): 검사할 값.

### Returns

(`boolean`): 값이 순수 객체이면 true.

## Examples

```typescript
console.log(isPlainObject({})); // true
console.log(isPlainObject([])); // false
console.log(isPlainObject(null)); // false
console.log(isPlainObject(Object.create(null))); // true
console.log(Buffer.from('hello, world')); // false
```
42 changes: 42 additions & 0 deletions docs/reference/object/flattenObject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# flattenObject

Flattens a nested object into a single-level object with dot-separated keys.

- `Array`s are flattened.
- Non-plain objects, like `Buffer`s or `TypedArray`s, are not flattened.

## Signature

```typescript
function flattenObject(object: object): Record<string, any>;
```

### Parameters

- `object` (`object`): The object to flatten.

### Returns

(`T`): The flattened object.

## Examples

```typescript
const nestedObject = {
a: {
b: {
c: 1
}
},
d: [2, 3]
};

const flattened = flattenObject(nestedObject);
console.log(flattened);
// Output:
// {
// 'a.b.c': 1,
// 'd.0': 2,
// 'd.1': 3
// }
```
27 changes: 27 additions & 0 deletions docs/reference/predicate/isPlainObject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# isPlainObject

Checks if a given value is a plain object.

## Signature

```typescript
function isPlainObject(object: object): boolean;
```

### Parameters

- `object` (`object`): The value to check.

### Returns

(`boolean`): True if the value is a plain object, otherwise false.

## Examples

```typescript
console.log(isPlainObject({})); // true
console.log(isPlainObject([])); // false
console.log(isPlainObject(null)); // false
console.log(isPlainObject(Object.create(null))); // true
console.log(Buffer.from('hello, world')); // false
```
1 change: 1 addition & 0 deletions docs/zh_hans/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ chunk([1, 2, 3, 4], 0);

- 隐式类型转换,例如将空字符串转换为零或假。
- 对特定类型数组有专门实现的函数,比如 [sortedUniq](https://lodash.com/docs/4.17.15#sortedUniq)
- 处理内部对象原型(例如 `Array.prototype`)被修改的情况。
- 通过 "Seq" 方法支持方法链。

## 实现状态
Expand Down
2 changes: 1 addition & 1 deletion docs/zh_hans/reference/array/chunk.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ chunk([1, 2, 3], 0); // Returns []

## 性能对比

| | [包大小](../../bundle-size.md) | [런타임 성능](../../performance.md) |
| | [包大小](../../bundle-size.md) | [性能](../../performance.md) |
| ----------------- | ------------------------------ | ----------------------------------- |
| es-toolkit | 238 字节 (小 92.4%) | 9,338,821 次 (慢 11%) |
| es-toolkit/compat | 307 字节 (小 90.2%) | 9,892,157 次 (慢 5%) |
Expand Down
42 changes: 42 additions & 0 deletions docs/zh_hans/reference/object/flattenObject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# flattenObject

将嵌套对象扁平化为具有点分隔键的单级对象。

- `Array` 会被扁平化。
- 非普通对象,如 `Buffer``TypedArray`,不会被扁平化。

## 签名

```typescript
function flattenObject(object: object): Record<string, any>;
```

### 参数

- `object` (`object`): 要扁平化的对象。

### 返回值

(`T`): 扁平化后的对象。

## 示例

```typescript
const nestedObject = {
a: {
b: {
c: 1
}
},
d: [2, 3]
};

const flattened = flattenObject(nestedObject);
console.log(flattened);
// 输出:
// {
// 'a.b.c': 1,
// 'd.0': 2,
// 'd.1': 3
// }
```
27 changes: 27 additions & 0 deletions docs/zh_hans/reference/predicate/isPlainObject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# isPlainObject

检查给定值是否是一个普通对象。

## 签名

```typescript
function isPlainObject(object: object): boolean;
```

### 参数

- `object` (`object`): 要检查的值。

### 返回值

(`boolean`): 如果该值是普通对象,则返回 `true`,否则返回 `false`

## 示例

```typescript
console.log(isPlainObject({})); // true
console.log(isPlainObject([])); // false
console.log(isPlainObject(null)); // false
console.log(isPlainObject(Object.create(null))); // true
console.log(Buffer.from('hello, world')); // false
```
2 changes: 2 additions & 0 deletions src/array/tail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export function tail<T, U>(arr: readonly [T, ...U[]]): U[];
* const result3 = tail(arr3);
* // result3 will be []
*/
export function tail<T>(arr: readonly T[]): T[];

export function tail<T>(arr: readonly T[]): T[] {
const len = arr.length;
if (len <= 1) {
Expand Down
Loading

0 comments on commit eaac995

Please sign in to comment.