{"_id":"@com.christiangrete.libs.js/sequential-promise-processor","_rev":"3-839e9eb66b3617286469928be61c3c20","name":"@com.christiangrete.libs.js/sequential-promise-processor","description":"A processor that queues and resolves promises in series","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1-0":{"author":{"name":"Christian Grete","email":"webmaster@christiangrete.com","url":"https://christiangrete.com"},"bugs":{"url":"https://github.com/ChristianGrete/sequential-promise-processor/issues","email":"webmaster@christiangrete.com"},"contributors":[{"name":"Christian Grete","email":"webmaster@christiangrete.com","url":"https://christiangrete.com"}],"dependencies":{},"description":"A processor that queues and resolves promises in series","files":[],"homepage":"https://github.com/ChristianGrete/sequential-promise-processor","keywords":[],"license":"MIT","main":"dist/index.js","maintainers":[{"name":"Christian Grete","email":"webmaster@christiangrete.com","url":"https://christiangrete.com"}],"name":"@com.christiangrete.libs.js/sequential-promise-processor","private":false,"repository":{"type":"git","url":"git://github.com/ChristianGrete/sequential-promise-processor.git"},"version":"0.0.1-0","gitHead":"264d1fc6362f0fa69f349e8c7214eccf3c25a185","_id":"@com.christiangrete.libs.js/sequential-promise-processor@0.0.1-0","_npmVersion":"5.3.0","_nodeVersion":"8.1.4","_npmUser":{"name":"christiangrete","email":"webmaster@christiangrete.com"},"dist":{"integrity":"sha512-SWmZvk0FH8Cgi6mfaSWPGdXjKK3uR5Ou3YuZfu+pmNH46S3OapvI9jPw+toRcZCurEEcIGx3QqNqoNwyAqHmZw==","shasum":"7ad8da63c9b882a0d678ce54460421bc9424f19e","tarball":"https://registry.npmjs.org/@com.christiangrete.libs.js/sequential-promise-processor/-/sequential-promise-processor-0.0.1-0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDza0Lrqhf67/qRjE9q3cmzFqpoGdM8xeC6NiB55t6nYQIgOo3mS3EGUM8xeUMHQfdXnmr99r0BXwj/WaJfSdRL3oU="}]},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sequential-promise-processor-0.0.1-0.tgz_1500985555166_0.40544795733876526"}},"0.0.1":{"author":{"name":"Christian Grete","email":"webmaster@christiangrete.com","url":"https://christiangrete.com"},"bugs":{"url":"https://github.com/ChristianGrete/sequential-promise-processor/issues","email":"webmaster@christiangrete.com"},"contributors":[{"name":"Christian Grete","email":"webmaster@christiangrete.com","url":"https://christiangrete.com"}],"dependencies":{},"description":"A processor that queues and resolves promises in series","files":["dist/index.js"],"homepage":"https://github.com/ChristianGrete/sequential-promise-processor","keywords":[],"license":"MIT","main":"dist/index.js","maintainers":[{"name":"christiangrete","email":"webmaster@christiangrete.com"}],"name":"@com.christiangrete.libs.js/sequential-promise-processor","private":false,"repository":{"type":"git","url":"git://github.com/ChristianGrete/sequential-promise-processor.git"},"version":"0.0.1","gitHead":"6dbaf0e2ec7031aaa8eb4639fee5bf9888b029ce","_id":"@com.christiangrete.libs.js/sequential-promise-processor@0.0.1","_npmVersion":"5.3.0","_nodeVersion":"8.1.4","_npmUser":{"name":"christiangrete","email":"webmaster@christiangrete.com"},"dist":{"integrity":"sha512-GBsIS0MLXfBdcQYdtlC+twUdYNizlvlCQRvTajgmklMtRPH7LXuEsd/8kT0fLY7FP29K8cDU0YiQf8/0UPtZuQ==","shasum":"bfe17628cb7a88a2093047cb7798779f59bdcae4","tarball":"https://registry.npmjs.org/@com.christiangrete.libs.js/sequential-promise-processor/-/sequential-promise-processor-0.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCC/4XzxxF/re3ZtXI5gd5S0pHLiyMeviuPK0KbvQWGdQIgQwbQvEUuNx8UJ/jKf9hus6Yb95Vq8d28BYS0i66XhF0="}]},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sequential-promise-processor-0.0.1.tgz_1501067991649_0.1692165178246796"}},"0.1.0":{"author":{"name":"Christian Grete","email":"webmaster@christiangrete.com","url":"https://christiangrete.com"},"bugs":{"url":"https://github.com/ChristianGrete/sequential-promise-processor/issues","email":"webmaster@christiangrete.com"},"contributors":[{"name":"Christian Grete","email":"webmaster@christiangrete.com","url":"https://christiangrete.com"}],"dependencies":{},"description":"A processor that queues and resolves promises in series","files":["*.md","dist/index.js"],"homepage":"https://github.com/ChristianGrete/sequential-promise-processor","keywords":[],"license":"MIT","main":"dist/index.js","maintainers":[{"name":"christiangrete","email":"webmaster@christiangrete.com"}],"name":"@com.christiangrete.libs.js/sequential-promise-processor","private":false,"repository":{"type":"git","url":"git://github.com/ChristianGrete/sequential-promise-processor.git"},"version":"0.1.0","gitHead":"ed0684f4e54220c695a906fe542e95eee3ad8534","_id":"@com.christiangrete.libs.js/sequential-promise-processor@0.1.0","_npmVersion":"5.3.0","_nodeVersion":"8.1.4","_npmUser":{"name":"christiangrete","email":"webmaster@christiangrete.com"},"dist":{"integrity":"sha512-E61MaB1KtRLuHKYUp6dbYZq4FdqaTRdsmbPlqGlF2zzJdCQ66tzorcxRg2OpomuIXxoXm/glQnyhg+SsYB6Szg==","shasum":"00bb8fe0ee738b128d40e3748fec9be588c20605","tarball":"https://registry.npmjs.org/@com.christiangrete.libs.js/sequential-promise-processor/-/sequential-promise-processor-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDIt/WN5z2OLCZ2DU0pg5h5ERQO10owzMdg2huLfOMEwAIhAJrgxyZohEZ5lvqWFM6huTPJes85lKeiKQK6xeOQKuip"}]},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sequential-promise-processor-0.1.0.tgz_1501167204284_0.3577614410314709"}}},"readme":"# [sequential-promise-processor][github-url]\n\n[![Travis CI][shield-travis-ci]][travis-ci-url]\n[![Latest GitHub Tag][shield-github-tag]][github-tags-url]\n[![Node.js Module Version][shield-npm-version]][npm-url]\n[![Downloads via npm per Month][shield-npm-downloads]][npm-url]\n\n> A processor that queues and resolves promises in series\n\n## Getting started\n\n### Installation\n\nTo install this package to your [Node.js](https://nodejs.org) modules, simply run:\n```sh\nnpm i -S @com.christiangrete.libs.js/sequential-promise-processor\n```\nOr, using [Yarn](https://yarnpkg.com), run:\n```sh\nyarn add @com.christiangrete.libs.js/sequential-promise-processor\n```\n\n### Usage\n\nJust import it as an ES2015 module and create an instance to get started:\n```js\nimport {\n  SequentialPromiseProcessor\n} from '@com.christiangrete.libs.js/sequential-promise-processor'\n\nconst sequentialPromiseProcessor = new SequentialPromiseProcessor()\n```\nThe class is also available as the `default` member, so you don’t need to explicitly import it as a named member.\n\nThis package is distributed using the [UMD](https://github.com/umdjs/umd) pattern and can be required using [RequireJS](http://requirejs.org) or used as a global variable under `window.SequentialPromiseProcessor.default` as well.\n\n## Example\n\nLet’s assume that we want to execute `git` commands in a series:\n```js\nimport {\n  SequentialPromiseProcessor\n} from '@com.christiangrete.libs.js/sequential-promise-processor'\n\nimport {exec} from 'child_process'\n\n// A factory function that returns another function which will be passed to the\n// Promise constructor as its executor function with the corresponding command\nconst createExecutor = $command => ($resolve, $reject) => {\n  exec($command, ($error, $stdout, $stderr) => {\n    if ($error === null) {\n      $resolve($stdout)\n    } else {\n      $reject($error, $stderr)\n    }\n  })\n}\n\n// Another factory function that returns a new Promise object created with the\n// corresponding command and the executor function from the factory above\nconst createFactory = ($command, $callback) => () => {\n  const _executor = createExecutor($command)\n  const _promise = new Promise(_executor)\n\n  if (typeof $callback === 'function') {\n    _promise.then(\n      $stdout => $callback(null, $stdout),\n      ($error, $stderr) => $callback($error, $stderr)\n    )\n  }\n\n  return _promise\n}\n\n// A list of commands that will be executed in series\nconst commands = [\n  'git add --all',\n  'git status',\n  \"git commit -m 'fix stuff'\",\n  'git pull origin develop',\n  'git push origin develop'\n]\n\n// A list of factory functions referenced with the corresponding command from\n// the list above\nconst factories = commands.map($command => createFactory(\n  $command,\n  (...$arguments) => console.log(...$arguments)\n))\n\nconst sequentialPromiseProcessor = new SequentialPromiseProcessor()\n\n// This method adds all factory functions to the queue...\nsequentialPromiseProcessor.queue(factories) // Queues the factories from above\n// ...it could also be used as follows:\n// sequentialPromiseProcessor.queue(...factories)\n// ...or...\n// sequentialPromiseProcessor.queue(factories[0]).queue(factories[1])\n\n// Start processing the queue needs to be done manually.\nsequentialPromiseProcessor.process()\n\n// It is possible to remove a factory from the queue, unless it has already\n// been processed.\nsequentialPromiseProcessor.unqueue(factories[1])\n\n// It is also possible to pause the processing of the queue...\nsequentialPromiseProcessor.pause()\n\n// ...and to resume it later on...\nsetTimeout(() => {\n  sequentialPromiseProcessor.resume()\n}, 500)\n\n// ...or completely abort the process.\nsequentialPromiseProcessor.cancel()\n```\n\n## Policy\n\nThis is communist software. It is crafted with heart and soul to the best of the authors’ knowledge and belief: _Not for profit but to satisfy the concrete needs._ Do whatever you want with it (as long as you keep the authors’ copyright notices in all copies or substantial portions of it included) for free. Imagine how the world could be if others would produce and distribute their products for the same benefits and ask yourself why they’re actually not.\n\n## Contributing\n\nYou’re more than welcome to contribute to the source code of this project. See the [contribution guidelines](CONTRIBUTING.md) on how to get involved.\n\nAlso, have a look at the [to-do list](TODO.md).\n\n## License\n\nThis software is licensed under [MIT License](LICENSE.md).\n\nCopyright © 2017 [Christian Grete](https://christiangrete.com)\n- [GitHub](https://github.com/ChristianGrete)\n- [npm](https://www.npmjs.com/~christiangrete)\n- [Twitter](https://twitter.com/ChristianGrete)\n- [LinkedIn](https://www.linkedin.com/in/ChristianGrete)\n- [XING](https://www.xing.com/profile/Christian_Grete2)\n\n[github-tags-url]: https://github.com/ChristianGrete/sequential-promise-processor/tags\n[github-url]: https://github.com/ChristianGrete/sequential-promise-processor\n[npm-url]: https://www.npmjs.com/package/@com.christiangrete.libs.js/sequential-promise-processor\n[shield-github-tag]: https://img.shields.io/github/tag/ChristianGrete/sequential-promise-processor.svg\n[shield-npm-downloads]: https://img.shields.io/npm/dm/@com.christiangrete.libs.js/sequential-promise-processor.svg\n[shield-npm-version]: https://img.shields.io/npm/v/@com.christiangrete.libs.js/sequential-promise-processor.svg\n[shield-travis-ci]: https://img.shields.io/travis/ChristianGrete/sequential-promise-processor.svg\n[travis-ci-url]: https://travis-ci.org/ChristianGrete/sequential-promise-processor","maintainers":[{"name":"christiangrete","email":"webmaster@christiangrete.com"}],"time":{"modified":"2022-04-05T00:23:28.944Z","created":"2017-07-25T12:25:56.005Z","0.0.1-0":"2017-07-25T12:25:56.005Z","0.0.1":"2017-07-26T11:19:52.536Z","0.1.0":"2017-07-27T14:53:25.285Z"},"homepage":"https://github.com/ChristianGrete/sequential-promise-processor","keywords":[],"repository":{"type":"git","url":"git://github.com/ChristianGrete/sequential-promise-processor.git"},"contributors":[{"name":"Christian Grete","email":"webmaster@christiangrete.com","url":"https://christiangrete.com"}],"author":{"name":"Christian Grete","email":"webmaster@christiangrete.com","url":"https://christiangrete.com"},"bugs":{"url":"https://github.com/ChristianGrete/sequential-promise-processor/issues","email":"webmaster@christiangrete.com"},"license":"MIT","readmeFilename":"README.md"}