Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
continue-stream
Advanced tools
Lazily merge multiple streams in to a single stream. continueStream
can also
be thought of as a pagination stream.
npm install continue-stream
Pass continueStream
a function that provides a new stream to it's callback.
This function will be called on initialization and after each stream has ended.
If the callback is called without any arguments the continueStream
will end.
var continueStream = require('continue-stream')
var request = require('request')
var page = 1
function next(callback, previousStream) {
if (page >= 4) return callback()
var stream = request({
url: 'https://api.github.com/repos/joyent/node/events?page=' + (page++),
headers: {'user-agent': 'pug'}
})
callback(null, stream)
}
continueStream(next)
.pipe(process.stdout)
Or you can use continueStream.obj
as a convenience for objectMode
var continueStream = require('continue-stream')
var request = require('request')
var pumpify = require('pumpify')
var JSONStream = require('JSONStream')
var page = 1
function next(callback, previousStream) {
if (page >= 4) return callback()
var req = request({
url: 'https://api.github.com/repos/joyent/node/events?page=' + (page++),
headers: {'user-agent': 'pug'}
})
var stream = pumpify.obj(req, JSONStream.parse('*'))
callback(null, stream)
}
continueStream.obj(next)
.on('data', function(data) {
console.log(data)
})
A good use case for this is paginated requests. Need to read the last n
pages of a feed and want all items piped through a single stream? That is
exactly what the last example is showing.
MIT
FAQs
Lazily merge multiple streams in to a single stream
We found that continue-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.