promise-snake
v1.3.3
Published
Continuous asynchronous operation for ES6 Promise
Downloads
14
Maintainers
Readme
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);
})();