npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

c3io

v0.1.0

Published

c3io exploits inter-process communication in order to communicate with other processes.

Downloads

2

Readme

c3io

c3io exploits stdin and stdout for inter-process communication in order to communicate with other processes.

If you only want to communicate with parent to child in nodejs you simply can use standard child_process communication.

WORK IN PROGRESS - NOT STABLE

Use cases

Have a look at c3docker using c3io as means of communicating with docker container.

Basic usage

var c3io  = require('c3io')(),
    spawn = require('child_process').spawn

c3io.on('message', function(msg) {
  // input request
  if ( msg.stdin ) {
    // send message [string]
    this.stdin = 'Hello World'
  }
  // stderr stream
  else if ( msg.stderr ) {
    console.log('stderr', msg.toString('utf8'))
  }
  // stdout stream
  else {
    console.log('stdout', msg.toString('utf8'))
  }
})

var child = spawn(
    'casperjs',
    ['test.js'],
    {stdio: c3io})

First a new c3io instance is created, which is basically an EventEmitter. Then you can listen to message as you would with child processes. Your child process can invoke this with simple commands. Here e.g. for casperjs.

var system = require('system'),
    casper = require("casper").create();

system.stdout.write('Hello, system.stdout.write!\n');

system.stdout.writeLine("c3io!req");
var line = system.stdin.readLine();
system.stdout.writeLine(line);

casper.echo('c3io!stp');
casper.exit();

notice for c3io is each line a command to be passed on. For that make sure it ends with an EOL.

As you maybe noticed there is also the abillity to push for certain commands. First there is the initial c3io! telling c3io to look for the given command. You can change the initial sequence within the enviroment.

env c3ctr="foo" c3len=1 node example.js

c3len configures how long the command name is. [default: 3] Currently there are following sequences. (for usage see latter example)

  • c3io!req

triggers an message event in order to replay to the input request

c3io!stp is c3docker specific.

custom commands

It is possible to define your own commands.

var c3io = require('c3io')

c3io.r2d2.wrt = function(_data) {
  // create response
  var write = function() {
    c3io.r2d2.call(this, _data)
    // do stuff e.g. write data to filesystem
    require('fs').writeFile('example.txt', _data)
  }
  // inheriting from c3io.r2d2 makes sure that standard methods are given in the response
  // c3io.r2d2 inherits from Buffer
  util.inherits(write, c3io.r2d2)
  return new write;
}

And executing the command in child process.

var system = require('system'),
    file_c = "Write something to File!"

// if you have line breaks within string make sure to handle them. e.g. through serializing.
system.stdout.writeLine("c3io!wrt" + file_c);

Installation

npm install c3io --save

or directly from github

npm install fentas/c3io