JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q63094F
  • License Apache-2.0

Decentralised music based on Hypercore

Package Exports

  • dcent-beats
  • dcent-beats/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dcent-beats) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Dcent Beats

Decentralised music using the Hypercore protocol.

Built on top of hyperdrive.

Install

npm i dcent-beats

API

const dBeats = new DcentBeats(drive, location)

Create a new Dcent Beats instance.

drive is a Hyperdrive instance, and location the folder where the music lives.

const key = dBeats.key

Returns the key corresponding to the underlying hyperdrive.

const blobsKey = dBeats.blobsKey

Returns the key corresponding to the underlying hyperdrive's blobs hypercore.

const dBeats = await dBeats.put(blob)

Upload a song. blob should contain the raw bytes of an mp3 file.

const dBeats = await dBeats.exists()

Returns true if a song exists at the location of this dcent beats instance, false otherwise.

const blob = await dBeats.get()

Get the audio as a blob of bytes.

const stream = dBeats.createReadStream()

Returns the audio stream of the song.

const metadata = await dBeats.getMetadata()

Get the metadata corresponding to this Dcent Beats song.

The metadata is an object:

{
  year, // Year of publishing
  title, // Song title
  artist, // Song artist
  durationSec, // Song duration in seconds
  version // internal version info ({ major, minor })
}

const cover = await dBeats.getCover()

Return the song's cover image (null otherwise).

cover is an object:

{
  data, // The raw data of the image (bytes)
  format, // The image format, as used in an html <img> tag (e.g. 'image/jpeg')
  major, // int: the major version of this cover structure
  minor / int: the minor version of this cover structure
}

await dBeats.close()

Close the dcent beats instance, cleaning up its hyperdrive session.

await dBeats.ready()

Open the dcent beats instance, ensuring its hyperdrive session is opened.