Timeout in milliseconds. Passing in a negative number deactivates the timeout.
Optional
cb: ((count: number) => void)Notification of when iteration stopped due to the timeout,
with parameter count
- the number of items processed before the timeout.
Ends iteration after a specified number of milliseconds (from the beginning of iteration). When
ms
< 0, the timeout is deactivated.Optional callback
cb
is invoked when timeout is reached before iteration is over.It works synchronously in a similar way:
Note that the examples above may not always produce a consistent result, as they rely on a race condition, which depends on the OS, your current CPU load and JavaScript engine.