{"_id":"gulp-stream-to-promise","_rev":"4-e9698bb018ec221b87df0d234e02bc10","name":"gulp-stream-to-promise","description":"Convert gulp stream to promise.","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"gulp-stream-to-promise","version":"0.1.0","homepage":"https://github.com/cssmagic/gulp-stream-to-promise","author":{"name":"cssmagic","email":"cssmagic.cn@gmail.com"},"description":"Convert gulp stream to promise.","main":"index.js","keywords":["gulp","stream","promise","task"],"license":"MIT","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"dependencies":{},"devDependencies":{},"gitHead":"154b7ae49d501abc4920471cae66e793969abeb5","_id":"gulp-stream-to-promise@0.1.0","_shasum":"15834274d90364d516878aaba6c5f05e0a5e788a","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"cssmagic","email":"cssmagic.cn@gmail.com"},"dist":{"shasum":"15834274d90364d516878aaba6c5f05e0a5e788a","tarball":"https://registry.npmjs.org/gulp-stream-to-promise/-/gulp-stream-to-promise-0.1.0.tgz","integrity":"sha512-qMLM9UIP2pyEbFKoqehu7O3NdgWdYvPJMlbKuYdPlAH15dZER504LdAb68zbJ2kCskAKwkyb2338NpicxYXoqQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7q6n7awYtRyk+mMlfbSmRuAM+aTL/GRxsPqWFlVseVQIgS1BHcGJ4p7/KrS+CTlJOCZ/TbebnaO58lkobMYTglxA="}]},"maintainers":[{"name":"cssmagic","email":"cssmagic.cn@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/gulp-stream-to-promise-0.1.0.tgz_1478688056831_0.7456830479204655"}}},"readme":"# gulp-stream-to-promise\n\n> Convert gulp stream to promise.\n\n## Introduction\n\nIn Gulp 4, all task functions need be async, that means a task function needs to return a gulp stream, or a promise, etc.\n\nWith this feature, we can define multiple gulp streams as one gulp task. To do that, firstly we convert each gulp steam to promise, then combine them via `Promise.all()` to get one promise, finally return this all-in-one promise in the task function.\n\nThis package is to convert gulp streams to promises.\n\n## Usage\n\n0. Install:\n\n\t```sh\n\t$ npm install --save gulp-stream-to-promise\n\t```\n\n0. Require:\n\n\t```js\n\tconst gulpStreamToPromise = require('gulp-stream-to-promise')\n\t```\n\n0. Convert:\n\n\t```js\n\t// we have a gulp stream here:\n\tlet stream = gulp.src('path/to/src')\n\t\t.pipe(/* ... */)\n\t\t.pipe(gulp.dest('path/to/dest'))\n\t\n\t// convert it to a promise:\n\tlet promise = gulpStreamToPromise(stream)\n\t```\n\n## Example\n\n```js\nconst gulp = require('gulp')\t// gulp 4\nconst concat = require('gulp-concat')\nconst gulpStreamToPromise = require('gulp-stream-to-promise')\n\n// suppose we need to combine files according to this config:\nconst rules = {\n\t'foo.js': [\n\t\t'./node_modules/foo/src/a.js',\n\t\t'./node_modules/foo/src/b.js',\n\t],\n\t'bar.js': [\n\t\t'./src/c.js',\n\t\t'./src/d.js',\n\t],\n}\n\ngulp.task('js', () => {\n\t// array to contain each single combining operation:\n\tvar tasks = []\n\n\tObject.keys(rules).forEach((filename) => {\n\t\tlet src = rules[filename]\n\t\t\n\t\t// get a gulp stream for a combining operation:\n\t\tlet stream = gulp.src(src)\n\t\t\t.pipe(concat(filename))\n\t\t\t.pipe(gulp.dest('path/to/dest'))\n\n\t\t// convert this gulp stream to a promise:\n\t\tlet promise = gulpStreamToPromise(stream)\n\n\t\t// put into the array:\n\t\ttasks.push(promise)\n\t})\n\t\n\t// return the combined promise to complete the task function:\n\treturn Promise.all(tasks)\n})\n```\n\n***\n\n## License\n\n[MIT License](http://www.opensource.org/licenses/mit-license.php)\n","maintainers":[{"name":"cssmagic","email":"cssmagic.cn@gmail.com"}],"time":{"modified":"2022-06-18T18:02:48.788Z","created":"2016-11-09T10:40:58.882Z","0.1.0":"2016-11-09T10:40:58.882Z"},"homepage":"https://github.com/cssmagic/gulp-stream-to-promise","keywords":["gulp","stream","promise","task"],"author":{"name":"cssmagic","email":"cssmagic.cn@gmail.com"},"license":"MIT","readmeFilename":"README.md","users":{"shaddyhm":true}}