{"_id":"561a88d530e7490d0022d661","__v":22,"user":"5617a0a4a410c90d00c612f4","category":{"_id":"5619a39a13874c0d007038ec","project":"5617a1f5a410c90d00c612f5","__v":9,"pages":["561a88d530e7490d0022d661","561a88de13874c0d0070394c","561a897730e7490d0022d663","5651055ea8567917000f71e9","56510675481fd91700dffe25","565106d8c042820d00de3a54","5652003550c76e0d00615a49","566bfb5a4db9c60d00c9a833","566bfbba7831040d003eb385"],"version":"5619a39913874c0d007038e9","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-10-09T13:15:56.785Z","from_sync":false,"order":5,"slug":"modules","title":"Natron Modules"},"project":"5617a1f5a410c90d00c612f5","version":{"_id":"5619a39913874c0d007038e9","project":"5617a1f5a410c90d00c612f5","__v":5,"createdAt":"2015-10-10T23:47:37.777Z","releaseDate":"2015-10-10T23:47:37.777Z","categories":["5619a39a13874c0d007038ea","5619a39a13874c0d007038eb","5619a39a13874c0d007038ec","5619a39a13874c0d007038ed","5651062a3b4d113500ed22d1","5651c89a852cfb3500a69830","565505ad055aa40d006f0ca7","56c219d8d3199a0d00694be6"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"Orange Arrow","version_clean":"0.2.0","version":"0.2"},"githubsync":"","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-10-11T16:05:41.803Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"[![Version][npm-img]][npm-url] [![Downloads][dlm-img]][npm-url]\n\n[npm-img]: https://img.shields.io/npm/v/natron-vinyl.svg\n[npm-url]: https://npmjs.org/package/natron-vinyl\n[dlm-img]: https://img.shields.io/npm/dm/natron-vinyl.svg\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Vinyl FS\",\n  \"body\": \"This module exports `src`, `dest`, `symlink` from [`vinyl-fs`](https://www.npmjs.com/package/vinyl-fs).\"\n}\n[/block]\n## Merge Streams\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import {task} from \\\"natron\\\";\\nimport {src, dest, merge} from \\\"natron-vinyl\\\";\\n\\nfunction bundle() {\\n  let s = src(\\\"src/**/*.js\\\");\\n  let v = src(\\\"vnd/**/*.js\\\");\\n  \\n  return (merge([s, v], {preserveOrder: true})\\n  \\t.pipe(dest(\\\"dist\\\"))\\n  );\\n}\\n\\ntask(bundle).run();\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n## Waiting for Multiple Streams to Finish\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import {task} from \\\"natron\\\";\\nimport {src, dest, awaitAll} from \\\"natron-vinyl\\\";\\n\\nfunction copy() {\\n  let j = src(\\\"src/**/*.js\\\").pipe(dest(\\\"js\\\"));\\n  let h = src(\\\"src/**/*.html\\\").pipe(dest(\\\"html\\\"));\\n  \\n  return awaitAll([j, h]);\\n}\\n\\ntask(copy).run();\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n## Stream from Promise\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import {task} from \\\"natron\\\";\\nimport {src, dest, File, fromPromise} from \\\"natron-vinyl\\\";\\n\\nfunction dlFile(name, url) {\\n  return (fetch(url)\\n  \\t.then((res) => res.text())\\n  \\t.then((txt) => {\\n    \\tlet contents = new Buffer(txt);\\n    \\treturn new File({path: name, contents});\\n  \\t})\\n  );\\n}\\n\\nfunction copy() {\\n  let url = \\\"http://example.com/test.txt\\\";\\n  return (fromPromise(dlFile(\\\"test.txt\\\", url))\\n    .pipe(dest(\\\"dist\\\"))\\n  );\\n}\\n\\ntask(copy).run();\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"Natron Vinyl Utilities","slug":"module-natron-vinyl","type":"basic","title":"natron-vinyl"}

natron-vinyl

Natron Vinyl Utilities

[![Version][npm-img]][npm-url] [![Downloads][dlm-img]][npm-url] [npm-img]: https://img.shields.io/npm/v/natron-vinyl.svg [npm-url]: https://npmjs.org/package/natron-vinyl [dlm-img]: https://img.shields.io/npm/dm/natron-vinyl.svg [block:callout] { "type": "info", "title": "Vinyl FS", "body": "This module exports `src`, `dest`, `symlink` from [`vinyl-fs`](https://www.npmjs.com/package/vinyl-fs)." } [/block] ## Merge Streams [block:code] { "codes": [ { "code": "import {task} from \"natron\";\nimport {src, dest, merge} from \"natron-vinyl\";\n\nfunction bundle() {\n let s = src(\"src/**/*.js\");\n let v = src(\"vnd/**/*.js\");\n \n return (merge([s, v], {preserveOrder: true})\n \t.pipe(dest(\"dist\"))\n );\n}\n\ntask(bundle).run();", "language": "javascript" } ] } [/block] ## Waiting for Multiple Streams to Finish [block:code] { "codes": [ { "code": "import {task} from \"natron\";\nimport {src, dest, awaitAll} from \"natron-vinyl\";\n\nfunction copy() {\n let j = src(\"src/**/*.js\").pipe(dest(\"js\"));\n let h = src(\"src/**/*.html\").pipe(dest(\"html\"));\n \n return awaitAll([j, h]);\n}\n\ntask(copy).run();", "language": "javascript" } ] } [/block] ## Stream from Promise [block:code] { "codes": [ { "code": "import {task} from \"natron\";\nimport {src, dest, File, fromPromise} from \"natron-vinyl\";\n\nfunction dlFile(name, url) {\n return (fetch(url)\n \t.then((res) => res.text())\n \t.then((txt) => {\n \tlet contents = new Buffer(txt);\n \treturn new File({path: name, contents});\n \t})\n );\n}\n\nfunction copy() {\n let url = \"http://example.com/test.txt\";\n return (fromPromise(dlFile(\"test.txt\", url))\n .pipe(dest(\"dist\"))\n );\n}\n\ntask(copy).run();", "language": "javascript" } ] } [/block]