{"_id":"mac","_rev":"305095","name":"mac","description":"A tiny library designed to parallel or series chain streams, promises or functions with callbacks.","dist-tags":{"latest":"0.4.0"},"maintainers":[{"name":"treshugart","email":"treshugart@gmail.com"}],"time":{"modified":"2021-06-03T19:28:56.000Z","created":"2015-02-26T02:09:12.921Z","0.4.0":"2015-08-14T06:55:22.366Z","0.3.0":"2015-03-23T05:12:28.048Z","0.2.1":"2015-03-12T05:59:03.092Z","0.2.0":"2015-02-26T02:09:12.921Z"},"users":{"aliemre":true},"author":{"name":"Trey Shugart","email":"treshugart@gmail.com","url":"http://treshugart.github.io"},"repository":{"type":"git","url":"git+https://github.com/treshugart/mac.git"},"versions":{"0.4.0":{"name":"mac","version":"0.4.0","description":"A tiny library designed to parallel or series chain streams, promises or functions with callbacks.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/treshugart/mac.git"},"keywords":["stream","promise","callback","parallel","series","chain","async","asynchronous","sync","synchronous"],"author":{"name":"Trey Shugart","email":"treshugart@gmail.com","url":"http://treshugart.github.io"},"license":"MIT","bugs":{"url":"https://github.com/treshugart/mac/issues"},"homepage":"https://github.com/treshugart/mac","gitHead":"06dd1ca93a017183e45b20e29497746450ef0bf1","_id":"mac@0.4.0","_shasum":"777fba48af0bc50ab8cdda796779a7105ca34b89","_from":".","_npmVersion":"2.12.0","_nodeVersion":"0.12.0","_npmUser":{"name":"treshugart","email":"treshugart@gmail.com"},"dist":{"shasum":"777fba48af0bc50ab8cdda796779a7105ca34b89","size":3111,"noattachment":false,"key":"/mac/-/mac-0.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mac/download/mac-0.4.0.tgz"},"maintainers":[{"name":"treshugart","email":"treshugart@gmail.com"}],"directories":{},"publish_time":1439535322366,"_cnpm_publish_time":1439535322366,"_hasShrinkwrap":false},"0.3.0":{"name":"mac","version":"0.3.0","description":"A tiny library designed to parallel or series chain streams, promises or functions with callbacks.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/treshugart/mac"},"keywords":["stream","promise","callback","parallel","series","chain","async","asynchronous","sync","synchronous"],"author":{"name":"Trey Shugart","email":"treshugart@gmail.com","url":"http://treshugart.github.io"},"license":"MIT","bugs":{"url":"https://github.com/treshugart/mac/issues"},"homepage":"https://github.com/treshugart/mac","gitHead":"53110b4e4da9e76e0b82e058f38c0ad9d4eac7dd","_id":"mac@0.3.0","_shasum":"72a16d7dc1b37c56c3097286e25ecfafb4e576f6","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"treshugart","email":"treshugart@gmail.com"},"maintainers":[{"name":"treshugart","email":"treshugart@gmail.com"}],"dist":{"shasum":"72a16d7dc1b37c56c3097286e25ecfafb4e576f6","size":3099,"noattachment":false,"key":"/mac/-/mac-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mac/download/mac-0.3.0.tgz"},"directories":{},"publish_time":1427087548048,"_cnpm_publish_time":1427087548048,"_hasShrinkwrap":false},"0.2.1":{"name":"mac","version":"0.2.1","description":"A tiny library designed to parallel or series chain streams, promises or functions with callbacks.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/treshugart/mac"},"keywords":["stream","promise","callback","parallel","series","chain","async","asynchronous","sync","synchronous"],"author":{"name":"Trey Shugart","email":"treshugart@gmail.com","url":"http://treshugart.github.io"},"license":"MIT","bugs":{"url":"https://github.com/treshugart/mac/issues"},"homepage":"https://github.com/treshugart/mac","gitHead":"d62073e47a3dff2361cc2688039a901b55bf407b","_id":"mac@0.2.1","_shasum":"c031267cc3e4162aa2eacb4f7b1b7e2f4b1eb2f7","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"treshugart","email":"treshugart@gmail.com"},"maintainers":[{"name":"treshugart","email":"treshugart@gmail.com"}],"dist":{"shasum":"c031267cc3e4162aa2eacb4f7b1b7e2f4b1eb2f7","size":3080,"noattachment":false,"key":"/mac/-/mac-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mac/download/mac-0.2.1.tgz"},"publish_time":1426139943092,"_cnpm_publish_time":1426139943092,"_hasShrinkwrap":false},"0.2.0":{"name":"mac","version":"0.2.0","description":"A tiny library designed to parallel or series chain streams, promises or functions with callbacks.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/treshugart/mac"},"keywords":["stream","promise","callback","parallel","series","chain","async","asynchronous","sync","synchronous"],"author":{"name":"Trey Shugart","email":"treshugart@gmail.com","url":"http://treshugart.github.io"},"license":"MIT","bugs":{"url":"https://github.com/treshugart/mac/issues"},"homepage":"https://github.com/treshugart/mac","gitHead":"2e1a30f74e1d73f9f4041df5d6add954a212044b","_id":"mac@0.2.0","_shasum":"a458060227738586ca71935a4c9535efdbec6f9f","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"treshugart","email":"treshugart@gmail.com"},"maintainers":[{"name":"treshugart","email":"treshugart@gmail.com"}],"dist":{"shasum":"a458060227738586ca71935a4c9535efdbec6f9f","size":3037,"noattachment":false,"key":"/mac/-/mac-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mac/download/mac-0.2.0.tgz"},"directories":{},"publish_time":1424916552921,"_cnpm_publish_time":1424916552921,"_hasShrinkwrap":false}},"readme":"# mac\n\n> \"Never break the chain.\" - Fleetwood Mac\n\nA tiny library designed to parallel or series chain streams, promises or functions with callbacks.\n\n## Installing\n\n```\nnpm install mac\n```\n\n## Including\n\n```\nvar mac = require('mac');\n```\n\n## Usage\n\nMac is designed to work with any combination of streams, promises or functions that define a single argument and will ensure that they are called in parallel or series. Since Mac returns a function that defines a callback, you can pass it into itself. The function that is returned when called begins executing the Mac chain.\n\n### Streams\n\nWorking with streams allows it to work with a multitude of libraries, most notably of these is probably Gulp, but it can be used with any sort of stream.\n\nThe following would ensure that your JS is transpiled from ES6 to ES5 and when that is finished it would then minify the `dist`.\n\n```js\nvar js = mac.series(\n  gulp.src('src/*.js').pipe(gulpBabelify).dest('dist'),\n  gulp.src('dist/*.js').pipe(gulpUglify).dest('dist')\n);\n```\n\nIf you want to run some tasks in paralell you can do that too. For example, if you wanted to take your JavaScript task and run it in parallel with your Less task, go for it:\n\n```js\nvar dist = mac.parallel(\n  js,\n  gulp.src('src/*.less').pipe(gulpLess).dest('dist')\n);\n```\n\nGulp is probably the shining example of this as most people will know it, but it can work with any stream that emits the `finish` event.\n\n### Promises\n\nIf you wanted to run two `fetch` (returns a promise, see: https://github.com/github/fetch) requests ensuring the first one is called before the second one:\n\n```js\nmac.series(\n  fetch('some/endpoint'),\n  fetch('something/else')\n);\n```\n\n### Functions\n\nIf you wanted to execute a series of functions ensuring one finishes before the other, you should define a single argument. This argument is a callback that you call in order to say that you're done doing whatever you're doing. Once called, it will proceed to the next.\n\n```js\nmac.series(\n  function (done) {\n    setTimeout(done, 100);\n  },\n\n  function (done) {\n\t  updateSomething();\n\t  done();\n  }\n);\n```\n\nIf your task doesn't need to report back, then you don't have to define a callback and call it and it will be called and passed through.\n\n```js\nmac.series(\n  function (done) {\n\t  setTimeout(done, 100);\n  },\n\n  function () {\n\t  updateSomething();\n  }\n);\n```\n\n### Build Example\n\nThe following is what an ES6 and Less project build might look like. It breaks each part down into separate functions that can be run individually, or batched using the main `dist` module. I chose not to require all the dependencies to reduce cruft, so just assume they're there.\n\n```js\n// tasks/dist/babelify.js\n\nmodule.exports = function () {\n  return gulp.src('src/*.js')\n    .pipe(gulpBabelify)\n    .pipe(gulp.dest('dist'));\n};\n\n// tasks/dist/uglify.js\n\nmodule.exports = function () {\n  return gulp.src('dist/*.js')\n    .pipe(gulpUglify)\n    .pipe(gulp.dest('dist'));\n};\n\n// tasks/dist/js.js\n\nmodule.exports = function () {\n  return mac.series(\n    require('./babelify'),\n    require('./uglify')\n  );\n};\n\n// tasks/dist/less.js\n\nmodule.exports = function () {\n  return gulp.src('src/*.less')\n    .pipe(gulpLess)\n    .pipe(gulp.dist('dist'));\n};\n\n// tasks/dist/cssmin.js\n\nmodule.exports = function () {\n  return gulp.src('dist/*.css')\n    .pipe(gulpCssmin)\n    .pipe(gulp.dist('dist'));\n};\n\n// tasks/dist/css.js\n\nmodule.exports = mac.series(\n  require('./less'),\n  require('./cssmin')\n);\n\n// tasks/dist.js\n\nmodule.exports = mac.parallel(\n  require('./dist/css'),\n  require('./dist/js')\n);\n\n```\n","_attachments":{},"homepage":"https://github.com/treshugart/mac","bugs":{"url":"https://github.com/treshugart/mac/issues"},"license":"MIT"}