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

0.1.0 • Public • Published

Dehydrater

Promise queue handler.

npm install dehydrater --save

Dehydrater.transaction

Dehydrater.transaction({n: 1}, next => {
  next(async (obj) => {
    await wait(100);
    return {n: obj.n + 1};
  });
 
  next(async (obj) => {
    await wait(100);
    return {n: obj.n + 2};
  });
 
  next(async (obj) => {
    await wait(100);
    return {n: obj.n + 3};
  });
 
}).then(result => {
  console.log(result); // {n: 7}
});

Dehydrater.startDehydrate(target)

const d = Dehydrater.create();
const {next, promise} = d.startDehydrate({n: 1});
 
next(async (obj) => {
  await wait(100);
  return {n: obj.n + 1};
});
 
next(async (obj) => {
  await wait(100);
  return {n: obj.n + 2};
});
 
next(async (obj) => {
  await wait(100);
  return {n: obj.n + 3};
});
 
promise.then(data => {
  console.log(data); // {n: 7}
});

LICENSE

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i dehydrater

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • mizchi