generated from Flcwl/duration-pretty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Flcwl/feat/unext
Feat/unext
- Loading branch information
Showing
13 changed files
with
84 additions
and
59 deletions.
There are no files selected for viewing
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,14 @@ | ||
# unext | ||
|
||
## 2.0.1 | ||
|
||
### Patch Changes | ||
|
||
- removeOne | ||
|
||
## 2.0.0 | ||
|
||
### Patch Changes | ||
|
||
- a18fd24: alpha.1 | ||
- 977d617: 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
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,15 @@ | ||
import { AnyArray } from "../types"; | ||
|
||
/** | ||
* Remove item from an array | ||
*/ | ||
export const removeOne = <T>(list: T[], removed: T) => { | ||
const result = [...list]; | ||
const index = result.findIndex((item) => item === removed); | ||
|
||
if (index !== -1) { | ||
result.splice(index, 1); | ||
} | ||
|
||
return result; | ||
}; |
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,7 +1,7 @@ | ||
export * from '../array/is' | ||
export * from '../dom/is' | ||
export * from '../func/is' | ||
export * from '../nullish/is' | ||
export * from '../number/is' | ||
export * from '../object/is' | ||
export * from '../string/is' | ||
export * from "../array/is"; | ||
export * from "../dom/is"; | ||
export * from "../func/is"; | ||
export * from "../nullish/is"; | ||
export * from "../number/is"; | ||
export * from "../object/is"; | ||
export * from "../string/is"; |
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,17 +1,20 @@ | ||
import { AnyFunc } from "../types" | ||
import { AnyFunc } from "../types"; | ||
|
||
/** | ||
* throttle optimization | ||
*/ | ||
export const throttle = <T extends AnyFunc>(callback: T, timeout: number): T => { | ||
let timer: undefined | number | NodeJS.Timeout = undefined | ||
export const throttle = <T extends AnyFunc>( | ||
callback: T, | ||
timeout: number | ||
): T => { | ||
let timer: undefined | number | NodeJS.Timeout = undefined; | ||
|
||
return function (...args: any[]) { | ||
if (timer) return | ||
if (timer) return; | ||
|
||
timer = setTimeout(() => { | ||
timer = undefined | ||
callback.apply(null, args) | ||
}, timeout) | ||
} as T | ||
} | ||
timer = undefined; | ||
callback.apply(null, args); | ||
}, timeout); | ||
} as T; | ||
}; |
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,13 +1,13 @@ | ||
export * from './array' | ||
export * from './assertion' | ||
export * from './dom' | ||
export * from './env' | ||
export * from './func' | ||
export * from './nullish' | ||
export * from './number' | ||
export * from './object' | ||
export * from './react' | ||
export * from './server' | ||
export * from './string' | ||
export * from './tree' | ||
export * from './types' | ||
export * from "./array"; | ||
export * from "./assertion"; | ||
export * from "./dom"; | ||
export * from "./env"; | ||
export * from "./func"; | ||
export * from "./nullish"; | ||
export * from "./number"; | ||
export * from "./object"; | ||
export * from "./react"; | ||
export * from "./server"; | ||
export * from "./string"; | ||
export * from "./tree"; | ||
export * from "./types"; |
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,9 +1,9 @@ | ||
export * from './is' | ||
export * from './clone' | ||
export * from './get-nested' | ||
export * from './set-nested' | ||
export * from './get-object-type' | ||
export * from './has-own-prop' | ||
export * from './merge' | ||
export * from './object-to-paths' | ||
export * from './to-string' | ||
export * from "./is"; | ||
export * from "./clone"; | ||
export * from "./get-nested"; | ||
export * from "./set-nested"; | ||
export * from "./get-object-type"; | ||
export * from "./has-own-prop"; | ||
export * from "./merge"; | ||
export * from "./object-to-paths"; | ||
export * from "./to-string"; |
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 @@ | ||
export * from './is' | ||
export * from "./is"; |
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,7 +1,7 @@ | ||
export * from './clone' | ||
export * from './crud' | ||
export * from './filter-tree' | ||
export * from './flatten' | ||
export * from './get' | ||
export * from './types' | ||
export * from './visit-tree' | ||
export * from "./clone"; | ||
export * from "./crud"; | ||
export * from "./filter-tree"; | ||
export * from "./flatten"; | ||
export * from "./get"; | ||
export * from "./types"; | ||
export * from "./visit-tree"; |