Socket
Book a DemoInstallSign in
Socket

@crabas0npm/sunt-quos-alias

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crabas0npm/sunt-quos-alias

Transform your data as it pass by, synchronously.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
60
Maintainers
1
Weekly downloads
 
Created
Source

@crabas0npm/sunt-quos-alias  ci

Transform your data as it pass by, synchronously.

@crabas0npm/sunt-quos-alias is a synchronous transform stream, similar to Transform stream and through2, but with a synchronous processing function. @crabas0npm/sunt-quos-alias 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(), pump(), or pipeline().

Install

npm i @crabas0npm/sunt-quos-alias --save

Example

import { createReadStream } from 'node:fs'
import { pipeline } from 'node:stream/promises'
import { @crabas0npm/sunt-quos-alias } from '@crabas0npm/sunt-quos-alias'

await pipeline(
  createReadStream(import.meta.filename),
  @crabas0npm/sunt-quos-alias(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()
  }),
  process.stdout)

API

@crabas0npm/sunt-quos-alias([transform(chunk)], [flush()])

Returns a new instance of @crabas0npm/sunt-quos-alias, 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.

@crabas0npm/sunt-quos-alias([transform(object)], [flush()])

Returns a new instance of @crabas0npm/sunt-quos-alias, 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.

instance.push(chunk)

Push a chunk to the destination.

Caveats

The API is the same of a streams 3 Transform, with some major differences:

  • backpressure is enforced, and the instance performs no buffering, e.g. when write() cannot be called after it returns false or it will throw (you need to wait for a 'drain' event).
  • It does not inherits from any of the Streams classes, and it does not have _readableState nor _writableState.
  • it does not have a read(n) method, nor it emits the 'readable' event, the data is pushed whenever ready.

Acknowledgements

This project was kindly sponsored by nearForm.

License

MIT

Keywords

enumerable

FAQs

Package last updated on 25 Apr 2024

Did you know?

Socket

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.

Install

Related posts