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

ipcevt

v1.0.3

Published

A tiny socket based event system

Downloads

3

Readme

IPCEVT - An IPC event system over socket

This module is designed to provide simple event driven ipc system over native nodejs socket module.

How to install ?

Run the following command to install the module.

npm install ipcevt

Note that this library is written using es6 modules. Please remember to use following nodejs option to use the module

node --experimental-modules [your boot script path]

How to use ?

Server

The ipcevt server is designed as a simple broadcasting server that only receive connection and broadcast events among the clients.

Example
import crypto from "crypto";
import {IPCEvtServer} from "ipcevt";


(new IPCEvtServer())
.on( 'connected', (socket)=>{
	// emit when socket is connected to the server!
	// Note that the socket object will be persistent in other events too!
	socket.id = crypto.randomBytes(20).toString('hex');
	console.log( `${socket.id} is connected!` );
})
.on( 'disconnected', (socket)=>{
	// emit when socket is disconnected from the server!
	console.log( `${socket.id} is disconnected!` );
})
.on( 'netevt', (socket, event, evt_args)=>{
	// evt_args are raw buffers, you can manipulate if you want!
	console.log( `Receiving ${event} from ${socket.id} (contains ${evt_args.length} arguments)` );
})
.listen( 12334, 'localhost' );

Client

The ipcevt client is designed to behave like normal event emitters.

Example
import {IPCEvtClient} from "ipcevt";

const Client = new IPCEvtClient();

// Register the central serializer to serialize each event argument passed into emit function
Client._serializer = (input)=>{
    return Buffer.from(JSON.stringify(input), 'utf8');
};

// Register the central deserializer to automatically deserialize evey event arguments
Client._deserializer = (input)=>{
    return JSON.parse(input.toString('utf8'));
};


Client
.on( 'connected', function() {
	console.log( "Client has connected to the server!" );
    
    // Note that the input must be a Buffer or an error will be thrown
    // You can register the _serializer is to preprocess each argument!
	Client.emit( 'greeting', id, 'Hi! There!!!', {a:1, b:2, c:"123", d:Date.now()} );
})
.on( 'disconnected', function() {
	console.log( "Client has disconnected from the server!" );
})
.on( 'greeting', function(...args){
    // The arguments will be Buffer if the _deserializer is not registered!
	console.log(`Receiving [test-event]: `, ...args);
})
.connect( 12334, 'localhost' );