Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cosm

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cosm

A library for interfacing with Cosm http://cosm.com/

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
2
Weekly downloads
 
Created
Source

node-cosm

Cosm is the new name for Pachube.

"Connect devices and apps on the Cosm platform, exchange data and ideas with developers, and bring smart products to the world."

Install

$ npm install cosm

Use


    var cosm = require('cosm');
        client = new cosm.Cosm('insert API key here'),
        feed = new cosm.Feed(cosm, {id: 12345}),
        stream = new cosm.Datastream(client, feed, {id: 1})

    stream.addPoint(1.234); // Adds a data point with the timestamp now

    // Creates a datapoint at a specific timestamp
    stream.addPoint(2.345, new Date(2012, 11, 11, 11, 11);

    // Creates a datapoint now, with a callback - this API will likely change to
    // be a bit nicer to use.
    stream.addPoint(3.456, undefined, function () {
        console.log("Point added...");
    });

You can also create feeds, list existing feeds, add streams to a feed, and list streams associated with a feed:

client.create({ }, function(err, id) {
  if (err) return ...;
  
  feed2 = new cosm.Feed(cosm, { id: id });

  feed2.get(function(err, data) {
    if (err) return ...;

    // data is a json representation of the stream, including datastream metadata (if any)
    data.datastreams = data.datastreams || [];
  });

  feed2.addStream({ id: 2 }, function(err, body) {
    if (err) return ...;

    // body is presently null
  });
});

client.list({ /* query parameters, if any */ }, function(error, json) {
  if (err) return ...;
  
  // json is the metadata for the stream
});

READ THIS

You can queue data to be uploaded, by setting the queue_size for the Datastream, the API will only push data to Cosm when the queue is full.

    var stream = new cosm.Datastream(client, feed, {id: 1, queue_size: 20});

The queue_size defaults to 1, so data is pushed as it's added.

License

(The MIT License)

Copyright (c) 2012 Kevin McDermott.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Package last updated on 24 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc