Socket
Socket
Sign inDemoInstall

main

Package Overview
Dependencies
8
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.17 to 0.0.18

9

examples/stdin.js
#!/usr/bin/env node
require('../index')(module).run(function($) {
// CALLBACK based
$.stdin(function(input) { // read from standard input
$.out(input); // write to standard output (process.stdout.write)
});
// PROMISE based
var stdin = $.stdin();
stdin.then(function(input) {
$.out(input);
});
});

6

package.json
{
"name": "main",
"version": "0.0.17",
"version": "0.0.18",
"main": "index.js",
"description": "Provides useful tools for writing command line scripts",
"repository": {

@@ -14,3 +15,4 @@ "type": "git",

"optimist": "~0.6.0",
"temp": "~0.6.0"
"temp": "~0.6.0",
"when": "~2.5.1"
},

@@ -17,0 +19,0 @@ "author": "Trevor Senior <trevor@tsenior.com> (http://tsenior.com/)",

@@ -83,3 +83,3 @@ node-main

##### `$.stdin(callback)`
##### `$.stdin(callback)` or `$.stdin()` (promise based)

@@ -89,4 +89,6 @@ Read from stdin in it's entirety, and return a string once finished in a callback. Do not use this if you are dealing with large amounts of data from stdin - look towards streaming solutions.

```javascript
// read from stdin, write to stdout
// read from stdin, write to stdout (callback based)
$.stdin(function(input) { $.out(input); });
// same thing with promises
$.stdin().then(function(input) { $.out(input); })
```

@@ -93,0 +95,0 @@

@@ -67,2 +67,5 @@ var extend = require('util')._extend;

self.stdin = function(callback) {
if (typeof callback === 'undefined') {
var defer = require('when').defer();
}
var stdinStr = '';

@@ -72,3 +75,8 @@ process.stdin.resume();

process.stdin.on('data', function(chunk) { stdinStr += chunk; });
process.stdin.on('end', function() { callback(stdinStr); });
process.stdin.on('end', function() {
return (typeof callback === 'function')
? callback(stdinStr) : defer.resolve(stdinStr);
});
if (defer) { return defer.promise; }
};

@@ -75,0 +83,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc