promise-snake
TypeScript icon, indicating that this package has built-in type declarations

1.3.3 • Public • Published

Promise Snake

This is a plugin for ES6 Promise, which can bring Scpos Process' scpoProce.snake and Proce#next to your code without additional importation of other Thenable library.

Usage

Multiple Timeout

import 'promise-snake';

Promise.snake([
  (res) => {
    console.log('How');
    return setTimeout(res, 200);
  },
  (res) => {
    console.log('are');
    return setTimeout(res, 500);
  },
  (res) => {
    console.log('you?');
    return res();
  },
]);

Reading Files Continuously

import * as fsp from 'fs/promises';
import 'promise-snake';

const files = ['a.txt', 'b.txt', 'c.txt'];

(async () => {
  
  const txts = files.mapAsync(async (file) => {
    const txt = await fsp.readFile(file);
    return `${txt}`;
  });

  console.log(await txts);
})();

Package Sidebar

Install

npm i promise-snake

Weekly Downloads

3

Version

1.3.3

License

MIT

Unpacked Size

18.4 kB

Total Files

9

Last publish

Collaborators

  • e0selmy4v