{"_id":"vinyl-bufferstream","_rev":"650875","name":"vinyl-bufferstream","description":"Deal with vinyl file contents, regardless of whether it is Buffer/Stream","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"shinnn","email":"snnskwtnb@gmail.com"}],"time":{"modified":"2021-08-26T04:42:52.000Z","created":"2015-01-20T20:11:07.028Z","1.0.1":"2015-02-11T10:02:09.046Z","1.0.0":"2015-01-20T20:39:18.283Z","0.0.0":"2015-01-20T20:11:07.028Z"},"users":{"9joneg":true,"miql":true},"author":{"name":"Shinnosuke Watanabe","url":"https://github.com/shinnn"},"repository":{"type":"git","url":"https://github.com/shinnn/vinyl-bufferstream"},"versions":{"1.0.1":{"name":"vinyl-bufferstream","version":"1.0.1","description":"Deal with vinyl file contents, regardless of whether it is Buffer/Stream","repository":{"type":"git","url":"https://github.com/shinnn/vinyl-bufferstream"},"author":{"name":"Shinnosuke Watanabe","url":"https://github.com/shinnn"},"scripts":{"pretest":"jscs *.js && eslint *.js","test":"node test.js | tap-spec","coverage":"istanbul cover test.js","coveralls":"${npm_package_scripts_coverage} && istanbul-coveralls"},"licenses":[{"type":"MIT","url":"https://github.com/shinnn/vinyl-bufferstream/blob/master/LICENSE"}],"files":["index.js"],"keywords":["gulpfriendly","gulp","vinyl","buffer","stream","compatibility","interchangeability","internal","helper"],"dependencies":{"bufferstreams":"1.0.1"},"devDependencies":{"eslint":"^0.14.1","istanbul":"^0.3.5","istanbul-coveralls":"^1.0.1","jscs":"^1.11.2","simple-bufferstream":"0.0.4","tap-spec":"^2.2.1","tape":"^3.5.0","vinyl":"^0.4.6"},"jscsConfig":{"preset":"google","maximumLineLength":98,"requireBlocksOnNewline":true,"validateLineBreaks":"LF"},"gitHead":"baaf30c5e6291c5838461902bab9098b1dcb4a30","bugs":{"url":"https://github.com/shinnn/vinyl-bufferstream/issues"},"homepage":"https://github.com/shinnn/vinyl-bufferstream","_id":"vinyl-bufferstream@1.0.1","_shasum":"0537869f580effa4ca45acb47579e4b9fe63081a","_from":".","_npmVersion":"2.5.0","_nodeVersion":"1.1.0","_npmUser":{"name":"shinnn","email":"snnskwtnb@gmail.com"},"maintainers":[{"name":"shinnn","email":"snnskwtnb@gmail.com"}],"dist":{"shasum":"0537869f580effa4ca45acb47579e4b9fe63081a","size":2963,"noattachment":false,"key":"/vinyl-bufferstream/-/vinyl-bufferstream-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/vinyl-bufferstream/download/vinyl-bufferstream-1.0.1.tgz"},"directories":{},"publish_time":1423648929046,"_cnpm_publish_time":1423648929046,"_hasShrinkwrap":false},"1.0.0":{"name":"vinyl-bufferstream","version":"1.0.0","description":"Deal with vinyl file contents, regardless of whether it is Buffer/Stream","repository":{"type":"git","url":"https://github.com/shinnn/vinyl-bufferstream"},"author":{"name":"Shinnosuke Watanabe","url":"https://github.com/shinnn"},"scripts":{"pretest":"jscs *.js && eslint *.js","test":"node test.js | tap-spec","coverage":"istanbul cover test.js","coveralls":"${npm_package_scripts_coverage} && istanbul-coveralls"},"licenses":[{"type":"MIT","url":"https://github.com/shinnn/vinyl-bufferstream/blob/master/LICENSE"}],"files":["index.js","LICENSE"],"keywords":["gulpfriendly","gulp","vinyl","buffer","stream","compatibility","interchangeability","internal","helper"],"dependencies":{"bufferstreams":"0.0.2"},"devDependencies":{"eslint":"^0.12.0","istanbul":"^0.3.5","istanbul-coveralls":"^1.0.1","jscs":"^1.10.0","simple-bufferstream":"0.0.4","tap-spec":"^2.2.0","tape":"^3.4.0","vinyl":"^0.4.6"},"jscsConfig":{"preset":"google","maximumLineLength":98,"requireBlocksOnNewline":true,"validateLineBreaks":"LF"},"gitHead":"2ade1d5cb929040c051c8fcea5fa0d92866d9ef1","bugs":{"url":"https://github.com/shinnn/vinyl-bufferstream/issues"},"homepage":"https://github.com/shinnn/vinyl-bufferstream","_id":"vinyl-bufferstream@1.0.0","_shasum":"c7bb256fa841408d6ab436cca09f1d453d7fac55","_from":".","_npmVersion":"2.1.18","_nodeVersion":"1.0.1","_npmUser":{"name":"shinnn","email":"snnskwtnb@gmail.com"},"maintainers":[{"name":"shinnn","email":"snnskwtnb@gmail.com"}],"dist":{"shasum":"c7bb256fa841408d6ab436cca09f1d453d7fac55","size":2951,"noattachment":false,"key":"/vinyl-bufferstream/-/vinyl-bufferstream-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/vinyl-bufferstream/download/vinyl-bufferstream-1.0.0.tgz"},"directories":{},"publish_time":1421786358283,"_cnpm_publish_time":1421786358283,"_hasShrinkwrap":false},"0.0.0":{"name":"vinyl-bufferstream","version":"0.0.0","description":"Deal with vinyl file contents, regardless of whether it is Buffer/Stream","repository":{"type":"git","url":"https://github.com/shinnn/vinyl-bufferstream"},"author":{"name":"Shinnosuke Watanabe","url":"https://github.com/shinnn"},"scripts":{"pretest":"jscs *.js && eslint *.js","test":"node test.js | tap-spec","coverage":"istanbul cover test.js","coveralls":"${npm_package_scripts_coverage} && istanbul-coveralls"},"licenses":[{"type":"MIT","url":"https://github.com/shinnn/vinyl-bufferstream/blob/master/LICENSE"}],"files":["index.js","LICENSE"],"keywords":["gulpfriendly","gulp","vinyl","buffer","stream","compatibility","interchangeability","internal","helper"],"dependencies":{"bufferstreams":"0.0.2"},"devDependencies":{"eslint":"^0.12.0","istanbul":"^0.3.5","istanbul-coveralls":"^1.0.1","jscs":"^1.10.0","simple-bufferstream":"0.0.4","tap-spec":"^2.2.0","tape":"^3.4.0","vinyl":"^0.4.6"},"jscsConfig":{"preset":"google","maximumLineLength":98,"requireBlocksOnNewline":true,"validateLineBreaks":"LF"},"gitHead":"a820d9c887d5a4c5b33fd706fb63f191cde26759","bugs":{"url":"https://github.com/shinnn/vinyl-bufferstream/issues"},"homepage":"https://github.com/shinnn/vinyl-bufferstream","_id":"vinyl-bufferstream@0.0.0","_shasum":"a7c4c289761254cf34209368a6eee4a13f25fd97","_from":".","_npmVersion":"2.1.18","_nodeVersion":"1.0.1","_npmUser":{"name":"shinnn","email":"snnskwtnb@gmail.com"},"maintainers":[{"name":"shinnn","email":"snnskwtnb@gmail.com"}],"dist":{"shasum":"a7c4c289761254cf34209368a6eee4a13f25fd97","size":2902,"noattachment":false,"key":"/vinyl-bufferstream/-/vinyl-bufferstream-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/vinyl-bufferstream/download/vinyl-bufferstream-0.0.0.tgz"},"directories":{},"publish_time":1421784667028,"_cnpm_publish_time":1421784667028,"_hasShrinkwrap":false}},"readme":"# vinyl-bufferstream\n\n[![NPM version](https://img.shields.io/npm/v/vinyl-bufferstream.svg?style=flat)](https://www.npmjs.com/package/vinyl-bufferstream)\n[![Build Status](https://img.shields.io/travis/shinnn/vinyl-bufferstream.svg?style=flat)](https://travis-ci.org/shinnn/vinyl-bufferstream)\n[![Build status](https://ci.appveyor.com/api/projects/status/gqc8t4mju49p6fkn?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/vinyl-bufferstream)\n[![Coverage Status](https://img.shields.io/coveralls/shinnn/vinyl-bufferstream.svg?style=flat)](https://coveralls.io/r/shinnn/vinyl-bufferstream)\n[![Dependency Status](https://img.shields.io/david/shinnn/vinyl-bufferstream.svg?style=flat&label=deps)](https://david-dm.org/shinnn/vinyl-bufferstream)\n[![devDependency Status](https://img.shields.io/david/dev/shinnn/vinyl-bufferstream.svg?style=flat&label=devDeps)](https://david-dm.org/shinnn/vinyl-bufferstream#info=devDependencies)\n\nDeal with [vinyl file](https://github.com/wearefractal/vinyl) contents, regardless of whether it is Buffer/Stream\n\n```javascript\nvar through = require('through2');\nvar VinylBufferStream = require('vinyl-bufferstream');\n\nfunction yourGulpPlugin() {\n  var vinylBufferStream = new VinylBufferStream(function(buf, done) {\n    syncOrAsyncFn(buf, done); \n  });\n\n  return through.obj(function(file, enc, cb) {\n    vinylBufferStream(file, function(err, contents) {\n      if (err) {\n        self.emit('error', err);\n      } else {\n        file.contents = contents;\n        self.push(file);\n      }\n      cb();\n    });\n  });\n}\n```\n\n## Installation\n\n[Use npm.](https://docs.npmjs.com/cli/install)\n\n```sh\nnpm install vinyl-bufferstream\n```\n\n## API\n\n```javascript\nvar VinylBufferStream = require('vinyl-bufferstream');\n```\n\n### vinylBufferStream = new VinylBufferStream(*transformFunction*)\n\n(`new` operator is optional.)\n\n*transformFunction*: `Function`  \nReturn: `Function`\n\nThe argument must be a function taking a [`Buffer`][buffer] and a callback function as its first and second argument, which calls the callback function with passing [Node](http://nodejs.org/)-style callback arguments (`error, result`).\n\n#### vinylBufferStream(*file*, *callback*)\n\n*file*: `Object` ([vinyl file](https://github.com/wearefractal/vinyl#file) object)  \n*callback*: `Function`\n\nWhen the [`file.contents`](https://github.com/wearefractal/vinyl#optionscontents) is a [`Buffer`][buffer], it will call the *transformFunction* with passing file.contents to the first argument.\n\nWhen the `file.contents` is a [`Stream`][buffer], it will call the *transformFunction* with passing the buffered stream of file.contents to the first argument.\n\nWhen the `file.contents` is a [`Stream`][stream], it won't call the *transformFunction*.\n\n##### callback(err, contents)\n\n*error*: `Error` or `null`  \n*contents*: [`Buffer`][buffer] or [`Stream`][stream]\n\nWhen the `file.contents` is a [`Buffer`][buffer], *contents* will be a result that *transformFunction* produces.\n\nWhen the `file.contents` is a [`Stream`][stream], *contents* will be a stream that emits a data *transformFunction* produces.\n\nWhen the `file.contents` is `null`, *contents* will be `null`.\n\n```javascript\nvar gulp = require('gulp');\nvar SVGO = require('svgo');\nvar through = require('through2');\nvar VinylBufferStream = require('vinyl-bufferstream');\n\nfunction svgminPlugin(options) {\n  var svgo = new SVGO(options);\n  var vinylBufferStream = new VinylBufferStream(function(buf, done) {\n    svgo.optimize(String(buf), function(result) {\n      if (result.error) {\n        done(result.error);\n        return;\n      }\n      done(null, result.data);\n    });\n  });\n\n  return through.obj(function(file, enc, cb) {\n    vinylBufferStream(file, function(err, contents) {\n      if (err) {\n        self.emit('error', err);\n      } else {\n        file.contents = contents;\n        self.push(file);\n      }\n      cb();\n    });\n  });\n}\n\ngulp.task('buffer', function() {\n  return gulp.src('*.svg')\n    .pipe(svgminPlugin())\n    .pipe(gulp.dest('dest'));\n});\n\ngulp.task('stream', function() {\n  return gulp.src('*.svg', {buffer: false})\n    .pipe(svgminPlugin())\n    .pipe(gulp.dest('dest'));\n});\n```\n\n## License\n\nCopyright (c) 2014 - 2015 [Shinnosuke Watanabe](https://github.com/shinnn)\n\nLicensed under [the MIT License](./LICENSE).\n\n[buffer]: https://iojs.org/api/buffer.html#buffer_class_buffer\n[stream]: https://iojs.org/api/stream.html\n","_attachments":{},"homepage":"https://github.com/shinnn/vinyl-bufferstream","bugs":{"url":"https://github.com/shinnn/vinyl-bufferstream/issues"}}