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

iotdb-thing

v3.0.9

Published

IOTDB Module for Managing Things

Downloads

27

Readme

iotdb-thing

IOTDB Module for Managing Things

Introduction

This is a total / radical rewriting of our Thing manipulation library. It has no knowledge of Things, per se - it's meant to plug into our other modules such iotdb and iotql.

The goals are:

  • write around "band" concept
  • use ES6 javascript
  • use composition rather than classes
  • promises where appropriate
  • maximal orthogonality in code and interfaces
  • test driven development
  • 100% code coverage in tests

Examples

For the most part, Thing objects will be created for you and you just manipulate them as per below.

General Use

There are much deeper ways of using these objects, but these are the most common you'll want to use

Creation

const thing = require("iotdb-thing").thing;
const thing_1 = thing.make()
const thing_2 = thing.make({
    "model": …,
    "meta": …,
    "istate": …,
    "ostate": …,
    "connection": …,
});

Getting Values

thing_1.get(":temperature");
thing_1.get(":temperature", thing.as.fahrenheit());

Setting Values

thing_1.set(":on", true);
thing_1.set(":temperature", 20, thing.as.fahrenheit());

Bands

ostate

The ostate is used to manipulate a thing - it's the output state.

get the ostate

const ostate_1 = thing_1.band("ostate");

see the current values

const d = ostate_1.state();

set a value semantically

const promise = ostate_1.set(":on", true);

set a value non-semantically

const promise = ostate_1.set("power", true);

change a whole bunch of values (non-semantic). Note that update is always non-semantic, it's dealing the raw underlying data.

const promise = ostate_1.update({
    "power": true,
    "level": 50,
})

istate

The istate is used to current the current readings from a thing - it's the input state.

Get the istate object

const istate_1 = thing_1.band("istate");

See the current values

const d = istate_1.state();

Get a particular value semantically. first and list guarentee a non-array or an array respectively, get just returns what is there

const is_on_get = istate_1.get(":on")
const is_on_first = istate_1.first(":on")
const is_on_list = istate_1.list(":on")

Get a particular value non-semantically

const is_on_get = istate_1.get("powered")
const is_on_first = istate_1.first("powered")
const is_on_list = istate_1.list("powered")

Listen for a change semantically

istate_1.on(":on", function(_thing, _band, _new_value) {
});

Listen for a change non-semantically

istate_1.on("powered", function(_thing, _band, _new_value) {
});

Paramaterized Data

Because we have a strong idea of data types, you can parameterize values being passed into things; and you can coerce output values.

Helper functions parametization

ostate_1.set("level", 50, thing.as.percent());
ostate_1.set("level", .5, thing.as.unit());
ostate_1.set("temperature", 22, thing.as.celsius());

Coercing output value

istate_1.get("temperature", thing.as.celsius());

Getting type definitions

This will return a semantic description describing this particular attribute of the Thing.

thing_1.attribute("temperature")

or with a coercion

thing_1.attribute("temperature", thing.as.celsius());