-
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.
refactor: cleanup pick pickBy omit omitBy and update docs
- Loading branch information
Showing
30 changed files
with
260 additions
and
278 deletions.
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
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,6 @@ | ||
export const objectItems = [ | ||
{ text: 'pick', link: '/object/pick' }, | ||
{ text: 'pickBy', link: '/object/pick-by' }, | ||
{ text: 'omit', link: '/object/omit' }, | ||
{ text: 'omitBy', link: '/object/omit-by' }, | ||
] |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
# omitBy | ||
|
||
Excludes an object property by providing a function that constructs a new object. Returns a `truthy` value to indicate that the property should be excluded. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { omitBy } from 'rattail' | ||
|
||
omitBy({ a: 1, b: 2, c: 3 }, (value) => value > 1) | ||
// return { a: 1 } | ||
omitBy({ a: 1, b: 2, c: 3 }, (value, key) => key !== 'a') | ||
// return { a: 1 } | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| -------- | ---------------------------------- | -------- | | ||
| `object` | `object` | | | ||
| `fn` | `(value: any, key: string) => any` | | | ||
|
||
### 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
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,27 @@ | ||
# pickBy | ||
|
||
By providing a function to extract object properties and construct a new object, returning a `truthy` value indicates that the property needs to be extracted. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { pickBy } from 'rattail' | ||
|
||
pickBy({ a: 1, b: 2, c: 3 }, (value) => value > 1) | ||
// return { b: 2, c: 3 } | ||
pickBy({ a: 1, b: 2, c: 3 }, (value, key) => key !== 'a') | ||
// return { b: 2, c: 3 } | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| -------- | ---------------------------------- | -------- | | ||
| `object` | `object` | | | ||
| `fn` | `(value: any, key: string) => any` | | | ||
|
||
### 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
# omitBy | ||
|
||
通过提供一个函数来排除对象属性并构造成一个新的对象, 返回 `真值` 表示需要排除该属性。 | ||
|
||
### 使用 | ||
|
||
```ts | ||
import { omitBy } from 'rattail' | ||
|
||
omitBy({ a: 1, b: 2, c: 3 }, (value) => value > 1) | ||
// return { a: 1 } | ||
omitBy({ a: 1, b: 2, c: 3 }, (value, key) => key !== 'a') | ||
// return { a: 1 } | ||
``` | ||
|
||
### 参数 | ||
|
||
| 参数 | 类型 | 默认值 | | ||
| -------- | ---------------------------------- | ------ | | ||
| `object` | `object` | | | ||
| `fn` | `(value: any, key: string) => any` | | | ||
|
||
### 返回值 | ||
|
||
| 类型 | | ||
| -------- | | ||
| `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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# omit | ||
|
||
通过从现有对象中排除指定键来创建新对象。 | ||
排除对象属性并构造成一个新的对象。 | ||
|
||
### 使用 | ||
|
||
|
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,27 @@ | ||
# pickBy | ||
|
||
通过提供一个函数来提取对象属性并构造成一个新的对象, 返回 `真值` 表示需要提取该属性。 | ||
|
||
### 使用 | ||
|
||
```ts | ||
import { pickBy } from 'rattail' | ||
|
||
pickBy({ a: 1, b: 2, c: 3 }, (value) => value > 1) | ||
// return { b: 2, c: 3 } | ||
pickBy({ a: 1, b: 2, c: 3 }, (value, key) => key !== 'a') | ||
// return { b: 2, c: 3 } | ||
``` | ||
|
||
### 参数 | ||
|
||
| 参数 | 类型 | 默认值 | | ||
| -------- | ---------------------------------- | ------ | | ||
| `object` | `object` | | | ||
| `fn` | `(value: any, key: string) => any` | | | ||
|
||
### 返回值 | ||
|
||
| 类型 | | ||
| -------- | | ||
| `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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# pick | ||
|
||
通过从现有对象中选择指定键来创建新对象。 | ||
提取对象属性并构造成一个新的对象。 | ||
|
||
### 使用 | ||
|
||
|
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
export * from './pick' | ||
export * from './pickBy' | ||
export * from './omit' | ||
export * from './omitBy' |
Oops, something went wrong.