Initial
This commit is contained in:
93
Client/node_modules/first-chunk-stream/index.js
generated
vendored
Executable file
93
Client/node_modules/first-chunk-stream/index.js
generated
vendored
Executable file
@@ -0,0 +1,93 @@
|
||||
'use strict';
|
||||
var util = require('util');
|
||||
var Transform = require('stream').Transform;
|
||||
|
||||
function ctor(options, transform) {
|
||||
util.inherits(FirstChunk, Transform);
|
||||
|
||||
if (typeof options === 'function') {
|
||||
transform = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (typeof transform !== 'function') {
|
||||
throw new Error('transform function required');
|
||||
}
|
||||
|
||||
function FirstChunk(options2) {
|
||||
if (!(this instanceof FirstChunk)) {
|
||||
return new FirstChunk(options2);
|
||||
}
|
||||
|
||||
Transform.call(this, options2);
|
||||
|
||||
this._firstChunk = true;
|
||||
this._transformCalled = false;
|
||||
this._minSize = options.minSize;
|
||||
}
|
||||
|
||||
FirstChunk.prototype._transform = function (chunk, enc, cb) {
|
||||
this._enc = enc;
|
||||
|
||||
if (this._firstChunk) {
|
||||
this._firstChunk = false;
|
||||
|
||||
if (this._minSize == null) {
|
||||
transform.call(this, chunk, enc, cb);
|
||||
this._transformCalled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this._buffer = chunk;
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._minSize == null) {
|
||||
this.push(chunk);
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._buffer.length < this._minSize) {
|
||||
this._buffer = Buffer.concat([this._buffer, chunk]);
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._buffer.length >= this._minSize) {
|
||||
transform.call(this, this._buffer.slice(), enc, function () {
|
||||
this.push(chunk);
|
||||
cb();
|
||||
}.bind(this));
|
||||
this._transformCalled = true;
|
||||
this._buffer = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.push(chunk);
|
||||
cb();
|
||||
};
|
||||
|
||||
FirstChunk.prototype._flush = function (cb) {
|
||||
if (!this._buffer) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._transformCalled) {
|
||||
this.push(this._buffer);
|
||||
cb();
|
||||
} else {
|
||||
transform.call(this, this._buffer.slice(), this._enc, cb);
|
||||
}
|
||||
};
|
||||
|
||||
return FirstChunk;
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
return ctor.apply(ctor, arguments)();
|
||||
};
|
||||
|
||||
module.exports.ctor = ctor;
|
||||
68
Client/node_modules/first-chunk-stream/package.json
generated
vendored
Executable file
68
Client/node_modules/first-chunk-stream/package.json
generated
vendored
Executable file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"_from": "first-chunk-stream@^1.0.0",
|
||||
"_id": "first-chunk-stream@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=",
|
||||
"_location": "/first-chunk-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "first-chunk-stream@^1.0.0",
|
||||
"name": "first-chunk-stream",
|
||||
"escapedName": "first-chunk-stream",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/strip-bom-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz",
|
||||
"_shasum": "59bfb50cd905f60d7c394cd3d9acaab4e6ad934e",
|
||||
"_spec": "first-chunk-stream@^1.0.0",
|
||||
"_where": "/home/nathan/Projects/Upsilon/UpsilonVsCodeLanguageServer/Client/node_modules/strip-bom-stream",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "http://sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/first-chunk-stream/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Transform the first chunk in a stream",
|
||||
"devDependencies": {
|
||||
"concat-stream": "^1.4.5",
|
||||
"mocha": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/first-chunk-stream#readme",
|
||||
"keywords": [
|
||||
"buffer",
|
||||
"stream",
|
||||
"streams",
|
||||
"transform",
|
||||
"first",
|
||||
"chunk",
|
||||
"size",
|
||||
"min",
|
||||
"minimum"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "first-chunk-stream",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/first-chunk-stream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
62
Client/node_modules/first-chunk-stream/readme.md
generated
vendored
Executable file
62
Client/node_modules/first-chunk-stream/readme.md
generated
vendored
Executable file
@@ -0,0 +1,62 @@
|
||||
# first-chunk-stream [](https://travis-ci.org/sindresorhus/first-chunk-stream)
|
||||
|
||||
> Transform the first chunk in a stream
|
||||
|
||||
Useful if you want to do something to the first chunk.
|
||||
|
||||
You can also set the minimum size of that chunk.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save first-chunk-stream
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var fs = require('fs');
|
||||
var concat = require('concat-stream');
|
||||
var firstChunk = require('first-chunk-stream');
|
||||
|
||||
// unicorn.txt => unicorn rainbow
|
||||
// `highWaterMark: 1` means it will only read 1 byte at the time
|
||||
fs.createReadStream('unicorn.txt', {highWaterMark: 1})
|
||||
.pipe(firstChunk({minSize: 7}, function (chunk, enc, cb) {
|
||||
this.push(chunk.toUpperCase());
|
||||
cb();
|
||||
}))
|
||||
.pipe(concat(function (data) {
|
||||
console.log(data);
|
||||
//=> UNICORN rainbow
|
||||
}));
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### firstChunk([options], transform)
|
||||
|
||||
#### options.minSize
|
||||
|
||||
Type: `number`
|
||||
|
||||
The minimum size of the first chunk.
|
||||
|
||||
#### transform(chunk, encoding, callback)
|
||||
|
||||
*Required*
|
||||
Type: `function`
|
||||
|
||||
The [function](http://nodejs.org/docs/latest/api/stream.html#stream_transform_transform_chunk_encoding_callback) that gets the first chunk.
|
||||
|
||||
### firstChunk.ctor()
|
||||
|
||||
Instead of returning a [stream.Transform](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform_1) instance, `firstChunk.ctor()` returns a constructor for a custom Transform. This is useful when you want to use the same transform logic in multiple instances.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
Reference in New Issue
Block a user