Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
syncthrough
Advanced tools
Transform your data as it pass by, synchronously.
syncthrough is a synchronous transform stream, similar to Transform
stream and through2, but with a synchronous processing function.
syncthrough enforces backpressure, but it maintain no internal
buffering, allowing much greater throughput.
In fact, it delivers 10x performance over a standard
Transform
.
Because of the caveats, it is best used in combination of
pipe()
or pump()
.
npm i syncthrough --save
'use strict'
var fs = require('fs')
var syncthrough = require('syncthrough')
fs.createReadStream(__filename)
.pipe(syncthrough(function (chunk) {
// there is no callback here
// you can return null to end the stream
// returning undefined will let you skip this chunk
return chunk.toString().toUpperCase()
}))
.pipe(process.stdout, { end: false })
Returns a new instance of syncthrough
, where transform(chunk)
is the
transformation that will be applied to all incoming chunks.
The default transform
function is:
function (chunk) {
return chunk
}
If it returns null
, the stream will be closed. If it returns
undefined
, the chunk will be skipped.
There is currently no way to split an incoming chunk into multiple chunks.
The flush()
function will be called before the transform sends end()
on the destination.
Returns a new instance of syncthrough
, where transform(object)
is the
transformation that will be applied to all incoming objects.
Syncthrough is compatible with Streams in Object Mode, the API is exactly the same, simply expect objects instead of buffer chunks.
Push a chunk to the destination.
The API is the same of a streams 3 Transform
, with some major differences:
write()
cannot be called after it returns false or it will throw
(you need to wait for a 'drain'
event)._readableState
nor _writableState
.read(n)
method, nor it emits the
'readable'
event, the data is pushed whenever ready.This project was kindly sponsored by nearForm.
MIT
FAQs
A Transform stream that is sync, and very fast
The npm package syncthrough receives a total of 464 weekly downloads. As such, syncthrough popularity was classified as not popular.
We found that syncthrough demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.