Registry / storage / checkpoint-stream

checkpoint-stream

JSON →
library0.1.2jsnpmunverified

Queue data from a stream until a checkpoint condition is met. Version 0.1.2. A transform stream that buffers incoming data until a user-defined function returns true for a checkpoint, then flushes the buffer. Useful for handling retries in streaming APIs with periodic tokens. Built on through2. Minimal API with configurable max queue size and object mode. No known active development.

npm install checkpoint-stream
INSTALL
IMPORT
SIG · CHECKPOINT-STREAM
C
checkpoint-stream
storagejavascriptv0.1.2
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.

default
import checkpoint from 'checkpoint-stream'
const checkpoint = require('checkpoint-stream')
Package is CommonJS-only; require() works but ESM import may fail in strict ESM environments.
checkpointStream
import { checkpointStream } from 'checkpoint-stream'
const checkpointStream = require('checkpoint-stream').checkpointStream
Named export not documented; use default import instead.
obj
import checkpoint from 'checkpoint-stream'; const objStream = checkpoint.obj(fn)
import { obj } from 'checkpoint-stream'
obj is a method on the default export, not a named export.

Shows how to use checkpoint-stream with object mode to buffer data until a checkpoint token is encountered.

const checkpoint = require('checkpoint-stream'); const { Readable, Transform } = require('stream'); // Simulate a stream of objects with a checkpoint token const source = Readable.from([ { id: 1 }, { id: 2 }, { token: 'abc' }, { id: 3 } ]); const checkpointer = checkpoint.obj((obj) => obj.token !== undefined); source.pipe(checkpointer).on('data', (data) => { console.log('Data:', data); }).on('checkpoint', (obj) => { console.log('Checkpoint:', obj); }); // Output: // Data: { id: 1 } // Data: { id: 2 } // Checkpoint: { token: 'abc' } // Data: { id: 3 }
Debug
Known issues
gotchaCheckpoint function receives each chunk; for object mode, the chunk is the object itself.
fix
Ensure the isCheckpointFn handles the raw chunk (string/buffer/object) based on stream mode.
affects: >=0.0.0
gotchaThe 'checkpoint' event emits the checkpoint object, not the queued data.
fix
Listen to 'data' events for buffered objects, and 'checkpoint' for the trigger object.
affects: >=0.0.0
gotchamaxQueued default is 10; if no checkpoint is found, buffer will flush after 10 items.
fix
Set maxQueued to 0 or Infinity based on desired behavior (0 disables flushing, Infinity never flushes).
affects: >=0.0.0
deprecatedPackage depends on through2, which is essentially unmaintained.
fix
Consider rewriting with native Node.js streams using Transform class.
affects: >=0.0.0
gotchaobjectMode must be set to true via checkpoint.obj() or by passing objectMode: true in config.
fix
Use checkpoint.obj(fn) for object mode streams, or pass { isCheckpointFn: fn, objectMode: true } to checkpoint().
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: this._transform is not a function
Using checkpoint-stream incorrectly as a constructor or without new, but it's a function.
fix
Use checkpoint(config) to create a stream instance, not checkpoint.new or similar.
Cannot find module 'through2'
through2 is a peer dependency, not automatically installed.
fix
Run npm install through2 --save alongside checkpoint-stream.
Error: This is not a checkpoint
Checkpoint function is throwing an error or returning undefined/non-boolean.
fix
Ensure isCheckpointFn returns a boolean (true or false).
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies
through2requiredused to create the transform stream internally
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
checkpoint-stream — npm install checkpoint-stream · libregistry