-
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
44 changed files
with
738 additions
and
188 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 |
---|---|---|
@@ -1 +1,4 @@ | ||
export const collectionItems = [{ text: 'mergeWith', link: '/collection/merge-with' }] | ||
export const collectionItems = [ | ||
{ text: 'merge', link: '/collection/merge' }, | ||
{ text: 'mergeWith', link: '/collection/merge-with' }, | ||
] |
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,5 +1,6 @@ | ||
export const functionItems = [ | ||
{ text: 'NOOP', link: '/function/noop' }, | ||
{ text: 'debounce', link: '/function/debounce' }, | ||
{ text: 'call', link: '/function/call' }, | ||
{ text: 'debounce', link: '/function/debounce' }, | ||
{ text: 'throttle', link: '/function/throttle' }, | ||
] |
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,9 @@ | ||
export const mathItems = [ | ||
{ text: 'sum', link: '/math/sum' }, | ||
{ text: 'sumBy', link: '/math/sum-by' }, | ||
{ text: 'minBy', link: '/math/min-by' }, | ||
{ text: 'maxBy', link: '/math/max-by' }, | ||
{ text: 'mean', link: '/math/mean' }, | ||
{ text: 'meanBy', link: '/math/mean-by' }, | ||
{ text: 'sample', link: '/math/sample' }, | ||
] |
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,25 @@ | ||
# merge | ||
|
||
Merge two objects recursively. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { merge } from 'rattail' | ||
|
||
merge({ a: 1, b: { c: 2 } }, { b: { d: 3 }, e: 4 }) | ||
// return { a: 1, b: { c: 2, d: 3 }, e: 4 } | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| -------- | -------- | -------- | | ||
| `object` | `object` | | | ||
| `source` | `object` | | | ||
|
||
### 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 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,25 @@ | ||
# maxBy | ||
|
||
Find the maximum value in an array based on the result of applying a function to each element. If the array is empty, `undefined` is returned. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { maxBy } from 'rattail' | ||
|
||
maxBy([{ n: 5 }, { n: 10 }, { n: 8 }], ({ n }) => n) | ||
// return { n: 10 } | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ----- | :------------------: | -------: | | ||
| `arr` | `T[]` | | | ||
| `fn` | `(val: T) => number` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :---------------: | | ||
| `T \| undefined` | |
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 @@ | ||
# meanBy | ||
|
||
Calculate the mean (average) of an `array` by applying a function to each element to derive a numeric value. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { meanBy } from 'rattail' | ||
|
||
meanBy([{ n: 4 }, { n: 6 }, { n: 8 }], ({ n }) => n) | ||
// return 6 | ||
meanBy([10, 20, 30], (n) => n / 2) | ||
// return 10 | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ----- | :------------------: | -------: | | ||
| `arr` | `T[]` | | | ||
| `fn` | `(val: T) => number` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :------: | | ||
| `number` | |
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,24 @@ | ||
# mean | ||
|
||
Calculate the `mean` (average) of an `array` of `numbers`. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { mean } from 'rattail' | ||
|
||
mean([1, 2, 3, 4, 5]) // return 3 | ||
mean([10, 20, 30]) // return 20 | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ----- | :--------: | -------: | | ||
| `arr` | `number[]` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :------: | | ||
| `number` | |
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,25 @@ | ||
# minBy | ||
|
||
Find the `minimum` value in an `array` based on the result of applying a function to each element. If the array is empty, `undefined` is returned. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { minBy } from 'rattail' | ||
|
||
minBy([{ n: 5 }, { n: 2 }, { n: 8 }], ({ n }) => n) | ||
// return { n: 2 } | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ----- | :------------------: | -------: | | ||
| `arr` | `T[]` | | | ||
| `fn` | `(val: T) => number` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :---------------: | | ||
| `T \| undefined` | |
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,24 @@ | ||
# sample | ||
|
||
Return a random element from an `array`. If the array is empty, `undefined` is returned. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { sample } from 'rattail' | ||
|
||
sample([1, 2, 3, 4, 5]) // returns a random element, e.g., 3 | ||
sample([]) // returns undefined | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ----- | :---: | -------: | | ||
| `arr` | `T[]` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :---------------: | | ||
| `T \| undefined` | |
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
File renamed without changes.
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,25 @@ | ||
# delay | ||
|
||
Create a promise that resolves after a specified time in milliseconds. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { delay } from 'rattail' | ||
|
||
console.log('Start') | ||
await delay(1000) | ||
console.log('End after 1 second') | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| --------------------- | :------: | -------: | | ||
| `time (ms)` | `number` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :-------------: | | ||
| `Promise<void>` | |
Oops, something went wrong.