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

frcp

v0.1.1

Published

An FRCP library and client.

Downloads

3

Readme

FRCP library for Node.JS

Build Status

npm install frcp

An implementation of the FRCP protocol for node.

Project status:

  • Expected to work

Not yet:

  • RELEASE not implemented
  • Completely stable APIs
  • Comprehensive tests
  • Measured test coverage
  • Comprehensive documentation
  • Known to be used in production (if anyone is using it in production, do let me know)

Client API example

More extended examples can be found in the example directory

Low-level API

var _ = require('underscore');
var frcp = require('frcp');

frcp.init({uri: process.argv[2] || 'amqp://localhost'});

var state = {
  propA: 23,
  propB: 'hi'
};
var propNames = _.keys(state);

// Monitoring a resource
//
var r = frcp.resource('foo')
  .onRequest(function(props) {
    if (!props) { return state; } // return everything
    var reply = {};
    _.each(_.intersection(_.keys(props), propNames), function(p) {
      reply[p] = state[p];
    });
    return reply;
  })
  .onConfigure(function(props) {
    var reply = {};
    _.each(_.intersection(_.keys(props), propNames), function(p) {
      reply[p] = state[p] = props[p];
    });
    return reply;
  })
  .onCreate(function(type, props, frcpProxy) {
    var s = {propC: 64};
    frcpProxy.onRequest(function() { return s; });
    return s;
  })
  ;

// Send an immediate INFORM message
r.inform(state);

// Stop monitoring after some time
setTimeout(function() { r.cancel(); }, 3000);

High-level API

var frcp = require('frcp');

frcp.init({uri: process.argv[2] || 'amqp://localhost'});

// Define a simple object with a single property 'rpm'
var Engine = function(opts) {
  var rpm = opts.rpm || 2000;
  var my = function() {};
  
  my.rpm = function(val) {
    if (!arguments.length) return rpm;
    rpm = val;
    return my;
  };
  return my;
}
// Describe object
context =  {
  type: 'http://schema.mytestbed.net/tut01/engine',
  rpm: {
    type: 'http://www.w3.org/2001/XMLSchema#integer',
    _getSet: 'rpm'
  }
}
// Create an engine and make it available as 'eng1'
frcp.proxy('eng1', Engine(), context);

Running tests

npm test

Best run with a locally-installed RabbitMQ, but you can point it at another using the environment variable URL; e.g.,

URL=amqp://dev.rabbitmq.com npm test

NB You may experience test failures due to timeouts if using the dev.rabbitmq.com instance.

Lastly, setting the environment variable LOG_ERRORS will cause the tests to output error messages encountered, to the console; this is really only useful for checking the kind and formatting of the errors.

LOG_ERRORS=true npm test

Test coverage

make coverage
open file://`pwd`/coverage/lcov-report/index.html