clear
This commit is contained in:
20
node_modules/vinyl-bufferstream/LICENSE
generated
vendored
Normal file
20
node_modules/vinyl-bufferstream/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 - 2015 Shinnosuke Watanabe
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
131
node_modules/vinyl-bufferstream/README.md
generated
vendored
Normal file
131
node_modules/vinyl-bufferstream/README.md
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
# vinyl-bufferstream
|
||||
|
||||
[](https://www.npmjs.com/package/vinyl-bufferstream)
|
||||
[](https://travis-ci.org/shinnn/vinyl-bufferstream)
|
||||
[](https://ci.appveyor.com/project/ShinnosukeWatanabe/vinyl-bufferstream)
|
||||
[](https://coveralls.io/r/shinnn/vinyl-bufferstream)
|
||||
[](https://david-dm.org/shinnn/vinyl-bufferstream)
|
||||
[](https://david-dm.org/shinnn/vinyl-bufferstream#info=devDependencies)
|
||||
|
||||
Deal with [vinyl file](https://github.com/wearefractal/vinyl) contents, regardless of whether it is Buffer/Stream
|
||||
|
||||
```javascript
|
||||
var through = require('through2');
|
||||
var VinylBufferStream = require('vinyl-bufferstream');
|
||||
|
||||
function yourGulpPlugin() {
|
||||
var vinylBufferStream = new VinylBufferStream(function(buf, done) {
|
||||
syncOrAsyncFn(buf, done);
|
||||
});
|
||||
|
||||
return through.obj(function(file, enc, cb) {
|
||||
vinylBufferStream(file, function(err, contents) {
|
||||
if (err) {
|
||||
self.emit('error', err);
|
||||
} else {
|
||||
file.contents = contents;
|
||||
self.push(file);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
[Use npm.](https://docs.npmjs.com/cli/install)
|
||||
|
||||
```sh
|
||||
npm install vinyl-bufferstream
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```javascript
|
||||
var VinylBufferStream = require('vinyl-bufferstream');
|
||||
```
|
||||
|
||||
### vinylBufferStream = new VinylBufferStream(*transformFunction*)
|
||||
|
||||
(`new` operator is optional.)
|
||||
|
||||
*transformFunction*: `Function`
|
||||
Return: `Function`
|
||||
|
||||
The 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`).
|
||||
|
||||
#### vinylBufferStream(*file*, *callback*)
|
||||
|
||||
*file*: `Object` ([vinyl file](https://github.com/wearefractal/vinyl#file) object)
|
||||
*callback*: `Function`
|
||||
|
||||
When 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.
|
||||
|
||||
When the `file.contents` is a [`Stream`][buffer], it will call the *transformFunction* with passing the buffered stream of file.contents to the first argument.
|
||||
|
||||
When the `file.contents` is a [`Stream`][stream], it won't call the *transformFunction*.
|
||||
|
||||
##### callback(err, contents)
|
||||
|
||||
*error*: `Error` or `null`
|
||||
*contents*: [`Buffer`][buffer] or [`Stream`][stream]
|
||||
|
||||
When the `file.contents` is a [`Buffer`][buffer], *contents* will be a result that *transformFunction* produces.
|
||||
|
||||
When the `file.contents` is a [`Stream`][stream], *contents* will be a stream that emits a data *transformFunction* produces.
|
||||
|
||||
When the `file.contents` is `null`, *contents* will be `null`.
|
||||
|
||||
```javascript
|
||||
var gulp = require('gulp');
|
||||
var SVGO = require('svgo');
|
||||
var through = require('through2');
|
||||
var VinylBufferStream = require('vinyl-bufferstream');
|
||||
|
||||
function svgminPlugin(options) {
|
||||
var svgo = new SVGO(options);
|
||||
var vinylBufferStream = new VinylBufferStream(function(buf, done) {
|
||||
svgo.optimize(String(buf), function(result) {
|
||||
if (result.error) {
|
||||
done(result.error);
|
||||
return;
|
||||
}
|
||||
done(null, result.data);
|
||||
});
|
||||
});
|
||||
|
||||
return through.obj(function(file, enc, cb) {
|
||||
vinylBufferStream(file, function(err, contents) {
|
||||
if (err) {
|
||||
self.emit('error', err);
|
||||
} else {
|
||||
file.contents = contents;
|
||||
self.push(file);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('buffer', function() {
|
||||
return gulp.src('*.svg')
|
||||
.pipe(svgminPlugin())
|
||||
.pipe(gulp.dest('dest'));
|
||||
});
|
||||
|
||||
gulp.task('stream', function() {
|
||||
return gulp.src('*.svg', {buffer: false})
|
||||
.pipe(svgminPlugin())
|
||||
.pipe(gulp.dest('dest'));
|
||||
});
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2014 - 2015 [Shinnosuke Watanabe](https://github.com/shinnn)
|
||||
|
||||
Licensed under [the MIT License](./LICENSE).
|
||||
|
||||
[buffer]: https://iojs.org/api/buffer.html#buffer_class_buffer
|
||||
[stream]: https://iojs.org/api/stream.html
|
||||
52
node_modules/vinyl-bufferstream/index.js
generated
vendored
Normal file
52
node_modules/vinyl-bufferstream/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/*!
|
||||
* vinyl-bufferstream | MIT (c) Shinnosuke Watanabe
|
||||
* https://github.com/shinnn/vinyl-bufferstream
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var BufferStreams = require('bufferstreams');
|
||||
|
||||
module.exports = function VinylBufferStream(fn) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError(
|
||||
fn +
|
||||
' is not a function. The argument to VinylBufferStream constructor must be a function.'
|
||||
);
|
||||
}
|
||||
|
||||
return function vinylBufferStream(file, cb) {
|
||||
if (typeof cb !== 'function') {
|
||||
throw new TypeError(
|
||||
cb +
|
||||
' is not a function. ' +
|
||||
'The second argument to VinylBufferStream instance must be a function.'
|
||||
);
|
||||
}
|
||||
|
||||
if (!file || typeof file.isNull !== 'function') {
|
||||
cb(new TypeError('Expecting a vinyl file object.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.isNull()) {
|
||||
cb(null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.isStream()) {
|
||||
var stream = file.contents.pipe(new BufferStreams(function(none, buf, done) {
|
||||
fn(buf, function(err, result) {
|
||||
done(err, result);
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
cb(null, stream);
|
||||
});
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
fn(file.contents, cb);
|
||||
};
|
||||
};
|
||||
118
node_modules/vinyl-bufferstream/package.json
generated
vendored
Normal file
118
node_modules/vinyl-bufferstream/package.json
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "vinyl-bufferstream@^1.0.1",
|
||||
"scope": null,
|
||||
"escapedName": "vinyl-bufferstream",
|
||||
"name": "vinyl-bufferstream",
|
||||
"rawSpec": "^1.0.1",
|
||||
"spec": ">=1.0.1 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"D:\\web\\layui\\res\\layui\\node_modules\\gulp-minify-css"
|
||||
]
|
||||
],
|
||||
"_from": "vinyl-bufferstream@>=1.0.1 <2.0.0",
|
||||
"_id": "vinyl-bufferstream@1.0.1",
|
||||
"_inCache": true,
|
||||
"_location": "/vinyl-bufferstream",
|
||||
"_nodeVersion": "1.1.0",
|
||||
"_npmUser": {
|
||||
"name": "shinnn",
|
||||
"email": "snnskwtnb@gmail.com"
|
||||
},
|
||||
"_npmVersion": "2.5.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "vinyl-bufferstream@^1.0.1",
|
||||
"scope": null,
|
||||
"escapedName": "vinyl-bufferstream",
|
||||
"name": "vinyl-bufferstream",
|
||||
"rawSpec": "^1.0.1",
|
||||
"spec": ">=1.0.1 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gulp-minify-css"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/vinyl-bufferstream/-/vinyl-bufferstream-1.0.1.tgz",
|
||||
"_shasum": "0537869f580effa4ca45acb47579e4b9fe63081a",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "vinyl-bufferstream@^1.0.1",
|
||||
"_where": "D:\\web\\layui\\res\\layui\\node_modules\\gulp-minify-css",
|
||||
"author": {
|
||||
"name": "Shinnosuke Watanabe",
|
||||
"url": "https://github.com/shinnn"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/shinnn/vinyl-bufferstream/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"bufferstreams": "1.0.1"
|
||||
},
|
||||
"description": "Deal with vinyl file contents, regardless of whether it is Buffer/Stream",
|
||||
"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"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "0537869f580effa4ca45acb47579e4b9fe63081a",
|
||||
"tarball": "https://registry.npmjs.org/vinyl-bufferstream/-/vinyl-bufferstream-1.0.1.tgz"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "baaf30c5e6291c5838461902bab9098b1dcb4a30",
|
||||
"homepage": "https://github.com/shinnn/vinyl-bufferstream",
|
||||
"jscsConfig": {
|
||||
"preset": "google",
|
||||
"maximumLineLength": 98,
|
||||
"requireBlocksOnNewline": true,
|
||||
"validateLineBreaks": "LF"
|
||||
},
|
||||
"keywords": [
|
||||
"gulpfriendly",
|
||||
"gulp",
|
||||
"vinyl",
|
||||
"buffer",
|
||||
"stream",
|
||||
"compatibility",
|
||||
"interchangeability",
|
||||
"internal",
|
||||
"helper"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/shinnn/vinyl-bufferstream/blob/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "shinnn",
|
||||
"email": "snnskwtnb@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "vinyl-bufferstream",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/shinnn/vinyl-bufferstream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "istanbul cover test.js",
|
||||
"coveralls": "${npm_package_scripts_coverage} && istanbul-coveralls",
|
||||
"pretest": "jscs *.js && eslint *.js",
|
||||
"test": "node test.js | tap-spec"
|
||||
},
|
||||
"version": "1.0.1"
|
||||
}
|
||||
Reference in New Issue
Block a user