-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
312 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# omitBy | ||
|
||
Creates a new object by omitting key-value pairs based on a predicate function. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { omitBy } from 'rattail' | ||
|
||
const obj = { a: 1, b: 2, c: 3 } | ||
const omitted = omitBy(obj, (value) => value < 3) | ||
console.log(omitted) // { c: 3 } | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ----------- | -------------------------------------- | -------- | | ||
| `object` | `object` | | | ||
| `predicate` | `(value: any, key: string) => boolean` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| -------- | | ||
| `object` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# omit | ||
|
||
Creates a new object by omitting specified keys from an existing object. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { omit } from 'rattail' | ||
|
||
const obj = { a: 1, b: 2, c: 3 } | ||
const omitted = omit(obj, ['b']) | ||
console.log(omitted) // { a: 1, c: 3 } | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| -------- | ---------- | -------- | | ||
| `object` | `object` | | | ||
| `keys` | `string[]` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| -------- | | ||
| `object` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# pickBy | ||
|
||
Creates a new object by picking key-value pairs based on a predicate function. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { pickBy } from 'rattail' | ||
|
||
const obj = { a: 1, b: 2, c: 3 } | ||
const picked = pickBy(obj, (value) => value > 1) | ||
console.log(picked) // { b: 2, c: 3 } | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ----------- | -------------------------------------- | -------- | | ||
| `object` | `object` | | | ||
| `predicate` | `(value: any, key: string) => boolean` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| -------- | | ||
| `object` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# pick | ||
|
||
Creates a new object by selecting specified keys from an existing object. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { pick } from 'rattail' | ||
|
||
const obj = { a: 1, b: 2, c: 3 } | ||
const picked = pick(obj, ['a', 'c']) | ||
console.log(picked) // { a: 1, c: 3 } | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| -------- | ---------- | -------- | | ||
| `object` | `object` | | | ||
| `keys` | `string[]` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| -------- | | ||
| `object` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# omitBy | ||
|
||
通过提供的谓词函数排除键值对来创建新对象。 | ||
|
||
### 使用 | ||
|
||
```ts | ||
import { omitBy } from 'rattail' | ||
|
||
const obj = { a: 1, b: 2, c: 3 } | ||
const omitted = omitBy(obj, (value) => value < 3) | ||
console.log(omitted) // { c: 3 } | ||
``` | ||
|
||
### 参数 | ||
|
||
| 参数 | 类型 | 默认值 | | ||
| ----------- | -------------------------------------- | ------ | | ||
| `object` | `object` | | | ||
| `predicate` | `(value: any, key: string) => boolean` | | | ||
|
||
### 返回值 | ||
|
||
| 类型 | | ||
| -------- | | ||
| `object` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# omit | ||
|
||
通过从现有对象中排除指定键来创建新对象。 | ||
|
||
### 使用 | ||
|
||
```ts | ||
import { omit } from 'rattail' | ||
|
||
const obj = { a: 1, b: 2, c: 3 } | ||
const omitted = omit(obj, ['b']) | ||
console.log(omitted) // { a: 1, c: 3 } | ||
``` | ||
|
||
### 参数 | ||
|
||
| 参数 | 类型 | 默认值 | | ||
| -------- | ---------- | ------ | | ||
| `object` | `object` | | | ||
| `keys` | `string[]` | | | ||
|
||
### 返回值 | ||
|
||
| 类型 | | ||
| -------- | | ||
| `object` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# pickBy | ||
|
||
通过提供的谓词函数选择键值对来创建新对象。 | ||
|
||
### 使用 | ||
|
||
```ts | ||
import { pickBy } from 'rattail' | ||
|
||
const obj = { a: 1, b: 2, c: 3 } | ||
const picked = pickBy(obj, (value) => value > 1) | ||
console.log(picked) // { b: 2, c: 3 } | ||
``` | ||
|
||
### 参数 | ||
|
||
| 参数 | 类型 | 默认值 | | ||
| ----------- | -------------------------------------- | ------ | | ||
| `object` | `object` | | | ||
| `predicate` | `(value: any, key: string) => boolean` | | | ||
|
||
### 返回值 | ||
|
||
| 类型 | | ||
| -------- | | ||
| `object` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# pick | ||
|
||
通过从现有对象中选择指定键来创建新对象。 | ||
|
||
### 使用 | ||
|
||
```ts | ||
import { pick } from 'rattail' | ||
|
||
const obj = { a: 1, b: 2, c: 3 } | ||
const picked = pick(obj, ['a', 'c']) | ||
console.log(picked) // { a: 1, c: 3 } | ||
``` | ||
|
||
### 参数 | ||
|
||
| 参数 | 类型 | 默认值 | | ||
| -------- | ---------- | ------ | | ||
| `object` | `object` | | | ||
| `keys` | `string[]` | | | ||
|
||
### 返回值 | ||
|
||
| 类型 | | ||
| -------- | | ||
| `object` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters