generated from stagas/ts
-
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.
- Loading branch information
Showing
2 changed files
with
79 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,69 @@ | ||
# debounce-micro | ||
<h1 align="center">debounce-micro</h1> | ||
|
||
<p align="center"> | ||
wrap a function in a debounce microtask | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="#install"> 🔧 <strong>Install</strong></a> | ||
· <a href="#example"> 🧩 <strong>Example</strong></a> | ||
· <a href="#api"> 📜 <strong>API docs</strong></a> | ||
· <a href="https://github.com/stagas/debounce-micro/releases"> 🔥 <strong>Releases</strong></a> | ||
· <a href="#contribute"> 💪🏼 <strong>Contribute</strong></a> | ||
· <a href="https://github.com/stagas/debounce-micro/issues"> 🖐️ <strong>Help</strong></a> | ||
</p> | ||
|
||
*** | ||
|
||
## Install | ||
|
||
```sh | ||
$ npm i debounce-micro | ||
``` | ||
|
||
## Example | ||
|
||
```ts | ||
let x = 0 | ||
const fn = debounce((y: number) => (x += y)) | ||
fn(1) | ||
fn(2) | ||
expect(x).toEqual(0) | ||
queueMicrotask(() => { | ||
expect(x).toEqual(2) // instead of 3 | ||
done() | ||
}) | ||
``` | ||
|
||
## API | ||
|
||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
|
||
#### Table of Contents | ||
|
||
* [debounce](#debounce) | ||
* [Parameters](#parameters) | ||
|
||
### debounce | ||
|
||
[src/index.ts:8-24](https://github.com/stagas/debounce-micro/blob/47ad0aec0ffc4b0f13650d5a26dc02ee52e46efb/src/index.ts#L8-L24 "Source code on GitHub") | ||
|
||
Wraps a function in a debounce microtask. | ||
|
||
#### Parameters | ||
|
||
* `inner` **function (...args: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<any>): any** The function to wrap in the debounce | ||
|
||
Returns **any** A debounced function | ||
|
||
## Contribute | ||
|
||
[Fork](https://github.com/stagas/debounce-micro/fork) or | ||
[edit](https://github.dev/stagas/debounce-micro) and submit a PR. | ||
|
||
All contributions are welcome! | ||
|
||
## License | ||
|
||
MIT © 2021 | ||
[stagas](https://github.com/stagas) |
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