mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-09-10 03:00:37 +00:00
* [requestidlecallback] export "request" instead aFarkas's requestIdleCallback polyfill does not export as "requestIdleCallback". It's "request" and "cancel". https://github.com/aFarkas/requestIdleCallback/blob/18e7d0036d970204e32451e6c4190003161176c0/index.js#L209-L212 * format * add line break to "Definitions by" I followed below: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#edit-an-existing-package
18 lines
511 B
TypeScript
18 lines
511 B
TypeScript
import {
|
|
request as requestIdleCallback,
|
|
cancel as cancelIdleCallback,
|
|
IdleRequestOptions,
|
|
IdleCallbackHandle,
|
|
} from 'requestidlecallback';
|
|
|
|
// Test requestIdleCallback with default param
|
|
requestIdleCallback(() => '1');
|
|
|
|
// Test requestIdleCallback with default param and optional param
|
|
const option: IdleRequestOptions = { timeout: 2000 };
|
|
requestIdleCallback(() => '2', option);
|
|
|
|
// Test cancelIdleCallback with default param
|
|
const handle: IdleCallbackHandle = 1;
|
|
cancelIdleCallback(handle);
|