Détail du package

@ljharb/through

ljharb12.2mMIT2.3.14

simplified stream construction

stream, streams, user-streams, pipe

readme

@ljharb/through Version Badge

Note: This package is a fork of https://npmjs.com/through, and builds off of it.

github actions coverage License Downloads

npm badge

Easy way to create a Stream that is both readable and writable.

  • Pass in optional write and end methods.
  • through takes care of pause/resume logic if you use this.queue(data) instead of this.emit('data', data).
  • Use this.pause() and this.resume() to manage flow.
  • Check this.paused to see current flow state. (write always returns !this.paused).

This function is the basis for most of the synchronous streams in event-stream.

var through = require('@ljharb/through')

through(function write(data) {
    this.queue(data) //data *must* not be null
  },
  function end () { //optional
    this.queue(null)
  })

Or, can also be used without buffering on pause, use this.emit('data', data), and this.emit('end')

var through = require('@ljharb/through')

through(function write(data) {
    this.emit('data', data)
    //this.pause()
  },
  function end () { //optional
    this.emit('end')
  })

Extended Options

You will probably not need these 99% of the time.

autoDestroy=false

By default, through emits close when the writable and readable side of the stream has ended. If that is not desired, set autoDestroy=false.

var through = require('@ljharb/through')

//like this
var ts = through(write, end, {autoDestroy: false})
//or like this
var ts = through(write, end)
ts.autoDestroy = false

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v2.3.14 - 2025-02-07

Commits

  • [types] any falsy value is allowed as write or end 0cc4d4d
  • [Dev Deps] update @arethetypeswrong/cli, @ljharb/eslint-config, @ljharb/tsconfig, @types/node, @types/tape, auto-changelog, tape a51fc2c
  • [Deps] update call-bind 78eabe4
  • [Tests] replace aud with npm audit 908d64a
  • [Dev Deps] add missing peer dep 80f3805

v2.3.13 - 2024-03-08

Commits

  • [types] use shared tsconfig 8e77c7b
  • [Tests] increase coverage 0a0a33f
  • [types] fix d.ts errors; use a namespace 653e55d
  • [actions] remove redundant finisher; use reusable workflows 65ab32c
  • [Dev Deps] update @arethetypeswrong/cli, tape, typescript 1d2c513
  • [Dev Deps] update @types/node, typescript d5bdc23
  • [Deps] update call-bind 2633dc6
  • [Tests] install missing @types/node fe34373

v2.3.12 - 2024-01-24

Commits

  • [patch] add TS types 0b68b9d
  • [readme] correct requires; remove redundant license section 90ff780
  • [Dev Deps] update aud, npmignore, tape f4456ce
  • [Deps] update call-bind c1b7daa
  • [Dev Deps] update tape 74a75ac
  • [meta] add sideEffects flag dcfef36

v2.3.11 - 2023-10-11

Commits

  • [Deps] add missing call-bind da5e46d

v2.3.10 - 2023-10-10

Commits

  • [Robustness] use call-bind 3fc8de1
  • [Dev Deps] update aud, tape db14fcf

v2.3.9 - 2023-07-17

Commits

  • [meta] add scripts, dev deps, linting; switch from travis to GHA 2bc7e2d
  • [meta] rename package to scoped 337610b
  • [meta] confirmed with dominictarr in writing that this package was only ever MIT 832061e
  • [Dev Deps] update from, stream-spec, tape dae9dda
  • [meta] fix auto-changelog start version 3ac451b
  • [Fix] node < v0.6 does not have stream === stream.Stream 9f72162

v2.3.8 - 2015-07-03

Merged

  • Update package.json #35

v2.3.7 - 2015-04-06

Commits

  • fix non-strict null check 7048350

v2.3.6 - 2014-09-16

Commits

v2.3.5 - 2013-05-05

Fixed

  • fix spelling Closes #13 #13

v2.3.4 - 2013-04-29

Merged

  • mark "write" method as code #14

Commits

v2.3.3 - 2013-04-24

Merged

  • Test on 0.10 on Travis #12

v2.3.2 - 2013-04-24

Commits

  • check that through ends exactly once 802ecff
  • emit "end" exactly once 6f814a6

v2.3.1 - 2013-04-13

Commits

v2.3.0 - 2013-04-13

Commits

v2.2.7 - 2013-03-15

Merged

Commits

v2.2.6 - 2013-03-13

Commits

v2.2.5 - 2013-03-13

Commits

  • hopefully make this work in browserify a346472
  • narrow testling range, so it does not take as long b1e474b

v2.2.4 - 2013-03-13

Commits

v2.2.3 - 2013-03-12

Commits

v2.2.2 - 2013-03-12

Commits

v2.2.1 - 2013-03-03

Merged

2.2.0 - 2013-02-11

Merged

  • Alias queue() to push() #5

v2.1.0 - 2012-11-27

Commits

v2.0.0 - 2012-11-25

Commits

v1.1.2 - 2012-11-20

Commits

  • Ensure that end will be queued if paused with data c3efc00

v1.1.1 - 2012-10-11

Commits

v1.1.0 - 2012-09-15

Commits

v0.1.4 - 2012-08-07

Commits

  • package.json: s/repo/repository/ 6c811fa

v0.1.3 - 2012-08-07

Commits

v0.1.2 - 2012-07-23

Commits

  • do not emit pause event when already paused 1e5a27e

v0.1.1 - 2012-07-23

Commits

v0.1.0 - 2012-07-23

Commits

  • emit pause on entering pause state 2a003f9

v0.0.4 - 2012-07-07

Commits

  • add opensource 9691145
  • a bit better test coverage 320ee05
  • do not throw on end if not writable, just ignore a04701b

v0.0.3 - 2012-07-05

Commits

v0.0.2 - 2012-07-05

Commits

v0.0.1 - 2012-07-05

Commits