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

@hoobs/ipc

v1.0.11

Published

A library for local inter process communications on unix based systems.

Downloads

39

Readme

IPC

A library for local interprocess communications on unix based systems.

Installation

You can install this module into your project.

yarn add @hoobs/ipc

Options

Options for creating an IPC server or client.

import { IPCOptions } from "@hoobs/ipc";

const options: IPCOptions = {
    id: "test",
    root: "./",
    namespace: "example",
    encoding: "utf8",
    maxConnections: 100,
}

The example above creates a sock file example.test.sock in the application's root.

| variable | Required | description | | -------------- | -------- | --------------------------------------------------------------------------------------- | | id | Yes | a unique name for the socket | | root | No | the path to store the Unix sock file, default is the app root | | namespace | No | adds a domain to the sock files | | encoding | No | text encoding for socket messages, default is utf8 | | maxConnections | No | this is the max number of connections allowed to a socket, default is 100 (server only) |

Server

Below is an example of a server implantation.

There are two types listeners;

  • Event
  • Route

Events are designed as void functions, where routes return a payload. Routes accept a path, parameters, and a body. Both requests and results are JSON objects.

import { IPCServer } from "@hoobs/ipc";

const server = new IPCServer({
    id: "test",
    maxConnections: 100,
});

// EVENTS
server.on("host", (data) => {
    console.log(data);
});

// ROUTES
server.route("hello", (request, response) => {
    response.send({
        message: `Hello ${request?.params?.name}`,
    });
});

server.start();

Client

The client can access a server's events and routes. Below is an example of a client implantation.

The two methods are;

  • Emit
  • Fetch

Emit sends a request to the server and doesn't expect a result. Fetch works much like HTTP calls. You need to define the route using the path parameter, and excepts parameters and a body object. Fetch is a promise, so it needs to be called with await or using the then method.

import { IPCClient } from "@hoobs/ipc";

const client = new IPCClient({
    id: "test",
});

// EVENTS
client.emit("host", {
    ip: "127.0.0.1",
});

// ROUTES
client.fetch("hello", {
    name: "Luke Skywalker",
}).then((response) => {
    console.log(response);
});

Legal

This is a modified project orginally wrote by Brandon Nozaki Miller.

HOOBS and the HOOBS logo are registered trademarks of HOOBS Inc. Copyright (C) 2021 HOOBS Inc. All rights reserved.