0.1.4 • Published 10 years ago

duplexer2 v0.1.4

Weekly downloads
4,998,147
License
BSD-3-Clause
Repository
github
Last release
10 years ago

duplexer2 Build Status Coverage Status

Like duplexer but using Streams3

var stream = require("stream");

var duplexer2 = require("duplexer2");

var writable = new stream.Writable({objectMode: true}),
    readable = new stream.Readable({objectMode: true});

writable._write = function _write(input, encoding, done) {
  if (readable.push(input)) {
    return done();
  } else {
    readable.once("drain", done);
  }
};

readable._read = function _read(n) {
  // no-op
};

// simulate the readable thing closing after a bit
writable.once("finish", function() {
  setTimeout(function() {
    readable.push(null);
  }, 500);
});

var duplex = duplexer2(writable, readable);

duplex.on("data", function(e) {
  console.log("got data", JSON.stringify(e));
});

duplex.on("finish", function() {
  console.log("got finish event");
});

duplex.on("end", function() {
  console.log("got end event");
});

duplex.write("oh, hi there", function() {
  console.log("finished writing");
});

duplex.end(function() {
  console.log("finished ending");
});
got data "oh, hi there"
finished writing
got finish event
finished ending
got end event

Overview

This is a reimplementation of duplexer using the Streams3 API which is standard in Node as of v4. Everything largely works the same.

Installation

Available via npm:

$ npm i duplexer2

API

duplexer2

Creates a new DuplexWrapper object, which is the actual class that implements most of the fun stuff. All that fun stuff is hidden. DON'T LOOK.

duplexer2([options], writable, readable)
const duplex = duplexer2(new stream.Writable(), new stream.Readable());

Arguments

  • options - an object specifying the regular stream.Duplex options, as well as the properties described below.
  • writable - a writable stream
  • readable - a readable stream

Options

  • bubbleErrors - a boolean value that specifies whether to bubble errors from the underlying readable/writable streams. Default is true.

License

3-clause BSD. A copy is included with the source.

Contact

stream-combiner2static-moduleunzippermultipipebrowserifyarchetype-librarysaidbekakagakilli8n-react-native-fast-imagetranslation-pkgl7mpwenke-browserifypanqibao@avorium/unzipperencrypto-browserify@mink-opn/build-tokens@infinitebrahmanuniverse/nolb-dupopea-bootstraap@everything-registry/sub-chunk-1538wistroni40-unzipper@rabailriaz/hisaab-web-portaltap-colortap-nyantanngotap-to-tapsontar-parse-onetar-vinyltar-vinyl-streamterminal-menuweb-component-tester-bundlewabotakbarwed_developerwraplinewpipetehsportscale-wifi-connectspongeswitchstreamthreejs-tree-shakevideo-multi-uploader@doxteam/service@doxteam/libs@cobalt-engine/co-browserify@dan/cryptocoins-icons@contrast/html-select@rstacruz/pnpm@pradeepgudipati/kovaad-chat-ui-kit-styles@roblabla/etlcauseway-concrete-stylesgenerator-bootstrap-boilerplate-templatejeuxuijm-etljson2po-streamgomantic_release3.0.0chain_diggerweb-yii2stream-adventurestrip-chromium-logsstream-switchstyle-depsstyle-streamspigot-ui-inventorysproutward-unzipperstatic-methodstreamfpss-buildsrt-streamtt-extended-menutrumpettools_may_24twine-libtwine-library@articulate/node-unzipper@arve.knudsen/static-module@anonybit-modules/videoreconstruction@assystant/firebase@blazinaj/app-kit@career0.1/my-first-career0.1@career0.1/my-first-career0.2@cljs-oss/module-deps@deranged/unzipper@devorso/dcountdown@contrast/trumpetzylvue-v3-yandex-metrikawc-starterkitvinyl-accumulatevinyl-forkunique-idsunzipper-fasterunzipper-liteunzipper-patchunzpr@guihash/unzipper@hummhive/saltpack@gofunky/trumpet@innodata/vue-v3-ya-metrika@l7mp/l7mp@lechuhuuha/unzipper@leichtgewicht/browserify
0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.2

11 years ago

0.0.1

12 years ago