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

zetta-scout

v1.0.0

Published

A Scout class for Zetta.

Downloads

32

Readme

zetta-scout

Installation

$ npm install zetta-scout --save

Reference and Usage

Class: Zetta.Scout

This is a class you inherit from when writing custom device drivers. Scouts are used to search for devices with external node modules, or protocols. It's used by require('zetta-scout'); or require('zetta').Scout;. You must inherit from the Scout class when building custom Zetta modules.

var util = require('util');
var Scout = require('zetta-scout');

function MyScout(){
  Scout.call(this);
}
util.inherits(MyScout, Scout);
Method: Scout#init(func)
  • func Function

This method should be implemented by you. This allows you to initialize any resources like bluetooth access, serial ports, or vendor modules needed to look for devices. The argument func is provided, and must be called after scouting has started.


MyScout.prototype.init = function(next) {
  var connection = Serial.connect(function(){
  });

  connection.on('start', function(){
    next();
  });
};
Method: Scout#discover(constructor, [arguments])
  • constructor Subclass of Device
  • arguments List of Objects

This method is called by you when you've found your device. The constructor argument should be a subclass of Device, and the second argument is a list of objects to be used by the constructor.

MyScout.prototype.init = function(next) {
  this.discover(MyDevice, foo, bar, 'baz');
};
Method: Scout#provision(deviceObject, constructor)
  • deviceObject Object
  • constructor Subclass of Device

Zetta will persist device data to an internal registry. Using an object retrieved from this registry you can initialize a device that Zetta already knows about. The first argument deviceObject is just data on the object from Zetta. The constructor argument is what will be created by Zetta.

MyScout.prototype.init = function(next) {
  var deviceObject = {
    name:'testObject',
    id: '123',
    foo: 'bar'
  };
  this.provision(deviceObject, MyDevice);
};
Property: Scout#server

This gives access to the zetta runtime. Here you can issue queries and lookup devices that Zetta already knows about.

MyScout.prototype.init = function(next) {
  var self = this;

  // query registry for any device that has type led and an id that we know of.
  var query = this.server.where({ type: 'lcd', id: 'some-id' });
  this.server.find(query, function(err, results) {
    if (results.length > 0) {
      // found in registry, tell zetta it came online
      self.provision(results[0], MyDevice, foo, bar, 'baz');
    } else {
      // does not exist in registry, discover a new one.
      self.discover(MyDevice, foo, bar, 'baz');
    }
  });
};