commit
This commit is contained in:
parent
be4fd23bcf
commit
0bd53741af
728 changed files with 86573 additions and 0 deletions
13
node_modules/sandwich-stream/.editorconfig
generated
vendored
Normal file
13
node_modules/sandwich-stream/.editorconfig
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
13
node_modules/sandwich-stream/LICENCE
generated
vendored
Normal file
13
node_modules/sandwich-stream/LICENCE
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
Copyright 2013 Paul Connolley (connrs)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
58
node_modules/sandwich-stream/README.md
generated
vendored
Normal file
58
node_modules/sandwich-stream/README.md
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
# SandwichStream
|
||||
|
||||
[](https://www.npmjs.com/package/sandwich-stream)
|
||||
[](https://www.npmjs.com/package/sandwich-stream)
|
||||
[](https://travis-ci.org/connrs/node-sandwich-stream)
|
||||
[](https://codecov.io/gh/connrs/node-sandwich-stream)
|
||||
[](https://www.codacy.com/project/connrs/node-sandwich-stream/dashboard?utm_source=github.com&utm_medium=referral&utm_content=connrs/node-sandwich-stream&utm_campaign=Badge_Grade_Dashboard)
|
||||
[](https://codeclimate.com/github/connrs/node-sandwich-stream/master/package.json)
|
||||
[](https://snyk.io/test/github/connrs/node-sandwich-stream?targetFile=package.json)
|
||||
[](https://codeclimate.com/github/connrs/node-sandwich-stream/maintainability)
|
||||
|
||||
## About
|
||||
While I'm not overjoyed about how performant the internals will operate, I wanted a readable stream that was ACTUALLY A READABLE STREAM. Not a streams1 stream masquerading as streams2. As soon as somebody writes a better concat stream as a readable stream with a nice simple API, this baby is going to develop some serious abandonment issues.
|
||||
|
||||
## Installation
|
||||
```bash
|
||||
npm install sandwich-stream --save
|
||||
```
|
||||
|
||||
**note**: this code was made using it [TypeScript](https://www.typescriptlang.org/), and its typings are linked in [package.json](./package.json), so there's no need of installing _@types/sandwich-stream_ or anything related.
|
||||
|
||||
## Usage
|
||||
```typescript
|
||||
import { SandwichStream } from 'sandwich-stream';
|
||||
// OR EVEN:
|
||||
// const SandwichStream = require('sandwich-stream');
|
||||
|
||||
const sandwich = SandwichStream({
|
||||
head: 'Thing at the top\n',
|
||||
tail: '\nThing at the bottom',
|
||||
separator: '\n ---- \n'
|
||||
});
|
||||
|
||||
sandwich.add(aStreamIPreparedEarlier)
|
||||
.add(anotherStreamIPreparedEarlier)
|
||||
.add(aFurtherStreamIPreparedEarlier)
|
||||
.pipe(process.stdout);
|
||||
|
||||
// The thing at the top
|
||||
// ----
|
||||
// Stream1
|
||||
// ----
|
||||
// Stream2
|
||||
// ----
|
||||
// Stream3
|
||||
// The thing at the bottom
|
||||
```
|
||||
## Configuration Options
|
||||
* `head` option takes a string/buffer and pushes the string before all other content
|
||||
* `foot` option takes a string/buffer and pushes the string after all other data has been pushed
|
||||
* `separator` option pushes a string/buffer between each stream
|
||||
* [Readable Options](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/be662c475da091788139b486a55708f02e2880b6/types/node/index.d.ts#L6485) can also be passed through.
|
||||
|
||||
## API
|
||||
Too add a stream use the **.add** method: `sandwich.add(streamVariable);`
|
||||
|
||||
## More
|
||||
Wanna known more about Node Streams? Read [this](https://medium.freecodecamp.org/node-js-streams-everything-you-need-to-know-c9141306be93).
|
107
node_modules/sandwich-stream/dist/sandwich-stream.d.ts
generated
vendored
Normal file
107
node_modules/sandwich-stream/dist/sandwich-stream.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
/// <reference types="node" />
|
||||
import { Readable, ReadableOptions } from 'stream';
|
||||
/**
|
||||
* Sandwich Options that will configure parsed data
|
||||
*/
|
||||
export interface SandwichOptions extends ReadableOptions {
|
||||
readonly head?: string | Buffer;
|
||||
readonly tail?: string | Buffer;
|
||||
readonly separator?: string | Buffer;
|
||||
}
|
||||
/**
|
||||
* Handles Readable streams requests as concatenation through data handling as
|
||||
* well adding tags it each begin, end and between of the streams
|
||||
*/
|
||||
export declare class SandwichStream extends Readable {
|
||||
private streamsActive;
|
||||
private streams;
|
||||
private newStreams;
|
||||
private head;
|
||||
private tail;
|
||||
private separator;
|
||||
private currentStream;
|
||||
/**
|
||||
* Initiates the SandwichStream, you can consider it also passing
|
||||
* ReadableOptions to it
|
||||
*
|
||||
* @param head Pushes this content before all other content
|
||||
* @param tail Pushes this content after all other data has been pushed
|
||||
* @param separator Pushes this content between each stream
|
||||
* @param remaining The other kind of options to be passed to Readable
|
||||
* @example
|
||||
* const ss = new SandwichStream({
|
||||
* head: 'This at the top\n',
|
||||
* tail: '\nThis at the bottom',
|
||||
* separator: '\n --- \n'
|
||||
* });
|
||||
*/
|
||||
constructor({ head, tail, separator, ...remaining }: SandwichOptions);
|
||||
/**
|
||||
* Add a new Readable stream in the queue
|
||||
*
|
||||
* @param newStream The Readable stream
|
||||
* @example
|
||||
* sandwichStream.add(streamOne);
|
||||
* sandwichStream.add(streamTwo);
|
||||
* sandwichStream.add(streamThree);
|
||||
* @throws An Error in case that this request was not accepted
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
add(newStream: Readable): this;
|
||||
/**
|
||||
* Works in a similar way from the Readable read, only that this one checks
|
||||
* for whether or not a stream is already being handled
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
_read(): void;
|
||||
/**
|
||||
* Binds an error thrown from one of the streams being handled
|
||||
*
|
||||
* @param err Error to be bind
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
private subStreamOnError;
|
||||
/**
|
||||
* Fetches the next stream to be handled
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
private streamNextStream;
|
||||
/**
|
||||
* Verifies whether or not the stream queue has ended
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
private nextStream;
|
||||
/**
|
||||
* Once the current stream starts to pass their data, this handles it in a
|
||||
* less complicated way
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
private bindCurrentStreamEvents;
|
||||
/**
|
||||
* Handles the data from a current stream once they are being streamed
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
private currentStreamOnReadable;
|
||||
/**
|
||||
* Handles the tagging once a stream is finished
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
private currentStreamOnEnd;
|
||||
/**
|
||||
* Adds the head tag to the Sandwich Stream
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
private pushHead;
|
||||
/**
|
||||
* Adds the separator tag to the Sandwich Stream
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
private pushSeparator;
|
||||
/**
|
||||
* Adds the tail tag to the Sandwich Stream
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
private pushTail;
|
||||
}
|
||||
export default SandwichStream;
|
||||
//# sourceMappingURL=sandwich-stream.d.ts.map
|
1
node_modules/sandwich-stream/dist/sandwich-stream.d.ts.map
generated
vendored
Normal file
1
node_modules/sandwich-stream/dist/sandwich-stream.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"sandwich-stream.d.ts","sourceRoot":"","sources":["src/sandwich-stream.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACpD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxC;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IACxC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,aAAa,CAAyB;IAE9C;;;;;;;;;;;;;;OAcG;gBACS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE,eAAe;IAQpE;;;;;;;;;;OAUG;IACI,GAAG,CAAC,SAAS,EAAE,QAAQ,GAAG,IAAI;IAWrC;;;;OAIG;IACI,KAAK,IAAI,IAAI;IAQpB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IASxB;;;OAGG;IACH,OAAO,CAAC,UAAU;IAOlB;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAK/B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAO/B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAMhB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAMrB;;;OAGG;IACH,OAAO,CAAC,QAAQ;CAKnB;AAED,eAAe,cAAc,CAAC"}
|
185
node_modules/sandwich-stream/dist/sandwich-stream.js
generated
vendored
Normal file
185
node_modules/sandwich-stream/dist/sandwich-stream.js
generated
vendored
Normal file
|
@ -0,0 +1,185 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var stream = require('stream');
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
function __rest(s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
||||
t[p[i]] = s[p[i]];
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles Readable streams requests as concatenation through data handling as
|
||||
* well adding tags it each begin, end and between of the streams
|
||||
*/
|
||||
class SandwichStream extends stream.Readable {
|
||||
/**
|
||||
* Initiates the SandwichStream, you can consider it also passing
|
||||
* ReadableOptions to it
|
||||
*
|
||||
* @param head Pushes this content before all other content
|
||||
* @param tail Pushes this content after all other data has been pushed
|
||||
* @param separator Pushes this content between each stream
|
||||
* @param remaining The other kind of options to be passed to Readable
|
||||
* @example
|
||||
* const ss = new SandwichStream({
|
||||
* head: 'This at the top\n',
|
||||
* tail: '\nThis at the bottom',
|
||||
* separator: '\n --- \n'
|
||||
* });
|
||||
*/
|
||||
constructor(_a) {
|
||||
var { head, tail, separator } = _a, remaining = __rest(_a, ["head", "tail", "separator"]);
|
||||
super(remaining);
|
||||
this.streamsActive = false;
|
||||
this.streams = [];
|
||||
this.newStreams = [];
|
||||
this.currentStream = null;
|
||||
this.head = (null !== head && undefined !== head) ? head : null;
|
||||
this.tail = (null !== tail && undefined !== tail) ? tail : null;
|
||||
this.separator = (null !== separator && undefined !== separator) ? separator : null;
|
||||
}
|
||||
/**
|
||||
* Add a new Readable stream in the queue
|
||||
*
|
||||
* @param newStream The Readable stream
|
||||
* @example
|
||||
* sandwichStream.add(streamOne);
|
||||
* sandwichStream.add(streamTwo);
|
||||
* sandwichStream.add(streamThree);
|
||||
* @throws An Error in case that this request was not accepted
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
add(newStream) {
|
||||
if (false === this.streamsActive) {
|
||||
this.streams.push(newStream);
|
||||
newStream.on('error', this.subStreamOnError.bind(this));
|
||||
}
|
||||
else {
|
||||
this.newStreams.push(newStream);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Works in a similar way from the Readable read, only that this one checks
|
||||
* for whether or not a stream is already being handled
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
_read() {
|
||||
if (false === this.streamsActive) {
|
||||
this.streamsActive = true;
|
||||
this.pushHead();
|
||||
this.streamNextStream();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Binds an error thrown from one of the streams being handled
|
||||
*
|
||||
* @param err Error to be bind
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
subStreamOnError(err) {
|
||||
this.emit('error', err);
|
||||
}
|
||||
/**
|
||||
* Fetches the next stream to be handled
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
streamNextStream() {
|
||||
if (true === this.nextStream()) {
|
||||
this.bindCurrentStreamEvents();
|
||||
}
|
||||
else {
|
||||
this.pushTail();
|
||||
this.push(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Verifies whether or not the stream queue has ended
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
nextStream() {
|
||||
const tmp = this.streams.shift();
|
||||
this.currentStream = (undefined !== tmp) ? tmp : null;
|
||||
return null !== this.currentStream;
|
||||
}
|
||||
/**
|
||||
* Once the current stream starts to pass their data, this handles it in a
|
||||
* less complicated way
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
bindCurrentStreamEvents() {
|
||||
this.currentStream.on('readable', this.currentStreamOnReadable.bind(this));
|
||||
this.currentStream.on('end', this.currentStreamOnEnd.bind(this));
|
||||
}
|
||||
/**
|
||||
* Handles the data from a current stream once they are being streamed
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
currentStreamOnReadable() {
|
||||
const tmp = this.currentStream.read();
|
||||
const data = (undefined !== tmp && null !== tmp) ? tmp : '';
|
||||
this.push(data);
|
||||
}
|
||||
/**
|
||||
* Handles the tagging once a stream is finished
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
currentStreamOnEnd() {
|
||||
this.pushSeparator();
|
||||
this.streams.concat(this.newStreams);
|
||||
this.newStreams = [];
|
||||
this.streamNextStream();
|
||||
}
|
||||
/**
|
||||
* Adds the head tag to the Sandwich Stream
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
pushHead() {
|
||||
if (null !== this.head) {
|
||||
this.push(this.head);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds the separator tag to the Sandwich Stream
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
pushSeparator() {
|
||||
if (0 < this.streams.length && null !== this.separator) {
|
||||
this.push(this.separator);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds the tail tag to the Sandwich Stream
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
pushTail() {
|
||||
if (null !== this.tail) {
|
||||
this.push(this.tail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.SandwichStream = SandwichStream;
|
||||
exports.default = SandwichStream;
|
181
node_modules/sandwich-stream/dist/sandwich-stream.mjs
generated
vendored
Normal file
181
node_modules/sandwich-stream/dist/sandwich-stream.mjs
generated
vendored
Normal file
|
@ -0,0 +1,181 @@
|
|||
import { Readable } from 'stream';
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
function __rest(s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
||||
t[p[i]] = s[p[i]];
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles Readable streams requests as concatenation through data handling as
|
||||
* well adding tags it each begin, end and between of the streams
|
||||
*/
|
||||
class SandwichStream extends Readable {
|
||||
/**
|
||||
* Initiates the SandwichStream, you can consider it also passing
|
||||
* ReadableOptions to it
|
||||
*
|
||||
* @param head Pushes this content before all other content
|
||||
* @param tail Pushes this content after all other data has been pushed
|
||||
* @param separator Pushes this content between each stream
|
||||
* @param remaining The other kind of options to be passed to Readable
|
||||
* @example
|
||||
* const ss = new SandwichStream({
|
||||
* head: 'This at the top\n',
|
||||
* tail: '\nThis at the bottom',
|
||||
* separator: '\n --- \n'
|
||||
* });
|
||||
*/
|
||||
constructor(_a) {
|
||||
var { head, tail, separator } = _a, remaining = __rest(_a, ["head", "tail", "separator"]);
|
||||
super(remaining);
|
||||
this.streamsActive = false;
|
||||
this.streams = [];
|
||||
this.newStreams = [];
|
||||
this.currentStream = null;
|
||||
this.head = (null !== head && undefined !== head) ? head : null;
|
||||
this.tail = (null !== tail && undefined !== tail) ? tail : null;
|
||||
this.separator = (null !== separator && undefined !== separator) ? separator : null;
|
||||
}
|
||||
/**
|
||||
* Add a new Readable stream in the queue
|
||||
*
|
||||
* @param newStream The Readable stream
|
||||
* @example
|
||||
* sandwichStream.add(streamOne);
|
||||
* sandwichStream.add(streamTwo);
|
||||
* sandwichStream.add(streamThree);
|
||||
* @throws An Error in case that this request was not accepted
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
add(newStream) {
|
||||
if (false === this.streamsActive) {
|
||||
this.streams.push(newStream);
|
||||
newStream.on('error', this.subStreamOnError.bind(this));
|
||||
}
|
||||
else {
|
||||
this.newStreams.push(newStream);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Works in a similar way from the Readable read, only that this one checks
|
||||
* for whether or not a stream is already being handled
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
_read() {
|
||||
if (false === this.streamsActive) {
|
||||
this.streamsActive = true;
|
||||
this.pushHead();
|
||||
this.streamNextStream();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Binds an error thrown from one of the streams being handled
|
||||
*
|
||||
* @param err Error to be bind
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
subStreamOnError(err) {
|
||||
this.emit('error', err);
|
||||
}
|
||||
/**
|
||||
* Fetches the next stream to be handled
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
streamNextStream() {
|
||||
if (true === this.nextStream()) {
|
||||
this.bindCurrentStreamEvents();
|
||||
}
|
||||
else {
|
||||
this.pushTail();
|
||||
this.push(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Verifies whether or not the stream queue has ended
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
nextStream() {
|
||||
const tmp = this.streams.shift();
|
||||
this.currentStream = (undefined !== tmp) ? tmp : null;
|
||||
return null !== this.currentStream;
|
||||
}
|
||||
/**
|
||||
* Once the current stream starts to pass their data, this handles it in a
|
||||
* less complicated way
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
bindCurrentStreamEvents() {
|
||||
this.currentStream.on('readable', this.currentStreamOnReadable.bind(this));
|
||||
this.currentStream.on('end', this.currentStreamOnEnd.bind(this));
|
||||
}
|
||||
/**
|
||||
* Handles the data from a current stream once they are being streamed
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
currentStreamOnReadable() {
|
||||
const tmp = this.currentStream.read();
|
||||
const data = (undefined !== tmp && null !== tmp) ? tmp : '';
|
||||
this.push(data);
|
||||
}
|
||||
/**
|
||||
* Handles the tagging once a stream is finished
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
currentStreamOnEnd() {
|
||||
this.pushSeparator();
|
||||
this.streams.concat(this.newStreams);
|
||||
this.newStreams = [];
|
||||
this.streamNextStream();
|
||||
}
|
||||
/**
|
||||
* Adds the head tag to the Sandwich Stream
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
pushHead() {
|
||||
if (null !== this.head) {
|
||||
this.push(this.head);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds the separator tag to the Sandwich Stream
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
pushSeparator() {
|
||||
if (0 < this.streams.length && null !== this.separator) {
|
||||
this.push(this.separator);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds the tail tag to the Sandwich Stream
|
||||
* @returns This instance of Sandwich Stream
|
||||
*/
|
||||
pushTail() {
|
||||
if (null !== this.tail) {
|
||||
this.push(this.tail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default SandwichStream;
|
||||
export { SandwichStream };
|
72
node_modules/sandwich-stream/package.json
generated
vendored
Normal file
72
node_modules/sandwich-stream/package.json
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"name": "sandwich-stream",
|
||||
"version": "2.0.2",
|
||||
"description": "A readable stream that concatenates multiple streams with optional head, tail & join buffers",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/connrs/node-sandwich-stream.git"
|
||||
},
|
||||
"main": "dist/sandwich-stream",
|
||||
"module": "dist/sandwich-stream.mjs",
|
||||
"types": "dist/sandwich-stream.d.ts",
|
||||
"keywords": [
|
||||
"stream",
|
||||
"sandwich",
|
||||
"readable",
|
||||
"typescript",
|
||||
"concatenation"
|
||||
],
|
||||
"scripts": {
|
||||
"rollup:build": "rollup -c",
|
||||
"rollup:watch": "npm run rollup:build -- --watch",
|
||||
"build": "npm run rollup:build",
|
||||
"test": "snyk test && npm run jest",
|
||||
"docs": "typedoc --out ./docs/ ./src/",
|
||||
"lint": "tslint --config tslint.json --project .",
|
||||
"jest": "jest --config jest.config.json --ci --runInBand --detectOpenHandles --forceExit --no-cache"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.txt"
|
||||
}
|
||||
],
|
||||
"author": {
|
||||
"name": "connrs",
|
||||
"url": "https://connrs.uk/"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Fazendaaa",
|
||||
"email": "lucas.carotta@outlook.com",
|
||||
"url": "http://fazendaaa.me/"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^23.3.5",
|
||||
"@types/node": "^10.12.0",
|
||||
"codecov": "^3.1.0",
|
||||
"husky": "^1.1.2",
|
||||
"jest": "^23.6.0",
|
||||
"rollup": "^0.66.6",
|
||||
"rollup-plugin-typescript2": "^0.17.2",
|
||||
"snyk": "^1.104.1",
|
||||
"ts-jest": "^23.10.4",
|
||||
"ts-node": "^7.0.1",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-microsoft-contrib": "^5.2.1",
|
||||
"typedoc": "^0.13.0",
|
||||
"typescript": "^3.1.4"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-push": "npm run build && npm test",
|
||||
"pre-commit": "npm run lint && npm run docs"
|
||||
}
|
||||
}
|
||||
}
|
40
node_modules/sandwich-stream/rollup.config.js
generated
vendored
Normal file
40
node_modules/sandwich-stream/rollup.config.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
import typescript from 'rollup-plugin-typescript2';
|
||||
|
||||
import nodeOs from 'os';
|
||||
import nodePath from 'path';
|
||||
|
||||
import pkg from './package.json';
|
||||
|
||||
export default [
|
||||
{
|
||||
input: 'src/sandwich-stream.ts',
|
||||
external: [
|
||||
'stream'
|
||||
],
|
||||
plugins: [
|
||||
typescript({
|
||||
cacheRoot: nodePath.join(
|
||||
nodeOs.tmpdir(),
|
||||
String(Date.now),
|
||||
'.rpt2_cache'
|
||||
),
|
||||
tsconfigOverride: {
|
||||
compilerOptions: {
|
||||
composite: false
|
||||
}
|
||||
}
|
||||
})
|
||||
],
|
||||
output: [
|
||||
{
|
||||
file: `${pkg.main}.js`,
|
||||
format: 'cjs',
|
||||
exports: 'named'
|
||||
},
|
||||
{
|
||||
file: `${pkg.main}.mjs`,
|
||||
format: 'esm'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue