docs(async): use Array.fromAsync() in debounce() example (#4283)

* docs(async): `debounce` example replace with `Array.fromAsync`

* Update async/debounce.ts

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
Hajime-san 2024-02-07 14:04:31 +09:00 committed by GitHub
parent 52138c6f99
commit 897b86d99c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,15 +26,12 @@ export interface DebouncedFunction<T extends Array<unknown>> {
* ```
* import { debounce } from "https://deno.land/std@$STD_VERSION/async/debounce.ts";
*
* const log = debounce(
* (event: Deno.FsEvent) =>
* console.log("[%s] %s", event.kind, event.paths[0]),
* 200,
* await Array.fromAsync(
* Deno.watchFs('./'),
* debounce((event) => {
* console.log('[%s] %s', event.kind, event.paths[0]);
* }, 200),
* );
*
* for await (const event of Deno.watchFs("./")) {
* log(event);
* }
* // wait 200ms ...
* // output: Function debounced after 200ms with baz
* ```