Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stdio

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stdio

Node.js module for standard input/output management

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20K
decreased by-57.23%
Maintainers
1
Weekly downloads
 
Created
Source

Module for input/output management with nodejs.

Build Status

Installation

To install the most recent release from npm, run:

npm install stdio

Usage

You can do many things with this module

Read standard input at once

var stdio = require('stdio');
stdio.read(function(data){
    console.log(data);
});

Parse Unix-like command line options

var stdio = require('stdio');
var ops = stdio.getopt({
    'check': {key: 'c', args: 2},
    'map': {key: 'm'},
    'kaka': {key: 'k', args: 2},
    'ooo': {key: 'o'}
});
console.log(ops);

If you run the previous example with the command

node pruebas.js -c 23 45 88 --map -k 23 44 cosa

Program output will be:

{ check: { args: [ '23', '45' ] },
  args: [ '88', 'cosa' ],
  map: true,
  kaka: { args: [ '23', '44' ] } }

So you can check options:

if(ops.map){
    // Your action
}
if(ops.kaka){
    // Your action, using ops.kaka[0] or ops.kaka[1] or...
}

Printf-like output

This simple line:

stdio.printf('example %d: %s is %j\n', 2, 'any', {a: 2, b: [0, 2, 8], c: 'str'});

will produce the following output:

example 2: any is {"a":2,"b":[0,2,8],"c":"str"}

You can use %s for strings, %d for numbers (integer or floating-point ones), and %j for JSON objects.

Keywords

FAQs

Package last updated on 30 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc