Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opus-decoder

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opus-decoder - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

package.json
{
"name": "opus-decoder",
"version": "0.3.0",
"version": "0.3.1",
"description": "Web Assembly streaming Opus decoder",

@@ -5,0 +5,0 @@ "main": "dist/opus-decoder.min.js",

# `opus-decoder`
`opus-decoder` is a Web Assembly Opus audio decoder.
* 87.2 KiB minified bundle size
* 87.4 KiB minified bundle size
* Browser and NodeJS support
* Built in Web Worker support

@@ -6,0 +7,0 @@ * Based on [`libopus`](https://github.com/xiph/opus)

@@ -7,4 +7,6 @@ import OpusDecodedAudio from "./OpusDecodedAudio.js";

export default class OpusDecoder {
constructor() {
this._ready = new Promise((resolve) => this._init().then(resolve));
constructor(_OpusDecodedAudio, _EmscriptenWASM) {
this._ready = new Promise((resolve) =>
this._init(_OpusDecodedAudio, _EmscriptenWASM).then(resolve)
);
}

@@ -30,19 +32,22 @@

async _init() {
// injects dependencies when running as a web worker
async _init(_OpusDecodedAudio, _EmscriptenWASM) {
if (!this._api) {
let isMainThread;
const isWebWorker = _OpusDecodedAudio && _EmscriptenWASM;
try {
if (wasm || !wasm) isMainThread = true;
} catch {
isMainThread = false;
}
if (isWebWorker) {
// use classes injected into constructor parameters
this._OpusDecodedAudio = _OpusDecodedAudio;
this._EmscriptenWASM = _EmscriptenWASM;
if (isMainThread) {
// running as a webworker, use class level singleton for wasm compilation
this._api = new this._EmscriptenWASM();
} else {
// use classes from es6 imports
this._OpusDecodedAudio = OpusDecodedAudio;
this._EmscriptenWASM = EmscriptenWASM;
// use a global scope singleton so wasm compilation happens once only if class is instantiated
if (!wasm) wasm = new EmscriptenWASM();
if (!wasm) wasm = new this._EmscriptenWASM();
this._api = wasm;
} else {
// running as a webworker, use class level singleton for wasm compilation
this._api = new EmscriptenWASM();
}

@@ -95,3 +100,3 @@ }

return new OpusDecodedAudio(
return new this._OpusDecodedAudio(
[

@@ -118,3 +123,3 @@ this._leftArr.slice(0, samplesDecoded),

return new OpusDecodedAudio(
return new this._OpusDecodedAudio(
[

@@ -121,0 +126,0 @@ OpusDecoder.concatFloat32(left, samples),

@@ -10,8 +10,6 @@ import Worker from "web-worker";

"'use strict';" +
EmscriptenWASM.toString() +
OpusDecodedAudio.toString() +
OpusDecoder.toString() +
`(${(() => {
// dependencies need to be manually resolved when stringifying this function
`(${((_OpusDecoder, _OpusDecodedAudio, _EmscriptenWASM) => {
// We're in a Web Worker
const decoder = new OpusDecoder();
const decoder = new _OpusDecoder(_OpusDecodedAudio, _EmscriptenWASM);

@@ -67,3 +65,3 @@ const detachBuffers = (buffer) =>

};
}).toString()})()`;
}).toString()})(${OpusDecoder}, ${OpusDecodedAudio}, ${EmscriptenWASM})`;

@@ -70,0 +68,0 @@ const type = "text/javascript";

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc