当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

async

优质
小牛编辑
130浏览
2023-12-01

Creates a sequence, with the same elements as this one, that will be iterated over asynchronously when calling each.

Signature

Sequence.async = function(interval) { /*...*/ }
Sequence.async = function async(interval) {
  return new AsyncSequence(this, interval);
}
NameType(s)Description
intervalnumber?

The approximate period, in milliseconds, that should elapse between each element in the resulting sequence. Omitting this argument will result in the fastest possible asynchronous iteration.

returnsAsyncSequence

The new asynchronous sequence.

Examples

Lazy([1, 2, 3]).async(100).each(fn) // calls fn 3 times asynchronously