mirror of
https://github.com/shimataro/ssh-key-action.git
synced 2025-06-22 23:02:10 +10:00
* first action!
This commit is contained in:
parent
8deacc95b1
commit
4e3aad3b7f
3750 changed files with 1155519 additions and 0 deletions
59
node_modules/stream-each/index.js
generated
vendored
Normal file
59
node_modules/stream-each/index.js
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
var eos = require('end-of-stream')
|
||||
var shift = require('stream-shift')
|
||||
|
||||
module.exports = each
|
||||
|
||||
function each (stream, fn, cb) {
|
||||
var want = true
|
||||
var error = null
|
||||
var ended = false
|
||||
var running = false
|
||||
var calling = false
|
||||
|
||||
stream.on('readable', onreadable)
|
||||
onreadable()
|
||||
|
||||
if (cb) eos(stream, {readable: true, writable: false}, done)
|
||||
return stream
|
||||
|
||||
function done (err) {
|
||||
if (!error) error = err
|
||||
ended = true
|
||||
if (!running) cb(error)
|
||||
}
|
||||
|
||||
function onreadable () {
|
||||
if (want) read()
|
||||
}
|
||||
|
||||
function afterRead (err) {
|
||||
running = false
|
||||
|
||||
if (err) {
|
||||
error = err
|
||||
if (ended) return cb(error)
|
||||
stream.destroy(err)
|
||||
return
|
||||
}
|
||||
if (ended) return cb(error)
|
||||
if (!calling) read()
|
||||
}
|
||||
|
||||
function read () {
|
||||
while (!running && !ended) {
|
||||
want = false
|
||||
|
||||
var data = shift(stream)
|
||||
if (ended) return
|
||||
if (data === null) {
|
||||
want = true
|
||||
return
|
||||
}
|
||||
|
||||
running = true
|
||||
calling = true
|
||||
fn(data, afterRead)
|
||||
calling = false
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue