function SoundBox(){this.sounds={},this.sound_callbacks={},this.load=function(s,n){this.sounds[s]=new Audio(n),this.sounds[s].addEventListener("ended",function(n){n.target.currentTime=0,"function"==typeof this.sound_callbacks[s]&&(this.sound_callbacks[s](s),delete this.sound_callbacks[s])}.bind(this))},this.remove=function(s){"undefined"!=typeof this.sounds&&delete this.sounds[s],"function"==typeof this.sound_callbacks&&delete this.sound_callbacks[s]},this.play=function(s,n){return"undefined"==typeof this.sounds[s]?(console.error("Can't find sound called '"+s+"'."),!1):("function"==typeof n&&(this.sound_callbacks[s]=n),void this.sounds[s].play())}}

function SoundBox(){this.sounds={},this.load=function(a,b,c){return this.sounds[a]=new Audio(b),"function"==typeof c?void this.sounds[a].addEventListener("canplaythrough",c):new Promise(d=>this.sounds[a].addEventListener("canplaythrough",d),this.sounds[a].addEventListener("error",reject))},this.remove=function(a){"undefined"!=typeof this.sounds&&delete this.sounds[a],"function"==typeof this.sound_callbacks&&delete this.sound_callbacks[a]},this.play=function(a,b){if("undefined"==typeof this.sounds[a])return console.error("Can't find sound called '"+a+"'."),!1;var c=this.sounds[a].cloneNode(!0);return c.play(),"function"==typeof b?(console.log("Adding callback"),c.addEventListener("ended",b),!0):(console.log("Returning promise"),new Promise(d=>c.addEventListener("ended",d)))}}

Update minified version