From cc454f2f725e6f4f4c796505b70e5a4fcd10d118 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 31 Mar 2017 12:02:36 -0400 Subject: [PATCH 1/2] Return the loader promise for chaining --- src/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index a5db0e7..4649b20 100644 --- a/src/index.js +++ b/src/index.js @@ -76,8 +76,7 @@ AudioEngine.prototype.decodeSound = function (sound) { } var storedContext = this; - - loaderPromise.then( + return loaderPromise.then( function (decodedAudio) { storedContext.audioBuffers[sound.md5] = new Tone.Buffer(decodedAudio); }, @@ -319,4 +318,3 @@ AudioPlayer.prototype.setVolume = function (value) { }; module.exports = AudioEngine; - From 6128309d93be82ad93903c8ce14cc4b5d4a1acdc Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 31 Mar 2017 12:09:07 -0400 Subject: [PATCH 2/2] Add jsdoc for decodeSound function --- src/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.js b/src/index.js index 4649b20..db9b645 100644 --- a/src/index.js +++ b/src/index.js @@ -59,6 +59,10 @@ function AudioEngine () { * Decode a sound, decompressing it into audio samples. * Store a reference to it the sound in the audioBuffers dictionary, indexed by md5 * @param {Object} sound - an object containing audio data and metadata for a sound + * @property {Buffer} data - sound data loaded from scratch-storage. + * @property {string} format - format type, either empty or adpcm. + * @property {string} md5 - the MD5 and extension of the sound. + * @returns {?Promise} - a promise which will resolve after the audio buffer is stored, or null on error. */ AudioEngine.prototype.decodeSound = function (sound) {