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

@sovpro/heos-stream

v1.0.3

Published

Node.js streams for HEOS protocol communication over a socket

Downloads

7

Readme

Heos Stream

Node.js streams for HEOS protocol communication over a socket

HeosStream

Constructor

Construct an instance with a Socket obtainable via net.createConnection() or new net.Socket()

const {HeosStream} = require ('@sovpro/heos-stream')
const heos_stream = new HeosStream (socket)

Writing

Writing requires objects implementing a commmand object interface.

Command object interface

The comand interface is an object with a string command and object params property. command represents the host and pathname of a HEOS command url*.

const command_object = {
  command: 'string' ,
  params: {
    key: value ,
    // , key2: value 
    // , ...
  } 
}
heos_stream.write (command_object)

The key value pairs correspond to query string parameters that are appended to the HEOS command.

* host and pathname are the command group and command according to the specification.

Reading

Reading provides data objects that are one of:

  • HeosData
  • HeosResult
  • HeosEvent

HeosData

All data provided by HeosStream is a HeosData instance consisting of a message and command property. A HeosResult or HeosEvent is provided if the data is determined to a be a result or an event.

Properties:

  • message : A key value object
  • command : The command that caused this data

HeosResult

HeosResult represents data that is known to be a command result.

Properties accompanying those from HeosData

  • result : A string that is either 'success' or 'fail'
  • payload : May be undefined, object or an array
  • options : May be undefined or an array

HeosEvent

HeosEvent represents data that is known to be a HEOS event.

Properties accompanying those from HeosData

  • event : A string name of the event (excluding 'event/' prefix)

Filtered Streams

There are two streams emitting data filtered to results (HeosResult) or events (HeosEvent).

HeosResultStream

An opt-in filtered stream that emits result (HeosResult) data with a command matching on of those provided to the constructor.

const result_stream = new HeosResultStream ([
  'player/set_volume'  ,
  'player/set_mute'    ,
  'player/toggle_mute' , 
  // ...
])
heos_stream.pipe (result_stream)
result_stream.on ('data', result_data => {
  // result_data.command will be one of
  // the commands provided to the constructor
  const {command, message} = result_data
})

HeosEventStream

An opt-in filtered stream that emits event (HeosEvent) data with a name matching one of those provided to the constructor.

const event_stream = new HeosEventStream ([
  'player_volume_changed'  ,
  // ...
])
heos_stream.pipe (event_stream)
event_stream.on ('data', event_data => {
  // event_data.event will be one of
  // the events provided the constructor
  const {event} = event_data
})

Links

Notice

This unsponsored software is provided, subject to a MIT license, unofficially and independently of Sound United, LLC, its affiliates, subsidiaries and brands (such as HEOS, Denon and any such not listed here).