Skip to content

E0SelmY4V/promise-snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
})();

About

Continuous asynchronous operation for ES6 Promise

Resources

License

Stars

Watchers

Forks

Packages

No packages published