Install yarn
This commit is contained in:
parent
0453e84836
commit
1fde8a81be
1927 changed files with 82144 additions and 83317 deletions
3
node_modules/gulp-header/node_modules/map-stream/.npmignore
generated
vendored
3
node_modules/gulp-header/node_modules/map-stream/.npmignore
generated
vendored
|
@ -1,3 +0,0 @@
|
|||
node_modules
|
||||
node_modules/*
|
||||
npm_debug.log
|
4
node_modules/gulp-header/node_modules/map-stream/.travis.yml
generated
vendored
4
node_modules/gulp-header/node_modules/map-stream/.travis.yml
generated
vendored
|
@ -1,4 +0,0 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
24
node_modules/gulp-header/node_modules/map-stream/LICENCE
generated
vendored
24
node_modules/gulp-header/node_modules/map-stream/LICENCE
generated
vendored
|
@ -1,24 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011 Dominic Tarr
|
||||
|
||||
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.
|
26
node_modules/gulp-header/node_modules/map-stream/examples/pretty.js
generated
vendored
26
node_modules/gulp-header/node_modules/map-stream/examples/pretty.js
generated
vendored
|
@ -1,26 +0,0 @@
|
|||
|
||||
var inspect = require('util').inspect
|
||||
|
||||
if(!module.parent) {
|
||||
var map = require('..') //load map-stream
|
||||
var es = require('event-stream') //load event-stream
|
||||
es.pipe( //pipe joins streams together
|
||||
process.openStdin(), //open stdin
|
||||
es.split(), //split stream to break on newlines
|
||||
map(function (data, callback) { //turn this async function into a stream
|
||||
var j
|
||||
try {
|
||||
j = JSON.parse(data) //try to parse input into json
|
||||
} catch (err) {
|
||||
return callback(null, data) //if it fails just pass it anyway
|
||||
}
|
||||
callback(null, inspect(j)) //render it nicely
|
||||
}),
|
||||
process.stdout // pipe it to stdout !
|
||||
)
|
||||
}
|
||||
|
||||
// run this
|
||||
//
|
||||
// curl -sS registry.npmjs.org/event-stream | node pretty.js
|
||||
//
|
144
node_modules/gulp-header/node_modules/map-stream/index.js
generated
vendored
144
node_modules/gulp-header/node_modules/map-stream/index.js
generated
vendored
|
@ -1,144 +0,0 @@
|
|||
//filter will reemit the data if cb(err,pass) pass is truthy
|
||||
|
||||
// reduce is more tricky
|
||||
// maybe we want to group the reductions or emit progress updates occasionally
|
||||
// the most basic reduce just emits one 'data' event after it has recieved 'end'
|
||||
|
||||
|
||||
var Stream = require('stream').Stream
|
||||
|
||||
|
||||
//create an event stream and apply function to each .write
|
||||
//emitting each response as data
|
||||
//unless it's an empty callback
|
||||
|
||||
module.exports = function (mapper, opts) {
|
||||
|
||||
var stream = new Stream()
|
||||
, inputs = 0
|
||||
, outputs = 0
|
||||
, ended = false
|
||||
, paused = false
|
||||
, destroyed = false
|
||||
, lastWritten = 0
|
||||
, inNext = false
|
||||
|
||||
opts = opts || {};
|
||||
var errorEventName = opts.failures ? 'failure' : 'error';
|
||||
|
||||
// Items that are not ready to be written yet (because they would come out of
|
||||
// order) get stuck in a queue for later.
|
||||
var writeQueue = {}
|
||||
|
||||
stream.writable = true
|
||||
stream.readable = true
|
||||
|
||||
function queueData (data, number) {
|
||||
var nextToWrite = lastWritten + 1
|
||||
|
||||
if (number === nextToWrite) {
|
||||
// If it's next, and its not undefined write it
|
||||
if (data !== undefined) {
|
||||
stream.emit.apply(stream, ['data', data])
|
||||
}
|
||||
lastWritten ++
|
||||
nextToWrite ++
|
||||
} else {
|
||||
// Otherwise queue it for later.
|
||||
writeQueue[number] = data
|
||||
}
|
||||
|
||||
// If the next value is in the queue, write it
|
||||
if (writeQueue.hasOwnProperty(nextToWrite)) {
|
||||
var dataToWrite = writeQueue[nextToWrite]
|
||||
delete writeQueue[nextToWrite]
|
||||
return queueData(dataToWrite, nextToWrite)
|
||||
}
|
||||
|
||||
outputs ++
|
||||
if(inputs === outputs) {
|
||||
if(paused) paused = false, stream.emit('drain') //written all the incoming events
|
||||
if(ended) end()
|
||||
}
|
||||
}
|
||||
|
||||
function next (err, data, number) {
|
||||
if(destroyed) return
|
||||
inNext = true
|
||||
|
||||
if (!err || opts.failures) {
|
||||
queueData(data, number)
|
||||
}
|
||||
|
||||
if (err) {
|
||||
stream.emit.apply(stream, [ errorEventName, err ]);
|
||||
}
|
||||
|
||||
inNext = false;
|
||||
}
|
||||
|
||||
// Wrap the mapper function by calling its callback with the order number of
|
||||
// the item in the stream.
|
||||
function wrappedMapper (input, number, callback) {
|
||||
return mapper.call(null, input, function(err, data){
|
||||
callback(err, data, number)
|
||||
})
|
||||
}
|
||||
|
||||
stream.write = function (data) {
|
||||
if(ended) throw new Error('map stream is not writable')
|
||||
inNext = false
|
||||
inputs ++
|
||||
|
||||
try {
|
||||
//catch sync errors and handle them like async errors
|
||||
var written = wrappedMapper(data, inputs, next)
|
||||
paused = (written === false)
|
||||
return !paused
|
||||
} catch (err) {
|
||||
//if the callback has been called syncronously, and the error
|
||||
//has occured in an listener, throw it again.
|
||||
if(inNext)
|
||||
throw err
|
||||
next(err)
|
||||
return !paused
|
||||
}
|
||||
}
|
||||
|
||||
function end (data) {
|
||||
//if end was called with args, write it,
|
||||
ended = true //write will emit 'end' if ended is true
|
||||
stream.writable = false
|
||||
if(data !== undefined) {
|
||||
return queueData(data, inputs)
|
||||
} else if (inputs == outputs) { //wait for processing
|
||||
stream.readable = false, stream.emit('end'), stream.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
stream.end = function (data) {
|
||||
if(ended) return
|
||||
end(data)
|
||||
}
|
||||
|
||||
stream.destroy = function () {
|
||||
ended = destroyed = true
|
||||
stream.writable = stream.readable = paused = false
|
||||
process.nextTick(function () {
|
||||
stream.emit('close')
|
||||
})
|
||||
}
|
||||
stream.pause = function () {
|
||||
paused = true
|
||||
}
|
||||
|
||||
stream.resume = function () {
|
||||
paused = false
|
||||
}
|
||||
|
||||
return stream
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
59
node_modules/gulp-header/node_modules/map-stream/package.json
generated
vendored
59
node_modules/gulp-header/node_modules/map-stream/package.json
generated
vendored
|
@ -1,59 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"map-stream@0.0.7",
|
||||
"F:\\laragon\\www\\wishthis"
|
||||
]
|
||||
],
|
||||
"_from": "map-stream@0.0.7",
|
||||
"_id": "map-stream@0.0.7",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ih8HiW2CsQkmvTdEokIACfiJdKg=",
|
||||
"_location": "/gulp-header/map-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "map-stream@0.0.7",
|
||||
"name": "map-stream",
|
||||
"escapedName": "map-stream",
|
||||
"rawSpec": "0.0.7",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.0.7"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gulp-header"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.7.tgz",
|
||||
"_spec": "0.0.7",
|
||||
"_where": "F:\\laragon\\www\\wishthis",
|
||||
"author": {
|
||||
"name": "Dominic Tarr",
|
||||
"email": "dominic.tarr@gmail.com",
|
||||
"url": "http://dominictarr.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/dominictarr/map-stream/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "construct pipes of streams of events",
|
||||
"devDependencies": {
|
||||
"asynct": "*",
|
||||
"event-stream": "~2.1",
|
||||
"from": "0.0.2",
|
||||
"it-is": "1",
|
||||
"stream-spec": "~0.2",
|
||||
"ubelt": "~2.9"
|
||||
},
|
||||
"homepage": "http://github.com/dominictarr/map-stream",
|
||||
"license": "MIT",
|
||||
"name": "map-stream",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dominictarr/map-stream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "asynct test/"
|
||||
},
|
||||
"version": "0.0.7"
|
||||
}
|
37
node_modules/gulp-header/node_modules/map-stream/readme.markdown
generated
vendored
37
node_modules/gulp-header/node_modules/map-stream/readme.markdown
generated
vendored
|
@ -1,37 +0,0 @@
|
|||
# MapStream
|
||||
|
||||
Refactored out of [event-stream](https://github.com/dominictarr/event-stream)
|
||||
|
||||
##map (asyncFunction[, options])
|
||||
|
||||
Create a through stream from an asyncronous function.
|
||||
|
||||
``` js
|
||||
var map = require('map-stream')
|
||||
|
||||
map(function (data, callback) {
|
||||
//transform data
|
||||
// ...
|
||||
callback(null, data)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
Each map MUST call the callback. It may callback with data, with an error or with no arguments,
|
||||
|
||||
* `callback()` drop this data.
|
||||
this makes the map work like `filter`,
|
||||
note:`callback(null,null)` is not the same, and will emit `null`
|
||||
|
||||
* `callback(null, newData)` turn data into newData
|
||||
|
||||
* `callback(error)` emit an error for this item.
|
||||
|
||||
>Note: if a callback is not called, `map` will think that it is still being processed,
|
||||
>every call must be answered or the stream will not know when to end.
|
||||
>
|
||||
>Also, if the callback is called more than once, every call but the first will be ignored.
|
||||
|
||||
##Options
|
||||
|
||||
* `failures` - `boolean` continue mapping even if error occured. On error `map-stream` will emit `failure` event. (default: `false`)
|
318
node_modules/gulp-header/node_modules/map-stream/test/simple-map.asynct.js
generated
vendored
318
node_modules/gulp-header/node_modules/map-stream/test/simple-map.asynct.js
generated
vendored
|
@ -1,318 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var map = require('../')
|
||||
, it = require('it-is')
|
||||
, u = require('ubelt')
|
||||
, spec = require('stream-spec')
|
||||
, from = require('from')
|
||||
, Stream = require('stream')
|
||||
, es = require('event-stream')
|
||||
|
||||
//REFACTOR THIS TEST TO USE es.readArray and es.writeArray
|
||||
|
||||
function writeArray(array, stream) {
|
||||
|
||||
array.forEach( function (j) {
|
||||
stream.write(j)
|
||||
})
|
||||
stream.end()
|
||||
|
||||
}
|
||||
|
||||
function readStream(stream, done) {
|
||||
|
||||
var array = []
|
||||
stream.on('data', function (data) {
|
||||
array.push(data)
|
||||
})
|
||||
stream.on('error', done)
|
||||
stream.on('end', function (data) {
|
||||
done(null, array)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//call sink on each write,
|
||||
//and complete when finished.
|
||||
|
||||
function pauseStream (prob, delay) {
|
||||
var pauseIf = (
|
||||
'number' == typeof prob
|
||||
? function () {
|
||||
return Math.random() < prob
|
||||
}
|
||||
: 'function' == typeof prob
|
||||
? prob
|
||||
: 0.1
|
||||
)
|
||||
var delayer = (
|
||||
!delay
|
||||
? process.nextTick
|
||||
: 'number' == typeof delay
|
||||
? function (next) { setTimeout(next, delay) }
|
||||
: delay
|
||||
)
|
||||
|
||||
return es.through(function (data) {
|
||||
if(!this.paused && pauseIf()) {
|
||||
console.log('PAUSE STREAM PAUSING')
|
||||
this.pause()
|
||||
var self = this
|
||||
delayer(function () {
|
||||
console.log('PAUSE STREAM RESUMING')
|
||||
self.resume()
|
||||
})
|
||||
}
|
||||
console.log("emit ('data', " + data + ')')
|
||||
this.emit('data', data)
|
||||
})
|
||||
}
|
||||
|
||||
exports ['simple map applied to a stream'] = function (test) {
|
||||
|
||||
var input = [1,2,3,7,5,3,1,9,0,2,4,6]
|
||||
//create event stream from
|
||||
|
||||
var doubler = map(function (data, cb) {
|
||||
cb(null, data * 2)
|
||||
})
|
||||
|
||||
spec(doubler).through().validateOnExit()
|
||||
|
||||
//a map is only a middle man, so it is both readable and writable
|
||||
|
||||
it(doubler).has({
|
||||
readable: true,
|
||||
writable: true,
|
||||
})
|
||||
|
||||
readStream(doubler, function (err, output) {
|
||||
it(output).deepEqual(input.map(function (j) {
|
||||
return j * 2
|
||||
}))
|
||||
// process.nextTick(x.validate)
|
||||
test.done()
|
||||
})
|
||||
|
||||
writeArray(input, doubler)
|
||||
|
||||
}
|
||||
|
||||
exports ['stream comes back in the correct order'] = function (test) {
|
||||
var input = [3, 2, 1]
|
||||
|
||||
var delayer = map(function(data, cb){
|
||||
setTimeout(function () {
|
||||
cb(null, data)
|
||||
}, 100 * data)
|
||||
})
|
||||
|
||||
readStream(delayer, function (err, output) {
|
||||
it(output).deepEqual(input)
|
||||
test.done()
|
||||
})
|
||||
|
||||
writeArray(input, delayer)
|
||||
}
|
||||
|
||||
exports ['continues on error event with failures `true`'] = function (test) {
|
||||
var input = [1, 2, 3]
|
||||
|
||||
var delayer = map(function(data, cb){
|
||||
cb(new Error('Something gone wrong'), data)
|
||||
}, { failures: true })
|
||||
|
||||
readStream(delayer, function (err, output) {
|
||||
it(output).deepEqual(input)
|
||||
test.done()
|
||||
})
|
||||
|
||||
writeArray(input, delayer)
|
||||
}
|
||||
|
||||
exports['pipe two maps together'] = function (test) {
|
||||
|
||||
var input = [1,2,3,7,5,3,1,9,0,2,4,6]
|
||||
//create event stream from
|
||||
function dd (data, cb) {
|
||||
cb(null, data * 2)
|
||||
}
|
||||
var doubler1 = map(dd), doubler2 = map(dd)
|
||||
|
||||
doubler1.pipe(doubler2)
|
||||
|
||||
spec(doubler1).through().validateOnExit()
|
||||
spec(doubler2).through().validateOnExit()
|
||||
|
||||
readStream(doubler2, function (err, output) {
|
||||
it(output).deepEqual(input.map(function (j) {
|
||||
return j * 4
|
||||
}))
|
||||
test.done()
|
||||
})
|
||||
|
||||
writeArray(input, doubler1)
|
||||
|
||||
}
|
||||
|
||||
//next:
|
||||
//
|
||||
// test pause, resume and drian.
|
||||
//
|
||||
|
||||
// then make a pipe joiner:
|
||||
//
|
||||
// plumber (evStr1, evStr2, evStr3, evStr4, evStr5)
|
||||
//
|
||||
// will return a single stream that write goes to the first
|
||||
|
||||
exports ['map will not call end until the callback'] = function (test) {
|
||||
|
||||
var ticker = map(function (data, cb) {
|
||||
process.nextTick(function () {
|
||||
cb(null, data * 2)
|
||||
})
|
||||
})
|
||||
|
||||
spec(ticker).through().validateOnExit()
|
||||
|
||||
ticker.write('x')
|
||||
ticker.end()
|
||||
|
||||
ticker.on('end', function () {
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
|
||||
exports ['emit failures with opts.failures === `ture`'] = function (test) {
|
||||
|
||||
var err = new Error('INTENSIONAL ERROR')
|
||||
, mapper =
|
||||
map(function () {
|
||||
throw err
|
||||
}, { failures: true })
|
||||
|
||||
mapper.on('failure', function (_err) {
|
||||
it(_err).equal(err)
|
||||
test.done()
|
||||
})
|
||||
|
||||
mapper.write('hello')
|
||||
|
||||
}
|
||||
|
||||
exports ['emit error thrown'] = function (test) {
|
||||
|
||||
var err = new Error('INTENSIONAL ERROR')
|
||||
, mapper =
|
||||
map(function () {
|
||||
throw err
|
||||
})
|
||||
|
||||
mapper.on('error', function (_err) {
|
||||
it(_err).equal(err)
|
||||
test.done()
|
||||
})
|
||||
|
||||
mapper.write('hello')
|
||||
|
||||
}
|
||||
|
||||
exports ['emit error calledback'] = function (test) {
|
||||
|
||||
var err = new Error('INTENSIONAL ERROR')
|
||||
, mapper =
|
||||
map(function (data, callback) {
|
||||
callback(err)
|
||||
})
|
||||
|
||||
mapper.on('error', function (_err) {
|
||||
it(_err).equal(err)
|
||||
test.done()
|
||||
})
|
||||
|
||||
mapper.write('hello')
|
||||
|
||||
}
|
||||
|
||||
exports ['do not emit drain if not paused'] = function (test) {
|
||||
|
||||
var maps = map(function (data, callback) {
|
||||
u.delay(callback)(null, 1)
|
||||
return true
|
||||
})
|
||||
|
||||
spec(maps).through().pausable().validateOnExit()
|
||||
|
||||
maps.on('drain', function () {
|
||||
it(false).ok('should not emit drain unless the stream is paused')
|
||||
})
|
||||
|
||||
it(maps.write('hello')).equal(true)
|
||||
it(maps.write('hello')).equal(true)
|
||||
it(maps.write('hello')).equal(true)
|
||||
setTimeout(function () {maps.end()},10)
|
||||
maps.on('end', test.done)
|
||||
}
|
||||
|
||||
exports ['emits drain if paused, when all '] = function (test) {
|
||||
var active = 0
|
||||
var drained = false
|
||||
var maps = map(function (data, callback) {
|
||||
active ++
|
||||
u.delay(function () {
|
||||
active --
|
||||
callback(null, 1)
|
||||
})()
|
||||
console.log('WRITE', false)
|
||||
return false
|
||||
})
|
||||
|
||||
spec(maps).through().validateOnExit()
|
||||
|
||||
maps.on('drain', function () {
|
||||
drained = true
|
||||
it(active).equal(0, 'should emit drain when all maps are done')
|
||||
})
|
||||
|
||||
it(maps.write('hello')).equal(false)
|
||||
it(maps.write('hello')).equal(false)
|
||||
it(maps.write('hello')).equal(false)
|
||||
|
||||
process.nextTick(function () {maps.end()},10)
|
||||
|
||||
maps.on('end', function () {
|
||||
console.log('end')
|
||||
it(drained).ok('shoud have emitted drain before end')
|
||||
test.done()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
exports ['map applied to a stream with filtering'] = function (test) {
|
||||
|
||||
var input = [1,2,3,7,5,3,1,9,0,2,4,6]
|
||||
|
||||
var doubler = map(function (data, callback) {
|
||||
if (data % 2)
|
||||
callback(null, data * 2)
|
||||
else
|
||||
callback()
|
||||
})
|
||||
|
||||
readStream(doubler, function (err, output) {
|
||||
it(output).deepEqual(input.filter(function (j) {
|
||||
return j % 2
|
||||
}).map(function (j) {
|
||||
return j * 2
|
||||
}))
|
||||
test.done()
|
||||
})
|
||||
|
||||
spec(doubler).through().validateOnExit()
|
||||
|
||||
writeArray(input, doubler)
|
||||
|
||||
}
|
||||
|
||||
|
9
node_modules/gulp-header/node_modules/through2/LICENSE.md
generated
vendored
9
node_modules/gulp-header/node_modules/through2/LICENSE.md
generated
vendored
|
@ -1,9 +0,0 @@
|
|||
# The MIT License (MIT)
|
||||
|
||||
**Copyright (c) Rod Vagg (the "Original Author") and additional contributors**
|
||||
|
||||
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.
|
134
node_modules/gulp-header/node_modules/through2/README.md
generated
vendored
134
node_modules/gulp-header/node_modules/through2/README.md
generated
vendored
|
@ -1,134 +0,0 @@
|
|||
# through2
|
||||
|
||||
[](https://nodei.co/npm/through2/)
|
||||
|
||||
**A tiny wrapper around Node streams.Transform (Streams2/3) to avoid explicit subclassing noise**
|
||||
|
||||
Inspired by [Dominic Tarr](https://github.com/dominictarr)'s [through](https://github.com/dominictarr/through) in that it's so much easier to make a stream out of a function than it is to set up the prototype chain properly: `through(function (chunk) { ... })`.
|
||||
|
||||
Note: As 2.x.x this module starts using **Streams3** instead of Stream2. To continue using a Streams2 version use `npm install through2@0` to fetch the latest version of 0.x.x. More information about Streams2 vs Streams3 and recommendations see the article **[Why I don't use Node's core 'stream' module](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html)**.
|
||||
|
||||
```js
|
||||
fs.createReadStream('ex.txt')
|
||||
.pipe(through2(function (chunk, enc, callback) {
|
||||
for (var i = 0; i < chunk.length; i++)
|
||||
if (chunk[i] == 97)
|
||||
chunk[i] = 122 // swap 'a' for 'z'
|
||||
|
||||
this.push(chunk)
|
||||
|
||||
callback()
|
||||
}))
|
||||
.pipe(fs.createWriteStream('out.txt'))
|
||||
.on('finish', () => doSomethingSpecial())
|
||||
```
|
||||
|
||||
Or object streams:
|
||||
|
||||
```js
|
||||
var all = []
|
||||
|
||||
fs.createReadStream('data.csv')
|
||||
.pipe(csv2())
|
||||
.pipe(through2.obj(function (chunk, enc, callback) {
|
||||
var data = {
|
||||
name : chunk[0]
|
||||
, address : chunk[3]
|
||||
, phone : chunk[10]
|
||||
}
|
||||
this.push(data)
|
||||
|
||||
callback()
|
||||
}))
|
||||
.on('data', (data) => {
|
||||
all.push(data)
|
||||
})
|
||||
.on('end', () => {
|
||||
doSomethingSpecial(all)
|
||||
})
|
||||
```
|
||||
|
||||
Note that `through2.obj(fn)` is a convenience wrapper around `through2({ objectMode: true }, fn)`.
|
||||
|
||||
## API
|
||||
|
||||
<b><code>through2([ options, ] [ transformFunction ] [, flushFunction ])</code></b>
|
||||
|
||||
Consult the **[stream.Transform](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform)** documentation for the exact rules of the `transformFunction` (i.e. `this._transform`) and the optional `flushFunction` (i.e. `this._flush`).
|
||||
|
||||
### options
|
||||
|
||||
The options argument is optional and is passed straight through to `stream.Transform`. So you can use `objectMode:true` if you are processing non-binary streams (or just use `through2.obj()`).
|
||||
|
||||
The `options` argument is first, unlike standard convention, because if I'm passing in an anonymous function then I'd prefer for the options argument to not get lost at the end of the call:
|
||||
|
||||
```js
|
||||
fs.createReadStream('/tmp/important.dat')
|
||||
.pipe(through2({ objectMode: true, allowHalfOpen: false },
|
||||
(chunk, enc, cb) => {
|
||||
cb(null, 'wut?') // note we can use the second argument on the callback
|
||||
// to provide data as an alternative to this.push('wut?')
|
||||
}
|
||||
)
|
||||
.pipe(fs.createWriteStream('/tmp/wut.txt'))
|
||||
```
|
||||
|
||||
### transformFunction
|
||||
|
||||
The `transformFunction` must have the following signature: `function (chunk, encoding, callback) {}`. A minimal implementation should call the `callback` function to indicate that the transformation is done, even if that transformation means discarding the chunk.
|
||||
|
||||
To queue a new chunk, call `this.push(chunk)`—this can be called as many times as required before the `callback()` if you have multiple pieces to send on.
|
||||
|
||||
Alternatively, you may use `callback(err, chunk)` as shorthand for emitting a single chunk or an error.
|
||||
|
||||
If you **do not provide a `transformFunction`** then you will get a simple pass-through stream.
|
||||
|
||||
### flushFunction
|
||||
|
||||
The optional `flushFunction` is provided as the last argument (2nd or 3rd, depending on whether you've supplied options) is called just prior to the stream ending. Can be used to finish up any processing that may be in progress.
|
||||
|
||||
```js
|
||||
fs.createReadStream('/tmp/important.dat')
|
||||
.pipe(through2(
|
||||
(chunk, enc, cb) => cb(null, chunk), // transform is a noop
|
||||
function (cb) { // flush function
|
||||
this.push('tacking on an extra buffer to the end');
|
||||
cb();
|
||||
}
|
||||
))
|
||||
.pipe(fs.createWriteStream('/tmp/wut.txt'));
|
||||
```
|
||||
|
||||
<b><code>through2.ctor([ options, ] transformFunction[, flushFunction ])</code></b>
|
||||
|
||||
Instead of returning a `stream.Transform` instance, `through2.ctor()` returns a **constructor** for a custom Transform. This is useful when you want to use the same transform logic in multiple instances.
|
||||
|
||||
```js
|
||||
var FToC = through2.ctor({objectMode: true}, function (record, encoding, callback) {
|
||||
if (record.temp != null && record.unit == "F") {
|
||||
record.temp = ( ( record.temp - 32 ) * 5 ) / 9
|
||||
record.unit = "C"
|
||||
}
|
||||
this.push(record)
|
||||
callback()
|
||||
})
|
||||
|
||||
// Create instances of FToC like so:
|
||||
var converter = new FToC()
|
||||
// Or:
|
||||
var converter = FToC()
|
||||
// Or specify/override options when you instantiate, if you prefer:
|
||||
var converter = FToC({objectMode: true})
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
- [through2-map](https://github.com/brycebaril/through2-map) - Array.prototype.map analog for streams.
|
||||
- [through2-filter](https://github.com/brycebaril/through2-filter) - Array.prototype.filter analog for streams.
|
||||
- [through2-reduce](https://github.com/brycebaril/through2-reduce) - Array.prototype.reduce analog for streams.
|
||||
- [through2-spy](https://github.com/brycebaril/through2-spy) - Wrapper for simple stream.PassThrough spies.
|
||||
- the [mississippi stream utility collection](https://github.com/maxogden/mississippi) includes `through2` as well as many more useful stream modules similar to this one
|
||||
|
||||
## License
|
||||
|
||||
**through2** is Copyright (c) Rod Vagg [@rvagg](https://twitter.com/rvagg) and additional contributors and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
69
node_modules/gulp-header/node_modules/through2/package.json
generated
vendored
69
node_modules/gulp-header/node_modules/through2/package.json
generated
vendored
|
@ -1,69 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"through2@2.0.5",
|
||||
"F:\\laragon\\www\\wishthis"
|
||||
]
|
||||
],
|
||||
"_from": "through2@2.0.5",
|
||||
"_id": "through2@2.0.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
|
||||
"_location": "/gulp-header/through2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "through2@2.0.5",
|
||||
"name": "through2",
|
||||
"escapedName": "through2",
|
||||
"rawSpec": "2.0.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gulp-header"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
|
||||
"_spec": "2.0.5",
|
||||
"_where": "F:\\laragon\\www\\wishthis",
|
||||
"author": {
|
||||
"name": "Rod Vagg",
|
||||
"email": "r@va.gg",
|
||||
"url": "https://github.com/rvagg"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/rvagg/through2/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"readable-stream": "~2.3.6",
|
||||
"xtend": "~4.0.1"
|
||||
},
|
||||
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",
|
||||
"devDependencies": {
|
||||
"bl": "~2.0.1",
|
||||
"faucet": "0.0.1",
|
||||
"nyc": "~13.1.0",
|
||||
"safe-buffer": "~5.1.2",
|
||||
"stream-spigot": "~3.0.6",
|
||||
"tape": "~4.9.1"
|
||||
},
|
||||
"homepage": "https://github.com/rvagg/through2#readme",
|
||||
"keywords": [
|
||||
"stream",
|
||||
"streams2",
|
||||
"through",
|
||||
"transform"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "through2.js",
|
||||
"name": "through2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rvagg/through2.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js | faucet"
|
||||
},
|
||||
"version": "2.0.5"
|
||||
}
|
96
node_modules/gulp-header/node_modules/through2/through2.js
generated
vendored
96
node_modules/gulp-header/node_modules/through2/through2.js
generated
vendored
|
@ -1,96 +0,0 @@
|
|||
var Transform = require('readable-stream').Transform
|
||||
, inherits = require('util').inherits
|
||||
, xtend = require('xtend')
|
||||
|
||||
function DestroyableTransform(opts) {
|
||||
Transform.call(this, opts)
|
||||
this._destroyed = false
|
||||
}
|
||||
|
||||
inherits(DestroyableTransform, Transform)
|
||||
|
||||
DestroyableTransform.prototype.destroy = function(err) {
|
||||
if (this._destroyed) return
|
||||
this._destroyed = true
|
||||
|
||||
var self = this
|
||||
process.nextTick(function() {
|
||||
if (err)
|
||||
self.emit('error', err)
|
||||
self.emit('close')
|
||||
})
|
||||
}
|
||||
|
||||
// a noop _transform function
|
||||
function noop (chunk, enc, callback) {
|
||||
callback(null, chunk)
|
||||
}
|
||||
|
||||
|
||||
// create a new export function, used by both the main export and
|
||||
// the .ctor export, contains common logic for dealing with arguments
|
||||
function through2 (construct) {
|
||||
return function (options, transform, flush) {
|
||||
if (typeof options == 'function') {
|
||||
flush = transform
|
||||
transform = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
if (typeof transform != 'function')
|
||||
transform = noop
|
||||
|
||||
if (typeof flush != 'function')
|
||||
flush = null
|
||||
|
||||
return construct(options, transform, flush)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// main export, just make me a transform stream!
|
||||
module.exports = through2(function (options, transform, flush) {
|
||||
var t2 = new DestroyableTransform(options)
|
||||
|
||||
t2._transform = transform
|
||||
|
||||
if (flush)
|
||||
t2._flush = flush
|
||||
|
||||
return t2
|
||||
})
|
||||
|
||||
|
||||
// make me a reusable prototype that I can `new`, or implicitly `new`
|
||||
// with a constructor call
|
||||
module.exports.ctor = through2(function (options, transform, flush) {
|
||||
function Through2 (override) {
|
||||
if (!(this instanceof Through2))
|
||||
return new Through2(override)
|
||||
|
||||
this.options = xtend(options, override)
|
||||
|
||||
DestroyableTransform.call(this, this.options)
|
||||
}
|
||||
|
||||
inherits(Through2, DestroyableTransform)
|
||||
|
||||
Through2.prototype._transform = transform
|
||||
|
||||
if (flush)
|
||||
Through2.prototype._flush = flush
|
||||
|
||||
return Through2
|
||||
})
|
||||
|
||||
|
||||
module.exports.obj = through2(function (options, transform, flush) {
|
||||
var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options))
|
||||
|
||||
t2._transform = transform
|
||||
|
||||
if (flush)
|
||||
t2._flush = flush
|
||||
|
||||
return t2
|
||||
})
|
102
node_modules/gulp-header/package.json
generated
vendored
102
node_modules/gulp-header/package.json
generated
vendored
|
@ -1,43 +1,42 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"gulp-header@2.0.9",
|
||||
"F:\\laragon\\www\\wishthis"
|
||||
]
|
||||
],
|
||||
"_from": "gulp-header@2.0.9",
|
||||
"_id": "gulp-header@2.0.9",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-LMGiBx+qH8giwrOuuZXSGvswcIUh0OiioNkUpLhNyvaC6/Ga8X6cfAeme2L5PqsbXMhL8o8b/OmVqIQdxprhcQ==",
|
||||
"_location": "/gulp-header",
|
||||
"_phantomChildren": {
|
||||
"readable-stream": "2.3.7",
|
||||
"xtend": "4.0.2"
|
||||
"name": "gulp-header",
|
||||
"version": "2.0.9",
|
||||
"description": "Gulp extension to add header to file(s) in the pipeline.",
|
||||
"main": "./index.js",
|
||||
"proxy": null,
|
||||
"https-proxy": null,
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "gulp-header@2.0.9",
|
||||
"name": "gulp-header",
|
||||
"escapedName": "gulp-header",
|
||||
"rawSpec": "2.0.9",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.9"
|
||||
"jshintConfig": {
|
||||
"esversion": 8,
|
||||
"strict": "implied",
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"mocha": true,
|
||||
"node": true
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/fomantic-ui"
|
||||
"scripts": {
|
||||
"pretest": "jshint *.js test",
|
||||
"test": "mocha --reporter spec",
|
||||
"publish-major": "npm version major && git push origin master && git push --tags",
|
||||
"publish-minor": "npm version minor && git push origin master && git push --tags",
|
||||
"publish-patch": "npm version patch && git push origin master && git push --tags"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/tracker1/gulp-header.git"
|
||||
},
|
||||
"keywords": [
|
||||
"header",
|
||||
"gulpplugin",
|
||||
"eventstream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gulp-header/-/gulp-header-2.0.9.tgz",
|
||||
"_spec": "2.0.9",
|
||||
"_where": "F:\\laragon\\www\\wishthis",
|
||||
"author": {
|
||||
"name": "Michael J. Ryan",
|
||||
"email": "tracker1@gmail.com",
|
||||
"url": "http://github.com/tracker1"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/tracker1/gulp-header/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "GoDaddy.com",
|
||||
|
@ -49,52 +48,21 @@
|
|||
"url": "http://github.com/douglasduteil"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/tracker1/gulp-header/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"concat-with-sourcemaps": "^1.1.0",
|
||||
"lodash.template": "^4.5.0",
|
||||
"map-stream": "0.0.7",
|
||||
"through2": "^2.0.0"
|
||||
},
|
||||
"description": "Gulp extension to add header to file(s) in the pipeline.",
|
||||
"devDependencies": {
|
||||
"gulp": "^4.0.0",
|
||||
"jshint": "*",
|
||||
"mocha": "*",
|
||||
"should": "*",
|
||||
"vinyl": "*"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"homepage": "https://github.com/tracker1/gulp-header#readme",
|
||||
"https-proxy": null,
|
||||
"jshintConfig": {
|
||||
"esversion": 8,
|
||||
"strict": "implied",
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"mocha": true,
|
||||
"node": true
|
||||
},
|
||||
"keywords": [
|
||||
"header",
|
||||
"gulpplugin",
|
||||
"eventstream"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./index.js",
|
||||
"name": "gulp-header",
|
||||
"proxy": null,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/tracker1/gulp-header.git"
|
||||
},
|
||||
"scripts": {
|
||||
"pretest": "jshint *.js test",
|
||||
"publish-major": "npm version major && git push origin master && git push --tags",
|
||||
"publish-minor": "npm version minor && git push origin master && git push --tags",
|
||||
"publish-patch": "npm version patch && git push origin master && git push --tags",
|
||||
"test": "mocha --reporter spec"
|
||||
},
|
||||
"version": "2.0.9"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue