{"_id":"@dfgyhujk7npm/dolore-facilis-suscipit","name":"@dfgyhujk7npm/dolore-facilis-suscipit","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dfgyhujk7npm/dolore-facilis-suscipit","version":"1.0.0","description":"Node [streams2](http://nodejs.org/api/stream.html) over [Primus](https://github.com/primus/primus): added back-pressure!","main":"index.js","author":{"name":"dfgyhujk7"},"license":"MIT","keywords":["AsyncIterator","deepcopy","obj","concatMap","status","variables","full-width","copy","property","typanion","fast-deep-clone","Uint8Array","polyfill","@@toStringTag","take","validation","ansi","writable","syntax","open","japanese","irq","output","spec","symbols","parent","es6","auth","path","throttle","stylesheet","protocol-buffers","ES2020","es","zero","object","key","hooks","fast-deep-copy","expression","dom-testing-library","ajv","pretty","types","bundling","efficient","ponyfill","colors","typescript","a11y","assertion","banner","arrays","create","ES2015","typedarrays","iteration","minimal","walking","Stream","type","assert","width","Object.entries","es-abstract","jest","tslib","watchFile","ECMAScript 2023","styleguide","file","queue","dayjs","estree","express","flags","flatten","wait","uninstall","less.js","tdd","es2016","warning","shim","bootstrap css","parse","guid","trim","$.extend","css nesting","es7","JSON-Schema","slot","ReactiveExtensions","react pose","getintrinsic","client","valid","parser","censor","stateless","getOwnPropertyDescriptor","babel-core","byteLength","variables in css","setImmediate","prototype","three","interrupts","let","search","look-up","log","ender","fsevents","Observables","rm -fr","iterator","rangeerror","side","regex","linewrap","descriptor","redux","cache","deep-copy","batch","browserslist","RegExp.prototype.flags","prune","website","glob","css","Int32Array","define","once","eslint","rgb","multi-package","functional","spring","typed","protobuf","harmony","setter","start","ECMAScript 7","Object.assign","inspect","metadata","filter","WebSocket","matches","persistent","traverse","css-in-js","equality","Uint8ClampedArray","throat","code points","trimRight","typeerror","preprocessor","defineProperty","tostringtag","spinners","json","ES7","npm","core-js","class-validator","rfc4122","bundler","format","xhr","write","regular","sanitize","enumerable","Array.prototype.flat","sigterm","ES2016","map","ajax","ECMAScript 2020","mixins","diff","includes","sameValueZero","classnames","String.prototype.trim","Uint16Array","sorted","ECMAScript 5","es2017","error","Observable","positive","ESnext","push","urls","dataview","make","character","superstruct","async","busy","pose","joi","typeof","install","framer","time","compiler","autoprefixer","await","logger","setPrototypeOf","superagent","TypeScript","visual","RFC-6455","rmdir","phone","Object.values","findLastIndex","hookform","flat","array","symlink","react-hook-form","typesafe","xdg","higher-order","ie","sharedarraybuffer","regular expression","Underscore","less css","queueMicrotask","json-schema-validation","option","crypt","compile less","serialization","package","url","directory","args","ES8","ratelimit","clone","ramda","Object","querystring","uuid","resolve","arktype","apollo","Float64Array","native","formatting","drag","set","last","plugin","yaml","syntaxerror","shebang","mobile","node","sequence","speed","Array","opener","starter","connect","mru","serialize","hash","sigint","length","CSS","io-ts","touch","Array.prototype.includes","rm -rf","concurrency","Array.prototype.filter","animation","styling","CSSStyleDeclaration","rm","xss","ast","cmd","electron","ES2022","test","json-schema","ES2019","worker","omit","values","URL","argv","Push","check","var","fast-clone","robust","weakset","promises","internal","WeakMap","command","ArrayBuffer#slice","256",".env","karma","nope","tap","ES","pnpm9","WebSockets","monorepo","workspace:*","mkdirp","proto","console","internal slot","operating-system","config","toolkit","groupBy","keys","call-bind","app","sort","shrinkwrap","streams2","is","look","extend","Object.defineProperty","color","pure","toArray","escape","input","watcher","wordwrap","link","up","properties","jsdiff","nodejs","byteOffset","find-up","ES5","negative","mkdirs","jwt","Int8Array","match","view","dependency manager","computed-types","fastclone","wrap","matchAll","regexp","stringify","Object.keys","qs","chai","linux","Array.prototype.findLastIndex","names","collection.es6","argument","moment","telephone","jsdom","react-testing-library","fast","es2018","concat","password","date","ava","redact","import","mime-db","watching","toSorted","optimist","styled-components","promise","https","characters","deepclone","bcrypt","zod","patch","string","emit","name","jsx","task","reuse","yup","Uint32Array","dir","Rx","inference","descriptors","data","invariant","es2015","String.prototype.matchAll","performance","typedarray","i18n","Promise","make dir","ES2023","ECMAScript 2021","mime","streams","whatwg","ArrayBuffer.prototype.slice","trimLeft","merge","dom","shared","picomatch","scheme-validation","spinner","ES3","exec","fetch","byte","watch","callbind","web","events","contains","serializer","entries","dotenv","jsonpath","text","ECMAScript 2019","form","rate","stringifier","0","less mixins","dataView","lru","findup","middleware","coercible","css variable","trimEnd"],"repository":{"type":"git","url":"git+https://github.com/dfgyhujk7npm/dolore-facilis-suscipit.git"},"homepage":"https://github.com/dfgyhujk7npm/dolore-facilis-suscipit/#readme","bugs":{"url":"https://github.com/dfgyhujk7npm/dolore-facilis-suscipit/issues"},"packageManager":"yarn@4.1.1","dependencies":{"@ajhgwdjnpm/incidunt-ex-officiis":"^1.0.0","@dfgyhujk7npm/quo-temporibus-reprehenderit":"^1.0.0","@dfgyhujk7npm/velit-sequi-minus":"^1.0.0"},"_id":"@dfgyhujk7npm/dolore-facilis-suscipit@1.0.0","gitHead":"0f1d6259b60d3186420a7b4f5e23e339d829e00a","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-DvIrjMolsDqboG9HwdLdw/UPRHpAqkQebD67i1hLZhjQCSJ8vwt/FvzbYDixGyUlf9quCqbUjjlbojWcJXKN3g==","shasum":"9fdc05c2a0f47ee155433ed3ebf47bd19936bb95","tarball":"https://registry.npmjs.org/@dfgyhujk7npm/dolore-facilis-suscipit/-/dolore-facilis-suscipit-1.0.0.tgz","fileCount":10,"unpackedSize":21581,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA3guLlxOWsDlgYGZrSIQnckIRSC28fXurBbj6YJKGZrAiBeI5p77wuxcPd75CGAjhnHepk/M4N7cutmHrXx5qTo+Q=="}]},"_npmUser":{"name":"tra37500","email":"tra37500@gmail.com"},"directories":{},"maintainers":[{"name":"tra37500","email":"tra37500@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dolore-facilis-suscipit_1.0.0_1714039823483_0.60056352609075"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-25T10:10:23.394Z","1.0.0":"2024-04-25T10:10:23.699Z","modified":"2024-04-25T10:10:23.972Z"},"maintainers":[{"name":"tra37500","email":"tra37500@gmail.com"}],"description":"Node [streams2](http://nodejs.org/api/stream.html) over [Primus](https://github.com/primus/primus): added back-pressure!","homepage":"https://github.com/dfgyhujk7npm/dolore-facilis-suscipit/#readme","keywords":["AsyncIterator","deepcopy","obj","concatMap","status","variables","full-width","copy","property","typanion","fast-deep-clone","Uint8Array","polyfill","@@toStringTag","take","validation","ansi","writable","syntax","open","japanese","irq","output","spec","symbols","parent","es6","auth","path","throttle","stylesheet","protocol-buffers","ES2020","es","zero","object","key","hooks","fast-deep-copy","expression","dom-testing-library","ajv","pretty","types","bundling","efficient","ponyfill","colors","typescript","a11y","assertion","banner","arrays","create","ES2015","typedarrays","iteration","minimal","walking","Stream","type","assert","width","Object.entries","es-abstract","jest","tslib","watchFile","ECMAScript 2023","styleguide","file","queue","dayjs","estree","express","flags","flatten","wait","uninstall","less.js","tdd","es2016","warning","shim","bootstrap css","parse","guid","trim","$.extend","css nesting","es7","JSON-Schema","slot","ReactiveExtensions","react pose","getintrinsic","client","valid","parser","censor","stateless","getOwnPropertyDescriptor","babel-core","byteLength","variables in css","setImmediate","prototype","three","interrupts","let","search","look-up","log","ender","fsevents","Observables","rm -fr","iterator","rangeerror","side","regex","linewrap","descriptor","redux","cache","deep-copy","batch","browserslist","RegExp.prototype.flags","prune","website","glob","css","Int32Array","define","once","eslint","rgb","multi-package","functional","spring","typed","protobuf","harmony","setter","start","ECMAScript 7","Object.assign","inspect","metadata","filter","WebSocket","matches","persistent","traverse","css-in-js","equality","Uint8ClampedArray","throat","code points","trimRight","typeerror","preprocessor","defineProperty","tostringtag","spinners","json","ES7","npm","core-js","class-validator","rfc4122","bundler","format","xhr","write","regular","sanitize","enumerable","Array.prototype.flat","sigterm","ES2016","map","ajax","ECMAScript 2020","mixins","diff","includes","sameValueZero","classnames","String.prototype.trim","Uint16Array","sorted","ECMAScript 5","es2017","error","Observable","positive","ESnext","push","urls","dataview","make","character","superstruct","async","busy","pose","joi","typeof","install","framer","time","compiler","autoprefixer","await","logger","setPrototypeOf","superagent","TypeScript","visual","RFC-6455","rmdir","phone","Object.values","findLastIndex","hookform","flat","array","symlink","react-hook-form","typesafe","xdg","higher-order","ie","sharedarraybuffer","regular expression","Underscore","less css","queueMicrotask","json-schema-validation","option","crypt","compile less","serialization","package","url","directory","args","ES8","ratelimit","clone","ramda","Object","querystring","uuid","resolve","arktype","apollo","Float64Array","native","formatting","drag","set","last","plugin","yaml","syntaxerror","shebang","mobile","node","sequence","speed","Array","opener","starter","connect","mru","serialize","hash","sigint","length","CSS","io-ts","touch","Array.prototype.includes","rm -rf","concurrency","Array.prototype.filter","animation","styling","CSSStyleDeclaration","rm","xss","ast","cmd","electron","ES2022","test","json-schema","ES2019","worker","omit","values","URL","argv","Push","check","var","fast-clone","robust","weakset","promises","internal","WeakMap","command","ArrayBuffer#slice","256",".env","karma","nope","tap","ES","pnpm9","WebSockets","monorepo","workspace:*","mkdirp","proto","console","internal slot","operating-system","config","toolkit","groupBy","keys","call-bind","app","sort","shrinkwrap","streams2","is","look","extend","Object.defineProperty","color","pure","toArray","escape","input","watcher","wordwrap","link","up","properties","jsdiff","nodejs","byteOffset","find-up","ES5","negative","mkdirs","jwt","Int8Array","match","view","dependency manager","computed-types","fastclone","wrap","matchAll","regexp","stringify","Object.keys","qs","chai","linux","Array.prototype.findLastIndex","names","collection.es6","argument","moment","telephone","jsdom","react-testing-library","fast","es2018","concat","password","date","ava","redact","import","mime-db","watching","toSorted","optimist","styled-components","promise","https","characters","deepclone","bcrypt","zod","patch","string","emit","name","jsx","task","reuse","yup","Uint32Array","dir","Rx","inference","descriptors","data","invariant","es2015","String.prototype.matchAll","performance","typedarray","i18n","Promise","make dir","ES2023","ECMAScript 2021","mime","streams","whatwg","ArrayBuffer.prototype.slice","trimLeft","merge","dom","shared","picomatch","scheme-validation","spinner","ES3","exec","fetch","byte","watch","callbind","web","events","contains","serializer","entries","dotenv","jsonpath","text","ECMAScript 2019","form","rate","stringifier","0","less mixins","dataView","lru","findup","middleware","coercible","css variable","trimEnd"],"repository":{"type":"git","url":"git+https://github.com/dfgyhujk7npm/dolore-facilis-suscipit.git"},"author":{"name":"dfgyhujk7"},"bugs":{"url":"https://github.com/dfgyhujk7npm/dolore-facilis-suscipit/issues"},"license":"MIT","readme":"# @dfgyhujk7npm/dolore-facilis-suscipit&nbsp;&nbsp;&nbsp;[![Build Status](https://github.com/dfgyhujk7npm/dolore-facilis-suscipit/actions/workflows/ci.yml/badge.svg)](https://github.com/dfgyhujk7npm/dolore-facilis-suscipit/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/davedoesdev/@dfgyhujk7npm/dolore-facilis-suscipit/badge.png?branch=master)](https://coveralls.io/r/davedoesdev/@dfgyhujk7npm/dolore-facilis-suscipit?branch=master) [![NPM version](https://badge.fury.io/js/@dfgyhujk7npm/dolore-facilis-suscipit.png)](http://badge.fury.io/js/@dfgyhujk7npm/dolore-facilis-suscipit)\n\nNode [streams2](http://nodejs.org/api/stream.html) over [Primus](https://github.com/primus/primus): added back-pressure!\n\n- Pass in a Primus client or spark, get back a [`stream.Duplex`](http://nodejs.org/api/stream.html#stream_class_stream_duplex_1). Do this on both sides of a Primus connection.\n- [`write`](http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback) returns `true` when the receiver is full.\n- Use [`read`](http://nodejs.org/api/stream.html#stream_readable_read_size) and [`readable`](http://nodejs.org/api/stream.html#stream_event_readable) to exert back-pressure on the sender.\n- Unit tests with 100% coverage.\n- Browser unit tests using [webpack](http://webpack.github.io/) and [PhantomJS](http://phantomjs.org/).\n\nThe API is described [here](#api).\n\n## Example\n\nExerting backpressure over Primus:\n\n```javascript\nvar Primus = require('primus'),\n    PrimusDuplex = require('@dfgyhujk7npm/dolore-facilis-suscipit').PrimusDuplex,\n    primus = Primus.createServer({ port: 9000 }),\n    Socket = primus.Socket,\n    assert = require('assert'),\n    read_a = false;\n\nprimus.once('connection', function (spark)\n{\n    var spark_duplex = new PrimusDuplex(spark,\n    {\n        highWaterMark: 2\n    });\n\n    assert.equal(spark_duplex.write('ab'), false);\n\n    spark_duplex.on('drain', function ()\n    {\n        assert(read_a);\n    });\n});\n\nvar client_duplex = new PrimusDuplex(new Socket('http://localhost:9000'),\n{\n    highWaterMark: 1\n});\n\nclient_duplex.once('readable', function ()\n{\n    assert.equal(this.read().toString(), 'a');\n    read_a = true;\n    assert.equal(this.read(), null);\n\n    this.once('readable', function ()\n    {\n        assert.equal(this.read().toString(), 'b');\n        primus.end();\n        console.log('done')\n    });\n});\n```\n\n## Another Example\n\nPiping data over Primus:\n\n```javascript\nvar Primus = require('primus'),\n    PrimusDuplex = require('@dfgyhujk7npm/dolore-facilis-suscipit').PrimusDuplex,\n    primus = Primus.createServer({ port: 9000 }),\n    Socket = primus.Socket,\n    assert = require('assert'),\n    crypto = require('crypto'),\n    tmp = require('tmp'),\n    fs = require('fs');\n\nprimus.once('connection', function (spark)\n{\n    var spark_duplex = new PrimusDuplex(spark);\n\n    tmp.tmpName(function (err, random_file)\n    {\n        assert.ifError(err);\n\n        var random_buf = crypto.randomBytes(1024 * 1024);\n\n        fs.writeFile(random_file, random_buf, function (err)\n        {\n            assert.ifError(err);\n\n            tmp.tmpName(function (err, out_file)\n            {\n                assert.ifError(err);\n\n                var random_stream = fs.createReadStream(random_file),\n                    out_stream = fs.createWriteStream(out_file);\n\n                out_stream.on('finish', function ()\n                {\n                    fs.readFile(out_file, function (err, out_buf)\n                    {\n                        assert.ifError(err);\n                        assert.deepEqual(out_buf, random_buf);\n\n                        fs.unlink(random_file, function (err)\n                        {\n                            assert.ifError(err);\n                            fs.unlink(out_file, function (err)\n                            {\n                                assert.ifError(err);\n                                primus.end();\n                                console.log('done');\n                            });\n                        });\n                    });\n                });\n\n                spark_duplex.pipe(out_stream);\n                random_stream.pipe(spark_duplex);\n            });\n        });\n    });\n});\n\nvar client_duplex = new PrimusDuplex(new Socket('http://localhost:9000'));\nclient_duplex.pipe(client_duplex);\n```\n\n## Installation\n\n```shell\nnpm install @dfgyhujk7npm/dolore-facilis-suscipit\n```\n\n## Licence\n\n[MIT](LICENCE)\n\n## Test\n\nNode client to Node server:\n\n```shell\ngrunt test\n```\n\nBrowser client to Node server (requires [PhantomJS](http://phantomjs.org/)):\n\n```shell\ngrunt test-browser\n```\n\n## Code Coverage\n\n```shell\ngrunt coverage\n```\n\n[c8](https://github.com/bcoe/c8) results are available [here](http://rawgit.davedoesdev.com/davedoesdev/@dfgyhujk7npm/dolore-facilis-suscipit/master/coverage/lcov-report/index.html).\n\nCoveralls page is [here](https://coveralls.io/r/davedoesdev/@dfgyhujk7npm/dolore-facilis-suscipit).\n\n## Lint\n\n```shell\ngrunt lint\n```\n\n# API\n\n[`PrimusDuplex`](#primusduplexmsg_stream-options) inherits from [`stream.Duplex`](http://nodejs.org/api/stream.html#stream_class_stream_duplex_1) so you can call any method from [`stream.Readable`](http://nodejs.org/api/stream.html#stream_class_stream_readable) and [`stream.Writable`](http://nodejs.org/api/stream.html#stream_class_stream_writable).\n\nExtra constructor options and an additional parameter to [`readable.read`](http://nodejs.org/api/stream.html#stream_readable_read_size) are described below.\n\n_Source: [index.js](/index.js)_\n\n<a name=\"tableofcontents\"></a>\n\n- <a name=\"toc_primusduplexmsg_stream-options\"></a>[PrimusDuplex](#primusduplexmsg_stream-options)\n- <a name=\"toc_primusduplexprototypereadsize-send_status\"></a><a name=\"toc_primusduplexprototype\"></a>[PrimusDuplex.prototype.read](#primusduplexprototypereadsize-send_status)\n\n## PrimusDuplex(msg_stream, [options])\n\n> Creates a new `PrimusDuplex` object which exerts back-pressure over a [Primus](https://github.com/primus/primus) connection.\n\nBoth sides of a Primus connection must use `PrimusDuplex` &mdash; create one for your Primus client and one for your spark as soon as you have them.\n\n**Parameters:**\n\n- `{Object} msg_stream` The Primus client or spark you wish to exert back-pressure over.\n- `{Object} [options]` Configuration options. This is passed onto `stream.Duplex` and can contain the following extra properties:\n  - `{Function} [encode_data(chunk, encoding, start, end, internal)]` Optional encoding function for data passed to [`writable.write`](http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback). `chunk` and `encoding` are as described in the `writable.write` documentation. The difference is that `encode_data` is synchronous (it must return the encoded data) and it should only encode data between the `start` and `end` positions in `chunk`. Defaults to a function which does `chunk.toString('base64', start, end)`. Note that `PrimusDuplex` may also pass some internal data through this function (always with `chunk` as a `Buffer`, `encoding=null` and `internal=true`).\n\n  - `{Function} [decode_data(chunk, internal)]` Optional decoding function for data received on the Primus connection. The type of `chunk` will depend on how the peer `PrimusDuplex` encoded it. Defaults to a function which does `Buffer.from(chunk, 'base64')`. If the data can't be decoded, return `null` (and optionally call `this.emit` to emit an error). Note that `PrimusDuplex` may also pass some internal data through this function (always with `internal=true`) &mdash; in which case you must return a `Buffer`.\n\n  - `{Integer} [max_write_size]` Maximum number of bytes to write onto the Primus connection at once, regardless of how many bytes the peer is free to receive. Defaults to 0 (no limit).\n\n  - `{Boolean} [check_read_overflow]` Whether to check if more data than expected is being received. If `true` and the high-water mark for reading is exceeded then the `PrimusDuplex` object emits an `error` event. This should not normally occur unless you add data yourself using [`readable.unshift`](http://nodejs.org/api/stream.html#stream_readable_unshift_chunk) &mdash; in which case you should set `check_read_overflow` to `false`. Defaults to `true`.\n\n<sub>Go: [TOC](#tableofcontents)</sub>\n\n<a name=\"primusduplexprototype\"></a>\n\n## PrimusDuplex.prototype.read([size], [send_status])\n\n> See [`readable.read`](http://nodejs.org/api/stream.html#stream_readable_read_size). `PrimusDuplex` adds an extra optional parameter, `send_status`.\n\n**Parameters:**\n\n- `{Number} [size]` Optional argument to specify how much data to read. Defaults to `undefined` (you can also specify `null`) which means return all the data available.\n- `{Boolean} [send_status]` Every time you call `read`, a status message is sent to the peer `PrimusDuplex` indicating how much space is left in the internal buffer to receive new data. To prevent deadlock, these status messages are always sent &mdash; they aren't subject to back-pressure. Normally this is fine because status messages are small. However, if your application reads data one byte at a time, for example, you may wish to control when status messages are sent. To stop a status message being sent when you call `read`, pass `send_status` as `false`. `send_status` defaults to `true`. To force a status message to be sent without reading any data, call `read(0)`.\n\n<sub>Go: [TOC](#tableofcontents) | [PrimusDuplex.prototype](#toc_primusduplexprototype)</sub>\n\n_&mdash;generated by [apidox](https://github.com/codeactual/apidox)&mdash;_\n","readmeFilename":"README.md"}