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

@burns-fm/l-plx

v1.0.3

Published

Player data encoding methods and values.

Downloads

9

Readme

l-plx

Player data encoding methods and values.

Setup

Install dependencies and build. See package.json scripts.

Building

Build the library. The output code will appear in the dist folder. It should work on the web in browsers, and on Node without changes or further configuration.

Testing

Test the code. Run this if you make any changes to ensure your changes will respect the existing functionality. These tests will need updated if you want to keep your work consistent if you happen to change the return types or parameter shapes.

Usage

Encoding

encode

This function encodes and encrypts a byte array or stream of audio data. It takes two arguments:

  • data: a Uint8Array or ReadableStream containing the audio data
  • options: an object containing the following properties:
    • secretKey: a Uint8Array or string representing the secret key used to encrypt the data
    • iv: a Uint8Array or string representing the initialization vector used to encrypt the data

The function returns a Promise that resolves to a Uint8Array or ReadableStream containing the encrypted audio data.

encodeFromString

This function encodes and encrypts a string of audio data. It takes two arguments:

  • data: a string containing the audio data
  • options: an object containing the following properties:
    • secretKey: a Uint8Array or string representing the secret key used to encrypt the data
    • iv: a Uint8Array or string representing the initialization vector used to encrypt the data

The function returns a Promise that resolves to a Uint8Array or ReadableStream containing the encrypted audio data.

Decoding

decode

This function decodes and decrypts a byte array of encoded audio data. It takes two arguments:

  • data: a Uint8Array or ReadableStream containing the encoded audio data
  • options: an object containing the following properties:
    • secretKey: a Uint8Array or string representing the secret key used to decrypt the data
  • iv: a Uint8Array or string representing the initialization vector used to * decrypt the data

The function returns a Promise that resolves to a Uint8Array or ReadableStream containing the decrypted audio data.

decodeFromString

The decodeFromString function is used to decode and decrypt an audio file that is represented as a string of encrypted data. It takes two arguments:

  • encryptedData: a string containing the encrypted audio data
  • options: an object containing the following properties:
    • secretKey: a string representing the secret key used to decrypt the data
    • iv: a string representing the initialization vector used to decrypt the data
    • encoding: a string representing the encoding of the encrypted data (e.g. 'base64')

The function returns a Promise that resolves to a Uint8Array containing the decrypted audio data. This data can then be used to create an audio Blob and played using an HTMLAudioElement.

decodeToString

This function decodes and decrypts an encoded byte array of audio data and returns the decrypted data as a string. It takes two arguments:

  • data: a Uint8Array containing the encoded audio data
  • options: an object containing the following properties:
    • secretKey: a Uint8Array or string representing the secret key used to decrypt the data
    • iv: a Uint8Array or string representing the initialization vector used to decrypt the data

The function returns a Promise that resolves to a string containing the decrypted audio data.

Example

import { decodeFromString } from './decodeFromString';

const audioElement = document.getElementById('audio') as HTMLAudioElement;

async function playDecryptedAudio(encryptedData: string, options: EncoderOptions) {
  const decryptedData = await decodeFromString(encryptedData, options);

  const audioBlob = new Blob([decryptedData], { type: 'audio/mpeg' });
  const audioUrl = URL.createObjectURL(audioBlob);

  audioElement.src = audioUrl;
  audioElement.play();
}

const encryptedData = 'eW91bGxmaW5kd2hhdGV2ZXJ5b3Vnb2xvb2tpbmdmb3I...';
const options = {
  secretKey: '...',
  iv: '...',
  encoding: 'base64',
};

playDecryptedAudio(encryptedData, options);

This software is provided as-is. Do not use this for security-critical applications.

© 2022 Burns Recording Company