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

argot

v0.1.10

Published

A language for the Internet of Things.

Downloads

33

Readme

argot Build Status

A language for the Internet of Things.

A JavaScript port of Argot SDK.

Documentation

Getting Started

Like all good node packages, you can find Argot in NPM.

Add Argot to your project with

npm install argot --save

Usage

Argot has a single entry point exported as a module, containing three functions that should fulfil all needs.

Pull it into your project with var argot = require('argot');

Of the available functions, one is to read dictionary files and the other two are for reading messages.

Argot.loadDictionary

Load dictionary takes an Argot Dictionary file, reads it and processes the contents into a Library containing data definitions.

  • Params: fileName - A file on disk
  • Returns: A Q promise containing a library

Example:

var argot = require('argot');

argot.loadDictionary('~/a/file/on/disk.dictionary')
  .then(function(lib) {
    // do something with the library here
  })
  .fail(function(err) {
    // uh-oh,
  });

Argot.readMessage

Read an Argot Message, a data type that includes dictionary defintions along with the message content.

  • Params: messageStream - A Node readable stream containing the data to be read. The data should conform to the Argot Message format.
  • Returns: A Q promise containing the read data and the library that has been built as part of the process

Example:

var argot = require('argot');

var stream = aStreamAppears();

argot.readMessage(stream)
  .then(function(libAndData) {
    var lib = libAndData[0];
    var data = libAndData[1];
    // do something with the data here
  })
  .fail(function(err) {
    // uh-oh,
  });

Read more about for format at Argot Message Format

Argot.read

Read some data from a stream.

  • Params:
    • library - A library containing data definitions
    • data - A Node readable stream of data to be read
    • type - Optional. The type of data being read, this should correspond to a type that the library knows about.
  • Returns: The read data. (This function performs no IO so we can run synchronously)

About Argot Definition identifiers, there are two identifiers, a Stream Id and a human readable name ('light.colour', 'person.name', etc). With Argot.js you only need to know about the name identifier. When you call read and supply a type name then Argot knows exactly how to build your data. But without the type, the stream Id needs to be the first thing in the data stream, as a prompt to direct Argot to the type that should be built.

For example, if you have a data type that has a Stream Id of 10 and a name of 'person', you can read an instance of that data with: argot.read(lib,data,'person')

For the same instance data, if you don't know that it's a 'person' type, but you do know that the stream begins with the Stream Id then the type name can be omitted. argot.read(lib,data)

Example, with known type:

var argot = require('argot');

argot.loadDictionary('~/a/file/on/disk.dictionary')
  .then(function(lib) {
    var stream = aStreamAppears();
    var data = argot.read(lib,stream,'yourtype');
    // do something with data
  })
  .fail(function(err) {
    // uh-oh,
  });

Example, with unknown type:

var argot = require('argot');

argot.loadDictionary('~/a/file/on/disk.dictionary')
  .then(function(lib) {
    var stream = aStreamAppears();
    var data = argot.read(lib,stream);
    // do something with data
  })
  .fail(function(err) {
    // uh-oh,
  });

Development

Check it out the project and run grunt to perform a style check (jshint) and run through the tests.

The main points of interest are:

  • argot.js is the main file
  • dictionary.js deals with loading dictionaries from a file
  • library.js is the Argot library data type

There are a few other files, mostly supplementary.

License

Copyright (c) 2014 Dan Midwood