all files / src/ getAudioContext.js

77.78% Statements 7/9
25% Branches 1/4
100% Functions 2/2
77.78% Lines 7/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                          11×        
/**
 * Ensures that there is only one Web Audio context per page.
 * Sets up a new AudioContext the first time it's called; then re-uses it.
 * @private
 * @returns {AudioContext} page-global Web Audio context
 */
var getAudioContext = (function() {
	let audioContext = null
 
	Eif (window.AudioContext !== undefined) {
		audioContext = new window.AudioContext()
	} else if (window.webkitAudioContext !== undefined) {
		/* eslint-disable new-cap */
		audioContext = new window.webkitAudioContext()
		/* eslint-enable new-cap */
	}
 
	function _getAudioContext() {
		return audioContext
	}
 
	return _getAudioContext
})()