Socket
Book a DemoInstallSign in
Socket

audio-context-singleton

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-context-singleton - npm Package Compare versions

Comparing version

to
1.2.0

34

index.js

@@ -12,23 +12,16 @@ /* global webkitAudioContext */

function getCurrentContext(done) {
function getCurrentContext() {
var { done } = organizeParams(arguments);
if (audioContext) {
// Warning: opts passed to getCurrentContext are ignored in this case.
// TODO: Think about what to do about this.
resolvedPromise.then(() => done(null, audioContext));
} else {
getNewContext(done);
getNewContext(arguments);
}
}
function getNewContext(firstParam, secondParam) {
var opts;
var done;
function getNewContext() {
var { opts, done } = organizeParams(arguments);
if (typeof firstParam === 'function') {
done = firstParam;
} else if (typeof secondParam === 'function') {
done = secondParam;
if (typeof firstParam === 'object') {
opts = firstParam;
}
}
if (audioContext) {

@@ -55,2 +48,15 @@ audioContext.close().then(passNewContext);

function organizeParams(firstParam, secondParam) {
var done, opts;
if (typeof firstParam === 'function') {
done = firstParam;
} else if (typeof secondParam === 'function') {
done = secondParam;
if (typeof firstParam === 'object') {
opts = firstParam;
}
}
return { done, opts };
}
module.exports = AudioContextSingleton;
{
"name": "audio-context-singleton",
"version": "1.1.2",
"version": "1.2.0",
"description": "When you want to have an audioContext singleton but don't want to rewrite [this code](index.js), use this. Deals with browser differences in AudioContext and maintains the singleton.",

@@ -5,0 +5,0 @@ "main": "index.js",