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

@living-room/service-js

v0.6.20

Published

http, eventstream, socketio, and osc server for livingroom

Downloads

13

Readme

service-js

Creates a living room that you can connect to over HTTP, eventstreams, socket.io, and osc!

You can test it out by running npm start after installing the dependencies with npm install

For a better example with more context, processes and displays, see https://github.com/living-room/lovelace

For a nice javascript client, check out https://github.com/living-room/client-js

installing

npm install
npm start
npm test

example http

$ curl -d 'facts=curl is an app at (20, 30)' localhost:3000/assert
OK

$ curl -d 'facts=$who is an app at ($x, $y)' localhost:3000/select
{"assertions":[{"who":{"word":"curl"},"x":{"value":20},"y":{"value":30}}]}%

example socket.io

npm run serve:examples && open http://localhost:5000

from examples/browser.html

const socket = io.connect(`http://localhost:3000`)

// The pattern we want to match on
const pattern = 'ping $number'

let pong = 0

// To subscribe pass in the JSON of an array of patterns
const patternsString = JSON.stringify([pattern])

// We will get back an object, we just care about new assertions
socket.on(patternsString, ({assertions}) => {
  assertions.forEach(({number}) => {
    const value = parseInt(number.value)
    if (value > pong) pong = value
    console.log(`<- pong ${pong}`)
    pong++
  })
})
socket.emit('subscribe', patternsString)

// Start pinging from highest previous ping
setInterval(() => {
  socket.emit('assert', `ping ${pong}`, data => {
    console.log(`-> ${data[0]}`)
  })
}, 1500)

example opensoundcontrol

from examples/osc/osc.pde

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
  size(400,400);
  frameRate(25);
  oscP5 = new OscP5(this, 12000);

  myRemoteLocation = new NetAddress("127.0.0.1",41234);
}


void draw() {
  background(0);
}

void mousePressed() {
  OscMessage assertMessage = new OscMessage("/assert");
  assertMessage.add("processing is a program at (0.2, 0.3)");
  oscP5.send(assertMessage, myRemoteLocation);

  OscMessage assert2Message = new OscMessage("/assert");
  assert2Message.add("coolprocessing is a notherprogram at (0.4, 0.4)");
  oscP5.send(assert2Message, myRemoteLocation);

  OscMessage selectMessage = new OscMessage("/select");
  selectMessage.add("$name is a $type at ($x, $y)");
  oscP5.send(selectMessage, myRemoteLocation);
}

api

The http, socketio, and osc endpoints are all the same HTTP uses POST unless otherwise stated.

Add some facts

/assert facts=['some', 'facts', 'here']

Remove some facts

/retract facts=['some', 'facts', 'here']

Batch add and remove facts from the database

/ facts=[{assert: 'some'}, {retract: 'facts'}, {assert: 'here'}]

Find some facts that match a pattern

/select `facts='$what'`

Get all the facts

GET /facts