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

particle-usb

v2.8.0

Published

A library for accessing Particle USB devices

Downloads

2,315

Readme

particle-usb

CI

A library for accessing Particle USB devices.

Note: This library requires Particle firmware 0.8.0 or later.

Installation | Usage | API Reference | Development | Testing | Releasing | License

Installation

Using npm:

$ npm install particle-usb @particle/device-constants

NOTE: particle-usb declares @particle/device-constants as a peerDependency - this ensures your app only ever has one copy of that dependency

Usage

In Node.js:

import * as usb from 'particle-usb';

Enumerating devices

const devices = await usb.getDevices();
for (let device of devices) {
  console.log(device.type); // Prints device type, e.g. "Photon"
}

Opening devices

Most of the device methods, such as reset(), require the device to be open:

const devices = await usb.getDevices();
if (devices.length == 0) {
  throw new Error('No devices found');
}
const device = devices[0];
await device.open();
await device.reset(); // Resets the device

It is possible to open a device by ID:

const device = await usb.openDeviceById('0123456789abcdef01234567');
await device.reset();

The device should be closed when it is no longer needed:

await device.close();

API reference

For more information, read the API reference on GitHub.

Development

Installing

  1. Install Node.js [[email protected] and [email protected] are required]
  2. Clone this repository $ git clone [email protected]:particle-iot/particle-usb.git && cd ./particle-usb
  3. Install dependencies $ npm install
  4. View available commands $ npm run
  5. Run the tests $ npm test
  6. Start Hacking!

Testing

Particle USB has a number of automated test suites and related commands. The most important are:

  • npm test - run all tests
  • npm run test:e2e - run all end-to-end tests NOTE: Requires additional setup
  • npm run test:ci - run all tests excluding device-dependent end-to-end tests as CI does
  • npm run lint - run the linter and print any errors to your terminal
  • npm run coverage - report code coverage stats

All tests use mocha, chai, and sinon with coverage handled by nyc.

We recommend running locally if you can as it greatly shortens your feedback loop. However, CI also runs against every PR and error reporting is publicly available.

Releasing

For release instructions, see RELEASE.md

License

This library is released under the Apache 2.0 license. See LICENSE for details.