Like duplexer (http://npm.im/duplexer) but using streams2.
duplexer2 is a reimplementation of duplexer using the readable-stream API which is standard in node as of v0.10. Everything largely works the same.
Available via npm:
$ npm install duplexer2
Or via git:
$ git clone git://github.com/deoxxa/duplexer2.git node_modules/duplexer2
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)
var duplex = duplexer2(new stream.Writable(), new stream.Readable());
Arguments
stream.Duplex
options, as
well as the properties described below.Options
true
.Also see example.js.
Code:
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");
});
Output:
got data "oh, hi there"
finished writing
got finish event
finished ending
got end event
3-clause BSD. A copy is included with the source.
duplexer2 [![build status](https://travis-ci.org/deoxxa/duplexer2.png)](https://travis-ci.org/deoxxa/fork) ========= Like duplexer (http://npm.im/duplexer) but using streams2. Overview -------- duplexer2 is a reimplementation of [duplexer](http://npm.im/duplexer) using the readable-stream API which is standard in node as of v0.10. Everything largely works the same. Installation ------------ Available via [npm](http://npmjs.org/): > $ npm install duplexer2 Or via git: > $ git clone git://github.com/deoxxa/duplexer2.git node_modules/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. ```javascript duplexer2([options], writable, readable) ``` ```javascript var 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`. Example ------- Also see [example.js](https://github.com/deoxxa/duplexer2/blob/master/example.js). Code: ```javascript 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"); }); ``` Output: ``` got data "oh, hi there" finished writing got finish event finished ending got end event ``` License ------- 3-clause BSD. A copy is included with the source. Contact ------- * GitHub ([deoxxa](http://github.com/deoxxa)) * Twitter ([@deoxxa](http://twitter.com/deoxxa)) * Email ([deoxxa@fknsrs.biz](mailto:deoxxa@fknsrs.biz))
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/duplexer2/README.md | |||||
#2 | 19053 | tjuricek |
Rebuild JavaScript Client SDK. The JavaScript client now is a "typed" approach that tends to be similar in approach to the other clients, based on the swagger definition for the platform version. Importantly, client SDK tests are individual scripts (that run under node) that are actually controlled via TestNG. This approach now lets us use a consistent test reporting format so we can at least collect reports from each of the jobs. The documentation is still in progress, that I want to validate as the tests are generated. |
||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |