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

ws-memory-store

v0.1.2

Published

Memory store based on WebSockets

Downloads

15

Readme

WS Memory Store

WS Memory Store is an in-memory data store based on WebSockets. It allows you to store and retrieve data through a simple WebSocket interface. The module consists of a server part written in Node.js and a client library for interacting with the server.

Installation

You can install the module using npm:

$ npm install -g ws-memory-store

Usage

Server

You can start the server using the serve command:

$ ws-memory-store serve -p 3000

Options:

  • -p, --port - port for running the server (default: 22922)

The server will listen for incoming WebSocket connections and handle messages for storing, retrieving, and deleting data.

Client Library

The ws-memory-store client library allows you to connect to the server and perform data storage and retrieval operations. The library supports both CommonJS modules and TypeScript.

Example usage with CommonJS

const { WsMemoryStore } = require("ws-memory-store/client");

const main = async () => {
  await WsMemoryStore.connect();
  const key = await WsMemoryStore.set('foo', 'bar');
  const value = await WsMemoryStore.get(key);
  console.log({ key, value });
  WsMemoryStore.disconnect();
};

main();

Example usage with TypeScript

import { WsMemoryStore } from "ws-memory-store/client";

const main = async () => {
  await WsMemoryStore.connect();
  const key = await WsMemoryStore.set('foo', 'bar');
  const value = await WsMemoryStore.get(key);
  console.log({ key, value });
  WsMemoryStore.disconnect();
};

main();

Client library methods:

  • connect({ host, port, http2 }) - establishes a connection with the server. Options:
    • host - server host (default: localhost)
    • port - server port (default: 22922)
    • http2 - use HTTP2 protocol (default: false)
  • disconnect() - closes the connection with the server
  • set(key, data) - stores data by key
  • get(key) - retrieves data by key
  • delete(key) - deletes data by key

Help

To get help on using the utility, you can use the help command:

$ ws-memory-store help

This will display a description of the commands and options for running the server.