{"_id":"read-input","_rev":"224620","name":"read-input","description":"Easily read from stdin or files.","dist-tags":{"latest":"0.3.1"},"maintainers":[{"name":"rstacruz","email":"rico@ricostacruz.com"}],"time":{"modified":"2021-06-03T15:41:59.000Z","created":"2014-08-05T06:19:55.788Z","0.3.1":"2015-06-03T09:27:03.590Z","0.3.0":"2015-05-23T07:38:17.399Z","0.2.0":"2014-08-27T05:38:13.960Z","0.1.0":"2014-08-05T06:19:55.788Z"},"users":{"chocolateboy":true},"author":{"name":"Rico Sta. Cruz","email":"hi@ricostacruz.com"},"repository":{"type":"git","url":"git://github.com/rstacruz/read-input.git"},"versions":{"0.3.1":{"name":"read-input","version":"0.3.1","description":"Easily read from stdin or files.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha","prepublish":"npm test","update-docs":"mdextract -u Readme.md"},"repository":{"type":"git","url":"git://github.com/rstacruz/read-input.git"},"keywords":["input","read","stdin"],"author":{"name":"Rico Sta. Cruz","email":"hi@ricostacruz.com"},"license":"MIT","bugs":{"url":"https://github.com/rstacruz/read-input/issues"},"homepage":"https://github.com/rstacruz/read-input","devDependencies":{"chai":"^1.9.1","mdextract":"^1.0.0","mocha":"^2.2.5","mocha-repeat":"^0.1.0"},"gitHead":"a623dfcc45ff80124550c0b12dc5cde159fd6649","_id":"read-input@0.3.1","_shasum":"5b3169308013464ffda6ec92e58d2d3cea948df1","_from":".","_npmVersion":"2.9.0","_nodeVersion":"2.0.2","_npmUser":{"name":"rstacruz","email":"rico@ricostacruz.com"},"maintainers":[{"name":"rstacruz","email":"rico@ricostacruz.com"}],"dist":{"shasum":"5b3169308013464ffda6ec92e58d2d3cea948df1","size":4134,"noattachment":false,"key":"/read-input/-/read-input-0.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/read-input/download/read-input-0.3.1.tgz"},"publish_time":1433323623590,"_cnpm_publish_time":1433323623590,"_hasShrinkwrap":false},"0.3.0":{"name":"read-input","version":"0.3.0","description":"Easily read from stdin or files.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha","prepublish":"npm test","update-docs":"mdextract -u Readme.md"},"repository":{"type":"git","url":"git://github.com/rstacruz/read-input.git"},"keywords":["input","read","stdin"],"author":{"name":"Rico Sta. Cruz","email":"hi@ricostacruz.com"},"license":"MIT","bugs":{"url":"https://github.com/rstacruz/read-input/issues"},"homepage":"https://github.com/rstacruz/read-input","devDependencies":{"chai":"^1.9.1","mdextract":"^1.0.0","mocha":"^2.2.5","mocha-repeat":"^0.1.0"},"gitHead":"ab30e1b86cdcd3f52b6685b143a04b7cd32d7995","_id":"read-input@0.3.0","_shasum":"cf535cc879efd450b69407b476c0ad8b91db27fd","_from":".","_npmVersion":"2.9.0","_nodeVersion":"2.0.2","_npmUser":{"name":"rstacruz","email":"rico@ricostacruz.com"},"maintainers":[{"name":"rstacruz","email":"rico@ricostacruz.com"}],"dist":{"shasum":"cf535cc879efd450b69407b476c0ad8b91db27fd","size":3892,"noattachment":false,"key":"/read-input/-/read-input-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/read-input/download/read-input-0.3.0.tgz"},"publish_time":1432366697399,"_cnpm_publish_time":1432366697399,"_hasShrinkwrap":false},"0.2.0":{"name":"read-input","version":"0.2.0","description":"Easily read from stdin or files.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/rstacruz/read-input.git"},"keywords":["input","read","stdin"],"author":{"name":"Rico Sta. Cruz","email":"hi@ricostacruz.com"},"license":"MIT","bugs":{"url":"https://github.com/rstacruz/read-input/issues"},"homepage":"https://github.com/rstacruz/read-input","devDependencies":{"chai":"^1.9.1","mocha":"^1.21.3"},"gitHead":"ff3edcdc6d080ebba4f4218aa705b3ea8c2a9472","_id":"read-input@0.2.0","_shasum":"6e0e80bdf6f492d6b0d07819834e2acc8ee81d57","_from":".","_npmVersion":"1.4.16","_npmUser":{"name":"rstacruz","email":"rico@ricostacruz.com"},"maintainers":[{"name":"rstacruz","email":"rico@ricostacruz.com"}],"dist":{"shasum":"6e0e80bdf6f492d6b0d07819834e2acc8ee81d57","size":3296,"noattachment":false,"key":"/read-input/-/read-input-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/read-input/download/read-input-0.2.0.tgz"},"publish_time":1409117893960,"_cnpm_publish_time":1409117893960,"_hasShrinkwrap":false},"0.1.0":{"name":"read-input","version":"0.1.0","description":"Easily read from stdin or files.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/rstacruz/read-input.git"},"keywords":["input","read","stdin"],"author":{"name":"Rico Sta. Cruz","email":"hi@ricostacruz.com"},"license":"MIT","bugs":{"url":"https://github.com/rstacruz/read-input/issues"},"homepage":"https://github.com/rstacruz/read-input","devDependencies":{"chai":"^1.9.1","mocha":"^1.21.3"},"gitHead":"133672f98db9064a82fae67de93b9dcd31dfe512","_id":"read-input@0.1.0","_shasum":"ebbd5a5a4c80613df9722810819967fa962ad15b","_from":".","_npmVersion":"1.4.16","_npmUser":{"name":"rstacruz","email":"rico@ricostacruz.com"},"maintainers":[{"name":"rstacruz","email":"rico@ricostacruz.com"}],"dist":{"shasum":"ebbd5a5a4c80613df9722810819967fa962ad15b","size":2580,"noattachment":false,"key":"/read-input/-/read-input-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/read-input/download/read-input-0.1.0.tgz"},"publish_time":1407219595788,"_cnpm_publish_time":1407219595788,"_hasShrinkwrap":false}},"readme":"# read-input\n\nWrite CLI utilities that take a stream of data either stdin from one of more \nfiles. To be able to handle this:\n\n```sh\n$ yourutil file.txt\n$ yourutil file1.txt file2.txt\n$ yourutil < file.txt\n$ cat file.txt | yourutil\n```\n\nJust do this:\n\n```js\n#!/usr/bin/env node\nvar read = require('read-input');\nvar fnames = process.argv.slice(2);\n\nread(fnames, function (err, res) {\n  // `err` will be given if at least one of the files fail.\n  if (err) {\n    console.error(err.message);\n    process.exit(8);\n  }\n\n  res.data /* => \"...\" */\n});\n```\n\n<!-- include: index.js -->\n\n### read()\n> `read(files, function(err, res) { ... })`\n\nReads from files. If no files are given, read from stdin.\nThe result `res` is a [result object](#res). If any of the files can't be\nread, `err` will be an error object.\n\n```js\nvar read = require('read-input');\nvar fnames = process.argv.slice(2); //=> ['readme.txt']\n\nread(fnames).then(function (res) {\n  res.data       // '...'\n  res.error      // undefined or Error()\n  res.stdin      // true or false\n  res.files      // [...]\n  res.successes  // [...]\n  res.failures   // [...]\n}).catch(function (err) {\n  // stdin error\n});\n```\n\nTo support older versions of Node.js without Promises, you can use callbacks:\n\n```js\nread(fname, function (err, res) {\n});\n```\n\nYou can also iterate through `res.files`.\n\n```js\nread(fnames).then(function(res) {\n  res.files.forEach(function (f) {\n    f.data    // ...\n    f.error   // undefined or Error(...)\n    f.stdin   // true or false\n    f.name    // 'readme.txt'\n  }\n});\n```\n\nIf `files` is a blank array (or null), data will be read from stdin. The\nresulting data will have a similar schema.\n\n```js\nread([]).then(fucntion (res) {\n  ...\n});\n```\n\n### read.stdin()\n> `read.stdin(fn)`\n\nRead data from standard input. This will not throw errors.\n\n```js\nread.stdin().then(function (data) {\n  console.log(data); // string\n});\n\nread.stdin(function (err, data) {\n  ...\n});\n```\n\n### res\n\nThe results value is an object passed to the callback of `read()`.\n\n* `data` *(String)* <span class='dash'>&mdash;</span> a concatenation of all data in all the files.\n* `error` *(Error)* <span class='dash'>&mdash;</span> The first error in all files. `undefined` if successful.\n* `stdin` *(Boolean)* <span class='dash'>&mdash;</span> is `true` if the file is read from stdin\n* `files` *(Array)* <span class='dash'>&mdash;</span> A list of files.\n* `failures` *(Array)* <span class='dash'>&mdash;</span> A list of files that failed.\n* `successes` *(Array)* <span class='dash'>&mdash;</span> A list of files that succeeded.\n\nThe `files`, `failures` and `successes` are lists of files. Each of the items in these lists\nhas a similar list of values:\n\n* `data` *(String)* <span class='dash'>&mdash;</span> File data\n* `error` *(Error)* <span class='dash'>&mdash;</span> the first error encountered, if applicable\n* `stdin` *(Boolean)* <span class='dash'>&mdash;</span> is `true` if the file is read from stdin\n* `name` *(String)* <span class='dash'>&mdash;</span> File name\n\nThere's also `error.result` which refers to the result object.\n\nSee [read()](read) for an example.\n\n<!-- /include -->\n\n## Thanks\n\n**read-input** © 2014+, Rico Sta. Cruz. Released under the [MIT License].<br>\nAuthored and maintained by Rico Sta. Cruz with help from [contributors].\n\n> [ricostacruz.com](http://ricostacruz.com) &nbsp;&middot;&nbsp;\n> GitHub [@rstacruz](https://github.com/rstacruz) &nbsp;&middot;&nbsp;\n> Twitter [@rstacruz](https://twitter.com/rstacruz)\n\n[MIT License]: License.md\n[MIT License]: http://mit-license.org/\n[contributors]: http://github.com/rstacruz/nprogress/contributors\n","_attachments":{},"homepage":"https://github.com/rstacruz/read-input","bugs":{"url":"https://github.com/rstacruz/read-input/issues"},"license":"MIT"}