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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nisper

v0.8.3

Published

A RPC lib based on websocket protocol and nisp language

Downloads

113

Readme

Overview

Nisper is a RPC lib based on websocket protocol and nisp language.

NPM version Build Status Deps Up to Date

Features

  • Script based call makes the functions composable, you can even write a complex program to remote
  • Safe by design, full control of the user's authority
  • Same api for both node to browser, browser to node and node to node
  • Full support for Promise calls
  • Supports binary data type (json by default)
  • Bidirectional communication
  • Auto reconnect

Example

For more usage, read the unit test test/index.js.

Live Demo: https://runkit.com/ysmood/nisper2

Echo Example

Node Server:

import nisper from 'nisper';
import $ from 'nisp/lib/$';

const server = nisper({
    wsOptions: { port: 8080 },
    sandbox: {
        $,
        // Define a function, client can call it remotely.
        '+': (a, b) => a + b
    },
    onOpen: (ws) => {
        // When a client connected, call it
        server.call(ws, ['-', 2, 1]).then(res => {
            console.log('client res:', res); // => 1
        });
    }
});

Browser or node client:

import nisper from 'nisper';

const client = nisper({
    url: `ws://127.0.0.1:8080`,
    sandbox: {
        // Define a function, server can call it remotely.
        '-': (a, b) => a - b
    }
});

// add(1, add(1, 1))
client.callx`(+ 1 (+ 1 1))`.then(res => {
    console.log('server res:', res); // => 3
});

Composable async function & msgpack

import nisper from 'nisper';
import async from 'nisp/lib/async';
import msgpack from 'msgpack-lite';

const server = nisper({
    wsOptions: { port: 8080 },
    encode: msgpack.encode,
    decode: msgpack.decode,
    sandbox: {
        // Define a function, client can call it remotely.
        // This add function will return the sum after 1 second.
        '+': async((a, b) =>
            new Promise(resolve =>
                setTimeout(resolve, 1000, a + b)
            )
        )
    }
});

Browser or node client:

import nisper from 'nisper';
import msgpack from 'msgpack-lite';

const client = nisper({
    url: `ws://127.0.0.1:8080`,
    encode: msgpack.encode,
    decode: msgpack.decode
});

// add(1, add(1, 1))
client.call(['+', 1, ['+', 1, 1]]).then(res => {
    // It will log 3 after 2 second.
    console.log('server res:', res);
});

API

nisper = ({
    // node native http.Server
    httpServer: null,

    // string, such as `ws://a.com`
    url: null,

    sandbox: {},

    onOpen: (connection) => env,

    onRequest: () => env,

    error: (err) => Error,

    isAutoReconnect: true,
    retrySpan: 1000,
    timeout: 1000 * 60 * 2,

    encode: (Object) => String || Buffer,
    decode: (String) => Object,

    // Same options as ws: https://github.com/websockets/ws/blob/master/doc/ws.md
    wsOptions: Object,

    isDebug: false
}) => {
    sandbox: Object,
    close: Function,
    websocketClient: Object,
    websocketServer: Object,
    middleware: Function,
    call: Function
};

call only once

var call = require('nisper/lib/call');


call('ws://127.0.0.1:8080', ['echo', 'hi']).then(res => {
    console.log(res);
});