I'm trying to fix the webaudio package to work with Safari as it exposes webkitAudioContext instead of AudioContext.
proc newAudioContext*(): AudioContext {.importjs: "new AudioContext()".}
In Javascript you'd generally do something like:
var AudioContext = window.AudioContext // Default
|| window.webkitAudioContext // Safari and old versions of Chrome
|| false; // unsupported
var ctx = null;
if(AudioContext) {
ctx = new AudioContext();
}
Is there an idiomatic way of doing this with Nim's JS backend?
Something like:
proc newAudioContext*(): AudioContext {.importjs: "new (window.AudioContext || window.webkitAudioContext)()".}