Registry / storage / it-queueless-pushable

it-queueless-pushable

JSON →
library2.0.5jsnpmunverified

A pushable async generator that waits until the current value is consumed before allowing a new value to be pushed. Useful for controlling memory usage and data flow in async iterators. Version 2.0.5 is the latest stable release. It is part of the 'it' monorepo by achingbrain. Unlike a standard pushable that queues all values, this variant enforces backpressure by having push() return a promise that resolves only after the value is consumed. Ships TypeScript types. Typically used in conjunction with other 'it' packages for streaming data processing. The package is ESM-only starting from version 3 (currently v2 supports both CJS and ESM).

npm install it-queueless-pushable
INSTALL
IMPORT
SIG · IT-QUEUELESS-PUSHA
I
it-queueless-pushable
storagejavascriptv2.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

queuelessPushable
import { queuelessPushable } from 'it-queueless-pushable'
const queuelessPushable = require('it-queueless-pushable')
CommonJS require() works in v2 but may break in future ESM-only releases.
QueuelessPushable
import type { QueuelessPushable } from 'it-queueless-pushable'
import { QueuelessPushable } from 'it-queueless-pushable'
QueuelessPushable is a TypeScript type, not a runtime export. Use type import or import type.
default export
import queuelessPushable from 'it-queueless-pushable'
const queuelessPushable = require('it-queueless-pushable').default
This package has both a named and default export. Default export is the same function, but prefer named import for clarity.

Demonstrates basic backpressure: push() resolves only after the value is consumed by the async iterator.

import { queuelessPushable } from 'it-queueless-pushable' const pushable = queuelessPushable<string>() // Producer: push a value asynchronously, it waits until consumed async function producer() { await pushable.push('hello') console.log('value pushed and consumed') } // Consumer: read values via async iteration async function consumer() { for await (const value of pushable) { console.log('received:', value) // after this log, the push promise resolves break } } producer() consumer()
Debug
Known issues
breakingIn v3, this package will be ESM-only and drop CommonJS support.
fix
Use import syntax or dynamic import(). If you need CommonJS, stick to v2.
affects: >=3.0.0
gotchaPush resolved promise order: If multiple push() calls are made before any consumption, they will not queue; push() will never resolve until previous values are consumed. This can lead to deadlocks if both producer and consumer are synchronous.
fix
Ensure producer and consumer run concurrently (e.g., in separate async functions or using Promise.resolve().then()).
affects: >=0.0.0
deprecatedThe package originally had a default export; the named export queuelessPushable is preferred.
fix
Use named import: import { queuelessPushable } from 'it-queueless-pushable'
affects: >=2.0.0 <3.0.0
gotchaCannot push null or undefined values; the pushable expects valid values and may throw or behave unexpectedly.
fix
Always push non-null, non-undefined values, or handle errors.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: queuelessPushable is not a function
Using CommonJS require() on ESM-only build or incorrect import path.
fix
Use import { queuelessPushable } from 'it-queueless-pushable'
Error: Cannot push to a pushable that is already ended
Calling push() after end() has been called.
fix
Check pushable state before pushing, or do not end early.
Promise never resolves / deadlock
Synchronous push and no concurrent consumer: push() waits indefinitely.
fix
Ensure consumer runs concurrently, e.g., via Promise.resolve().then(() => consume())
Upgrade
Version history
2.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
it-queueless-pushable — npm install it-queueless-pushable · libregistry