Browse Source

init

master
Sindre Sorhus 11 years ago
commit
2f3efbb11d
  1. 12
      .editorconfig
  2. 1
      .gitattributes
  3. 1
      .gitignore
  4. 19
      .jshintrc
  5. 3
      .travis.yml
  6. 15
      index.js
  7. 31
      package.json
  8. 32
      readme.md
  9. 10
      test.js

12
.editorconfig

@ -0,0 +1,12 @@
# editorconfig.org
root = true
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

1
.gitattributes

@ -0,0 +1 @@
* text=auto

1
.gitignore

@ -0,0 +1 @@
node_modules

19
.jshintrc

@ -0,0 +1,19 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true
}

3
.travis.yml

@ -0,0 +1,3 @@
language: node_js
node_js:
- '0.10'

15
index.js

@ -0,0 +1,15 @@
'use strict';
module.exports = function (cb) {
var ret = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (data) {
ret += data;
});
process.stdin.on('end', function () {
cb(ret);
});
};

31
package.json

@ -0,0 +1,31 @@
{
"name": "get-stdin",
"version": "0.0.0",
"description": "Easier stdin",
"license": "MIT",
"repository": "sindresorhus/get-stdin",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "echo unicorns | mocha"
},
"files": [
"index.js"
],
"keywords": [
"stdin",
"stdio",
"concat",
"buffer",
"stream"
],
"devDependencies": {
"mocha": "*"
}
}

32
readme.md

@ -0,0 +1,32 @@
# get-stdin [![Build Status](https://travis-ci.org/sindresorhus/get-stdin.png?branch=master)](https://travis-ci.org/sindresorhus/get-stdin)
> Easier stdin
## Install
```
npm install --save get-stdin
```
## Example
```js
// example.js
var stdin = require('get-stdin');
stdin(function (data) {
console.log(data);
//=> unicorns
});
```
```
$ echo unicorns | node example.js
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

10
test.js

@ -0,0 +1,10 @@
'use strict';
var assert = require('assert');
var stdin = require('./index');
it('should get stdin', function (cb) {
stdin(function (data) {
assert.equal(data.trim(), 'unicorns');
cb();
});
});
Loading…
Cancel
Save