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

@johntalton/i2c-port

v4.0.0

Published

Provides tooling that allows for `I2CBus` to be hosted natively, over `MessagePort`, within `Worker` and over `WebSockets`.

Downloads

4

Readme

I²C MessagePort based Bus

Provides tooling that allows for I2CBus to be hosted natively, over MessagePort, within Worker and over WebSockets.

npm Version GitHub package.json version CI GitHub Downloads Per Month GitHub last commit

This allows the I2CBus api to be used in a wide range of deployment cases.

It can also be using with bus Multiplexing such as @johntalton/i2c-bus-tca9548a that adheres to the I2CBus interface. As well as using i2c-bus as the default concrete/base implementation.

Provided Abstraction

Key is providing multiple abstraction layers.

  • A Message type definition (including Read, ReadResult, Error, etc)
  • An I2CPort function that maps Message into I2CBus commands on provided bus
  • And I2CPortBus which implements I2CBus over a MessagePort interface

The corresponding WebSocket to MessagePort example can be run to provide this service.

Message

The Message definition layer provides a naming convention and contract without implementation details. It is ideal for abstracting the service at each layer.

I2CPort

The port utility provides a handleMessage function. By which, given a provided I2CBus and Message, will execute that bus command.

const busX = ... // a I2CBus impl from somewhere
const result = await I2CPort.handleMessage(busX, {
  namespace: 'NS',
  type: 'readI2cBlock',
  address: 0x00,
  cmd: 0x00,
  length: 3
})

console.log(result)
/*
{
    namespace: 'NS',
    address: 0,
    type: 'readResult',
    bytesRead: 3,
    buffer: Uint8Array(3) [ 1, 3, 4 ]
    ...
}
*/

This message to bus method and back is particularly useful when abstracting the I2CBus class methods accros a MessagePort implementation such as I2CPortBbus.

I2CPortBus

The implementation of I2CBus allows for creating a instance classes which use the generic I2CBus interface and alow them to run atop of a MessagePort.

Useful application (as seen in the examples) of this are: - Workers: allow for running I2CBus implementation and Sensor across worker (shared i2c service for multiple workers) - WebSockets: allow for transmission of Message across a WebSocket to allow for remote i2c Sensor implementations.

ArrayBuffer and friends

The current implementation attempts to preserve a common ArrayBuffer interface across the implementation in order to provide flexibility