Initial import with skill sheet working
This commit is contained in:
21
node_modules/to-through/LICENSE
generated
vendored
Normal file
21
node_modules/to-through/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017, 2020-2021 Blaine Bublitz <blaine.bublitz@gmail.com> and Eric Schoffstall <yo@contra.io>
|
||||
|
||||
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.
|
55
node_modules/to-through/README.md
generated
vendored
Normal file
55
node_modules/to-through/README.md
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<p align="center">
|
||||
<a href="http://gulpjs.com">
|
||||
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# to-through
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
|
||||
|
||||
Wrap a `Readable` stream in a `Transform` stream.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var { Readable } = require('streamx');
|
||||
var concat = require('concat-stream');
|
||||
var toThrough = require('to-through');
|
||||
|
||||
var readable = Readable.from([' ', 'hello', ' ', 'world']);
|
||||
|
||||
// Can be used as a Readable or Transform
|
||||
var maybeTransform = toThrough(readable);
|
||||
|
||||
Readable.from(['hi', ' ', 'there', ','])
|
||||
.pipe(maybeTransform)
|
||||
.pipe(
|
||||
concat(function (result) {
|
||||
// result === 'hi there, hello world'
|
||||
})
|
||||
);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `toThrough(readableStream)`
|
||||
|
||||
Takes a `Readable` stream as the only argument and returns a `Transform` stream wrapper. Any data
|
||||
piped into the `Transform` stream is piped passed along before any data from the wrapped `Readable` is injected into the stream.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
[downloads-image]: https://img.shields.io/npm/dm/to-through.svg?style=flat-square
|
||||
[npm-url]: https://www.npmjs.com/package/to-through
|
||||
[npm-image]: https://img.shields.io/npm/v/to-through.svg?style=flat-square
|
||||
|
||||
[ci-url]: https://github.com/gulpjs/to-through/actions?query=workflow:dev
|
||||
[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/to-through/dev?style=flat-square
|
||||
|
||||
[coveralls-url]: https://coveralls.io/r/gulpjs/to-through
|
||||
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/to-through/master.svg?style=flat-square
|
||||
<!-- prettier-ignore-end -->
|
134
node_modules/to-through/index.js
generated
vendored
Normal file
134
node_modules/to-through/index.js
generated
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
'use strict';
|
||||
|
||||
var Transform = require('streamx').Transform;
|
||||
|
||||
// Based on help from @mafintosh via https://gist.github.com/mafintosh/92836a8d03df0ef41356e233e0f06382
|
||||
|
||||
function toThrough(readable) {
|
||||
var highWaterMark = readable._readableState.highWaterMark;
|
||||
|
||||
// Streamx uses 16384 as the default highWaterMark for everything and then
|
||||
// divides it by 1024 for objects
|
||||
// However, node's objectMode streams the number of objects as highWaterMark, so we need to
|
||||
// multiply the objectMode highWaterMark by 1024 to make it streamx compatible
|
||||
if (readable._readableState.objectMode) {
|
||||
highWaterMark = readable._readableState.highWaterMark * 1024;
|
||||
}
|
||||
|
||||
var destroyedByError = false;
|
||||
var readableClosed = false;
|
||||
var readableEnded = false;
|
||||
|
||||
function flush(cb) {
|
||||
var self = this;
|
||||
|
||||
// Afer all writes have drained, we change the `_read` implementation
|
||||
self._read = function (cb) {
|
||||
readable.resume();
|
||||
cb();
|
||||
};
|
||||
|
||||
readable.on('data', onData);
|
||||
readable.once('error', onError);
|
||||
readable.once('end', onEnd);
|
||||
|
||||
function cleanup() {
|
||||
readable.off('data', onData);
|
||||
readable.off('error', onError);
|
||||
readable.off('end', onEnd);
|
||||
}
|
||||
|
||||
function onData(data) {
|
||||
var drained = self.push(data);
|
||||
// When the stream is not drained, we pause it because `_read` will be called later
|
||||
if (!drained) {
|
||||
readable.pause();
|
||||
}
|
||||
}
|
||||
|
||||
function onError(err) {
|
||||
cleanup();
|
||||
cb(err);
|
||||
}
|
||||
|
||||
function onEnd() {
|
||||
cleanup();
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the case where a user destroyed the returned stream
|
||||
function predestroy() {
|
||||
// Only call destroy on the readable if this `predestroy` wasn't
|
||||
// caused via the readable having an `error` or `close` event
|
||||
if (destroyedByError) {
|
||||
return;
|
||||
}
|
||||
if (readableClosed) {
|
||||
return;
|
||||
}
|
||||
readable.destroy(new Error('Wrapper destroyed'));
|
||||
}
|
||||
|
||||
var wrapper = new Transform({
|
||||
highWaterMark: highWaterMark,
|
||||
flush: flush,
|
||||
predestroy: predestroy,
|
||||
});
|
||||
|
||||
// Forward errors from the underlying stream
|
||||
readable.once('error', onError);
|
||||
readable.once('end', onEnd);
|
||||
readable.once('close', onClose);
|
||||
|
||||
function onError(err) {
|
||||
destroyedByError = true;
|
||||
wrapper.destroy(err);
|
||||
}
|
||||
|
||||
function onEnd() {
|
||||
readableEnded = true;
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
readableClosed = true;
|
||||
// Only destroy the wrapper if the readable hasn't ended successfully
|
||||
if (!readableEnded) {
|
||||
wrapper.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
var shouldFlow = true;
|
||||
wrapper.once('pipe', onPipe);
|
||||
wrapper.on('piping', onPiping);
|
||||
wrapper.on('newListener', onListener);
|
||||
|
||||
function onPiping() {
|
||||
maybeFlow();
|
||||
wrapper.off('piping', onPiping);
|
||||
wrapper.off('newListener', onListener);
|
||||
}
|
||||
|
||||
function onListener(event) {
|
||||
// Once we've seen the data or readable event, check if we need to flow
|
||||
if (event === 'data' || event === 'readable') {
|
||||
onPiping();
|
||||
}
|
||||
}
|
||||
|
||||
function onPipe() {
|
||||
// If the wrapper is piped, disable flow
|
||||
shouldFlow = false;
|
||||
}
|
||||
|
||||
function maybeFlow() {
|
||||
// If we need to flow, end the stream which triggers flush
|
||||
if (shouldFlow) {
|
||||
wrapper.end();
|
||||
}
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
module.exports = toThrough;
|
51
node_modules/to-through/package.json
generated
vendored
Normal file
51
node_modules/to-through/package.json
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "to-through",
|
||||
"version": "3.0.0",
|
||||
"description": "Wrap a Readable stream in a Transform stream.",
|
||||
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
|
||||
"contributors": [
|
||||
"Blaine Bublitz <blaine.bublitz@gmail.com>"
|
||||
],
|
||||
"repository": "gulpjs/to-through",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"pretest": "npm run lint",
|
||||
"test": "nyc mocha --async-only"
|
||||
},
|
||||
"dependencies": {
|
||||
"streamx": "^2.12.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-gulp": "^5.0.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"expect": "^27.4.2",
|
||||
"mocha": "^8.4.0",
|
||||
"nyc": "^15.1.0",
|
||||
"readable-stream": "^3.6.0"
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"lcov",
|
||||
"text-summary"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
},
|
||||
"keywords": [
|
||||
"transform",
|
||||
"readable",
|
||||
"through",
|
||||
"wrap"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user