Coder Social home page Coder Social logo

alex-spark / sparkjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from particle-iot/sparkjs

0.0 2.0 0.0 1.26 MB

Spark JavaScript SDK

Home Page: https://www.spark.io/

License: Apache License 2.0

Makefile 1.09% HTML 1.64% JavaScript 94.78% CSS 2.49%

sparkjs's Introduction

SparkJS: A Javascript library for Spark devices

SparkJS is a library for interacting with your cores and the Spark Cloud. It uses node.js and can run on Windows, Mac OS X, and Linux fairly easily. It can also run in the browser without node.js. It's also open source so you can edit, change or even send in pull requests if you want to share!

Documentation

Complete documentation can be found in Spark Docs

Installation

First, make sure you have node.js installed!

Next, open a command prompt or terminal, and install by typing:

$ npm install -g spark

Usage

var Spark = require('spark');

Spark.login({ username: '[email protected]', password: 'password' }, function(err, body) {
  console.log('API call login completed on callback:', body);
});

For further examples visit /examples directory: https://github.com/spark/sparkjs/tree/master/examples

Complete documentation can be found in Spark Docs

Getting Started

It's important that you login before executing any command.

Every function returns a promise for you to handle the async result, or you can pass a callback function. (Please note that if a callback function is passed, the function will return null instead of a promise)

More examples on how to use promises/callbacks visit: https://github.com/spark/sparkjs/tree/master/examples

Supported commands

  • compileCode
  • createUser
  • callFunction
  • claimCore
  • downloadBinary
  • flashCore
  • getAttributes
  • getAttributesForAll
  • getEventStream
  • getVariable
  • listDevices
  • login
  • onEvent
  • publishEvent
  • removeCore
  • removeToken
  • renameCore
  • signalCore

Device object

You can get a list of devices by calling: Spark.devices

Each device has the following parameters:

  • name
  • connected
  • variables
  • functions
  • version
  • requiresUpgrade

And you can call the following commands on it:

  • callFunction
  • claim
  • flash
  • subscribe
  • getVariable
  • onEvent
  • remove
  • rename
  • sendPublicKey
  • signal
  • stopSignal
  • getAttributes

Complete documentation can be found in Spark Docs

Setup your dev environment

Install your local dependencies:

$ npm install

Install globally mocha, istanbul uglify-js and jshint

$ npm install -g mocha
$ npm install -g istanbul
$ npm install -g uglify-js
$ npm install -g jshint

How to test

make test

Lint your code

make lint

Coverage report

make cover

Release History

Version 0.1.0 Initial release Version 0.2.1 Publishing, test release Version 0.2.2 Pulling in getDevice Version 0.2.4 adding some basic parsing to the getEventStream function, now returns an object Version 0.2.5 fixing a callback param bug in getEventStream Version 0.2.6 fixing minified js

sparkjs's People

Contributors

edgarsilva avatar towynlin avatar dmiddlecamp avatar moors7 avatar kennethlimcp avatar sjlu avatar suda avatar

Watchers

James Cloos avatar Alex Davis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.