wing-sequence
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

wing-sequence

JavaScript Sequence

Uage

import Sequence, { type PromiseHandler } from 'wing-sequence';

const sequence = new Sequence<PromiseHandler<boolean>>();
const log = (value: string) => sequence.push((v: boolean) => new Promise(async (r) => r(v && (await logAsync(value)))));
const logAsync = (value: string): Promise<boolean> => {
  return new Promise((resolve) => {
    setTimeout(() => {
      console.log(value);
      resolve(true);
    }, Math.random() * 100);
  });
};

function test() {
  setTimeout(() => {
    log('3');
  }, 200);

  log('1');

  log('2');
}


test();
// 1
// 2
// 3

Readme

Keywords

Package Sidebar

Install

npm i wing-sequence

Weekly Downloads

4

Version

0.0.2

License

MIT

Unpacked Size

6.96 kB

Total Files

8

Last publish

Collaborators

  • wadlay