{"_id":"mock-stdin","_rev":"231415","name":"mock-stdin","description":"Mock STDIN file descriptor in Node.js","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"caitp","email":"caitpotter88@gmail.com"}],"time":{"modified":"2021-06-03T15:46:24.000Z","created":"2014-10-12T00:03:20.030Z","1.0.0":"2019-11-14T19:33:55.068Z","0.3.1":"2016-09-30T18:35:33.636Z","0.3.0":"2014-10-14T02:42:13.759Z","0.2.2":"2014-10-12T19:28:29.804Z","0.2.1":"2014-10-12T18:41:39.461Z","0.2.0":"2014-10-12T17:09:06.779Z","0.1.0":"2014-10-12T00:03:20.030Z"},"users":{"caitp":true,"nickytonline":true},"author":{"name":"Caitlin Potter","email":"caitpotter88@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/caitp/node-mock-stdin.git"},"versions":{"1.0.0":{"name":"mock-stdin","version":"1.0.0","description":"Mock STDIN file descriptor in Node.js","main":"./lib/index.js","scripts":{"test":"mocha test/"},"repository":{"type":"git","url":"git+https://github.com/caitp/node-mock-stdin.git"},"keywords":["test","mock","node","fs","stdin"],"author":{"name":"Caitlin Potter","email":"caitpotter88@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/caitp/node-mock-stdin/issues"},"homepage":"https://github.com/caitp/node-mock-stdin","devDependencies":{"mocha":"^6.2.2"},"gitHead":"f982e0cd65d8ffd96288dcb5fbeb65a1bfb2d661","_id":"mock-stdin@1.0.0","_nodeVersion":"10.17.0","_npmVersion":"6.11.3","dist":{"shasum":"efcfaf4b18077e14541742fd758b9cae4e5365ea","size":6070,"noattachment":false,"key":"/mock-stdin/-/mock-stdin-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-stdin/download/mock-stdin-1.0.0.tgz"},"maintainers":[{"name":"caitp","email":"caitpotter88@gmail.com"}],"_npmUser":{"name":"caitp","email":"caitpotter88@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-stdin_1.0.0_1573760034897_0.6144758547742386"},"_hasShrinkwrap":false,"publish_time":1573760035068,"_cnpm_publish_time":1573760035068},"0.3.1":{"name":"mock-stdin","version":"0.3.1","description":"Mock STDIN file descriptor in Node.js","main":"./lib/index.js","scripts":{"test":"nodeunit test/"},"repository":{"type":"git","url":"git+https://github.com/caitp/node-mock-stdin.git"},"keywords":["test","mock","node","fs","stdin"],"author":{"name":"Caitlin Potter","email":"caitpotter88@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/caitp/node-mock-stdin/issues"},"homepage":"https://github.com/caitp/node-mock-stdin","devDependencies":{"nodeunit":"^0.9.0"},"gitHead":"1839bf77118893df09b0454d41fa37e3ebaaef03","_id":"mock-stdin@0.3.1","_shasum":"c657d9642d90786435c64ca5e99bbd4d09bd7dd3","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"caitp","email":"caitpotter88@gmail.com"},"dist":{"shasum":"c657d9642d90786435c64ca5e99bbd4d09bd7dd3","size":5705,"noattachment":false,"key":"/mock-stdin/-/mock-stdin-0.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-stdin/download/mock-stdin-0.3.1.tgz"},"maintainers":[{"name":"caitp","email":"caitpotter88@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/mock-stdin-0.3.1.tgz_1475260532412_0.5353258675895631"},"directories":{},"publish_time":1475260533636,"_cnpm_publish_time":1475260533636,"_hasShrinkwrap":false},"0.3.0":{"name":"mock-stdin","version":"0.3.0","description":"Mock STDIN file descriptor in Node.js","main":"./lib/index.js","scripts":{"test":"nodeunit test/"},"repository":{"type":"git","url":"https://github.com/caitp/node-mock-stdin"},"keywords":["test","mock","node","fs","stdin"],"author":{"name":"Caitlin Potter","email":"caitpotter88@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/caitp/node-mock-stdin/issues"},"homepage":"https://github.com/caitp/node-mock-stdin","devDependencies":{"nodeunit":"^0.9.0"},"_id":"mock-stdin@0.3.0","dist":{"shasum":"f40d2a513a114e6d547480625b5ef5190744bd4d","size":5577,"noattachment":false,"key":"/mock-stdin/-/mock-stdin-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-stdin/download/mock-stdin-0.3.0.tgz"},"_from":"https://github.com/caitp/node-mock-stdin/archive/v0.3.0.tar.gz","_resolved":"https://github.com/caitp/node-mock-stdin/archive/v0.3.0.tar.gz","_npmVersion":"1.4.3","_npmUser":{"name":"caitp","email":"caitpotter88@gmail.com"},"maintainers":[{"name":"caitp","email":"caitpotter88@gmail.com"}],"directories":{},"publish_time":1413254533759,"_cnpm_publish_time":1413254533759,"_hasShrinkwrap":false},"0.2.2":{"name":"mock-stdin","version":"0.2.2","description":"Mock STDIN file descriptor in Node.js","main":"./lib/index.js","scripts":{"test":"nodeunit test/"},"repository":{"type":"git","url":"https://github.com/caitp/node-mockfd"},"keywords":["test","mock","node","fs","stdin"],"author":{"name":"Caitlin Potter","email":"caitpotter88@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/caitp/node-mock-stdin/issues"},"homepage":"https://github.com/caitp/node-mock-stdin","devDependencies":{"nodeunit":"^0.9.0"},"_id":"mock-stdin@0.2.2","dist":{"shasum":"f985f81faabf3f28e02ed270169d97b6f6ff6f61","size":4796,"noattachment":false,"key":"/mock-stdin/-/mock-stdin-0.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-stdin/download/mock-stdin-0.2.2.tgz"},"_from":"https://github.com/caitp/node-mock-stdin/archive/v0.2.2.tar.gz","_resolved":"https://github.com/caitp/node-mock-stdin/archive/v0.2.2.tar.gz","_npmVersion":"1.4.3","_npmUser":{"name":"caitp","email":"caitpotter88@gmail.com"},"maintainers":[{"name":"caitp","email":"caitpotter88@gmail.com"}],"directories":{},"publish_time":1413142109804,"_cnpm_publish_time":1413142109804,"_hasShrinkwrap":false},"0.2.1":{"name":"mock-stdin","version":"0.2.1","description":"Mock STDIN file descriptor in Node.js","main":"./lib/index.js","scripts":{"test":"nodeunit test/"},"repository":{"type":"git","url":"https://github.com/caitp/node-mockfd"},"keywords":["test","mock","node","fs","stdin"],"author":{"name":"Caitlin Potter","email":"caitpotter88@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/caitp/node-mock-stdin/issues"},"homepage":"https://github.com/caitp/node-mock-stdin","devDependencies":{"nodeunit":"^0.9.0"},"_id":"mock-stdin@0.2.1","dist":{"shasum":"5a81327af13c06a3f5f44419c592ea6221833fec","size":4739,"noattachment":false,"key":"/mock-stdin/-/mock-stdin-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-stdin/download/mock-stdin-0.2.1.tgz"},"_from":"https://github.com/caitp/node-mock-stdin/archive/v0.2.1.tar.gz","_resolved":"https://github.com/caitp/node-mock-stdin/archive/v0.2.1.tar.gz","_npmVersion":"1.4.3","_npmUser":{"name":"caitp","email":"caitpotter88@gmail.com"},"maintainers":[{"name":"caitp","email":"caitpotter88@gmail.com"}],"directories":{},"publish_time":1413139299461,"_cnpm_publish_time":1413139299461,"_hasShrinkwrap":false},"0.2.0":{"name":"mock-stdin","version":"0.2.0","description":"Mock STDIN file descriptor in Node.js","main":"./lib/index.js","scripts":{"test":"nodeunit test/"},"repository":{"type":"git","url":"https://github.com/caitp/node-mockfd"},"keywords":["test","mock","node","fs","stdin"],"author":{"name":"Caitlin Potter","email":"caitpotter88@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/caitp/node-mock-stdin/issues"},"homepage":"https://github.com/caitp/node-mock-stdin","devDependencies":{"nodeunit":"^0.9.0"},"_id":"mock-stdin@0.2.0","dist":{"shasum":"5a88b8b1f1ef92593de878b46e5a7b858e5e65cc","size":4595,"noattachment":false,"key":"/mock-stdin/-/mock-stdin-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-stdin/download/mock-stdin-0.2.0.tgz"},"_from":"https://github.com/caitp/node-mock-stdin/archive/v0.2.0.tar.gz","_resolved":"https://github.com/caitp/node-mock-stdin/archive/v0.2.0.tar.gz","_npmVersion":"1.4.3","_npmUser":{"name":"caitp","email":"caitpotter88@gmail.com"},"maintainers":[{"name":"caitp","email":"caitpotter88@gmail.com"}],"directories":{},"publish_time":1413133746779,"_cnpm_publish_time":1413133746779,"_hasShrinkwrap":false},"0.1.0":{"name":"mock-stdin","version":"0.1.0","description":"Mock STDIN file descriptor in Node.js","main":"./lib/index.js","scripts":{"test":"nodeunit test/"},"repository":{"type":"git","url":"https://github.com/caitp/node-mockfd"},"keywords":["test","mock","node","fs","stdin"],"author":{"name":"Caitlin Potter","email":"caitpotter88@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/caitp/node-mock-stdin/issues"},"homepage":"https://github.com/caitp/node-mock-stdin","devDependencies":{"nodeunit":"^0.9.0"},"_id":"mock-stdin@0.1.0","dist":{"shasum":"b2acbd52d36d5855cc470aef936dc0b6b686a664","size":4077,"noattachment":false,"key":"/mock-stdin/-/mock-stdin-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-stdin/download/mock-stdin-0.1.0.tgz"},"_from":"https://github.com/caitp/node-mock-stdin/archive/v0.1.0.tar.gz","_resolved":"https://github.com/caitp/node-mock-stdin/archive/v0.1.0.tar.gz","_npmVersion":"1.4.3","_npmUser":{"name":"caitp","email":"caitpotter88@gmail.com"},"maintainers":[{"name":"caitp","email":"caitpotter88@gmail.com"}],"directories":{},"publish_time":1413072200030,"_cnpm_publish_time":1413072200030,"_hasShrinkwrap":false}},"readme":"# node-mock-stdin\n\n[![Build Status](https://travis-ci.org/caitp/node-mock-stdin.svg?branch=master)](https://travis-ci.org/caitp/node-mock-stdin) [![Coverage Status](https://img.shields.io/coveralls/caitp/node-mock-stdin.svg)](https://coveralls.io/r/caitp/node-mock-stdin?branch=master) [![NPM Version](http://img.shields.io/npm/v/mock-stdin.svg)](https://www.npmjs.org/package/mock-stdin)\n\nProvide a mock readable stream, useful for testing interactive CLI applications.\n\nMaybe simple mocks for other standard files wouldn't be a terrible idea, if anyone\nfeels like those are needed. Patches welcome.\n\n## API\n\n- **Module**\n  - [stdin()](#modulestdin)\n- **MockSTDIN**\n  - [send()](#mockstdinsenddata-encoding)\n  - [end()](#mockstdinend)\n  - [restore()](#mockstdinrestore)\n  - [reset()](#mockstdinresetremovelisteners)\n\n---\n\n### Module.stdin()\n\n**example**\n\n```js\nrequire('mock-stdin').stdin();\n```\n\nReplaces the existing `process.stdin` value with a mock object exposing a `send` method (a\n`MockSTDIN` instance). This allows APIs like `process.openStdin()` or `process.stdin.on()`\nto operate on a mock instance.\n\n**note**: Event listeners from the original `process.stdin` instance are not added to the\nmock instance. Installation of the mock should occur before any event listeners are\nregistered.\n\n**return value**: A `MockSTDIN` instance\n\n---\n\n### MockSTDIN.send(data, encoding)\n\n**example**\n\n```js\nvar stdin = require('mock-stdin').stdin();\nstdin.send(\"Some text\", \"ascii\");\nstdin.send(Buffer(\"Some text\", \"Some optional encoding\"));\nstdin.send([\n  \"Array of lines\",\n  \"  which are joined with a linefeed.\"\n]);\n\n// sending a null will trigger EOF and dispatch an 'end' event.\nstdin.send(null);\n```\n\nQueue up data to be read by the stream. Results in data (and possibly end) events being \ndispatched.\n\n**parameters**\n  - `data`: A `String`, `Buffer`, `Array<String>`, or `null`. The `data` parameter will result in\n    the default encoding if specified as a string or array of strings.\n  - `encoding`: An optional encoding which is used when `data` is a `String`.\n      Node.js's internal Readable Stream will convert the specified encoding into the output\n      encoding, which is transcoded if necessary.\n\n**return value**: The `MockSTDIN` instance, for chaining.\n\n---\n\n### MockSTDIN.end()\n\n**example**\n\n```js\nvar stdin = require('mock-stdin').stdin();\nstdin.end();\n```\n\nAlias for [MockSTDIN.send(null)](#mockstdinsend). Results in dispatching an `end` event.\n\n**return value**: The `MockSTDIN` instance, for chaining.\n\n---\n\n### MockSTDIN.restore()\n\n**example**\n\n```js\nvar stdin = require('mock-stdin').stdin();\n// process.stdin is now a mock stream\nstdin.restore();\n// process.stdin is returned to its original state\n```\n\nRestore the target of the mocked stream. If only a single mock stream is created, will restore\nthe original `stdin` TTY stream. If multiple mock streams are created, it will restore the\nstream which was active at the time the mock was created.\n\n**return value**: The `MockSTDIN` instance, for chaining.\n\n---\n\n### MockSTDIN.reset(removeListeners)\n\n**example**\n\n```js\nvar stdin = require('mock-stdin').stdin();\nstdin.end();\nstdin.reset();\nstdin.send(\"some data\");\n```\n\nOrdinarily, a Readable stream will throw when attempting to push after an EOF. This routine will\nreset the `ended` state of a Readable stream, preventing it from throwing post-EOF. This prevents\nbeing required to re-create a mock STDIN instance during certain tests where a fresh stdin is\nrequired.\n\nIf the `removeListeners` flag is set to `true`, all event listeners will also be reset. This is\nuseful in cases where you need to emulate restarting an entire application, without fully \nre-creating the mock object.\n\n**parameters**\n  - `removeListeners`: Boolean value which, when set to `true`, will remove all event listeners\n  attached to the stream.\n\n**return value**: The `MockSTDIN` instance, for chaining.\n\n---\n\n## [LICENSE](LICENSE)\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Caitlin Potter & Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_attachments":{},"homepage":"https://github.com/caitp/node-mock-stdin","bugs":{"url":"https://github.com/caitp/node-mock-stdin/issues"},"license":"MIT"}