matatk / audiochart

Allows the user to experience charts on web pages using sound.

Home Page:http://matatk.agrip.org.uk/audiochart/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move to using const and let

matatk opened this issue · comments

This will be possible when PhantomJS 2.5 is out: ariya/phantomjs#14506

Have moved from PhantomJS to Karma, running the browsers for real (using headless Chrome on Travis). The tests and most of the main code have now been moved to using const and let, however...

Can't fully move to using ES6 until #38 is done, because currently everything's attached to window using var. (Before moving to NPM scripts, "exports.js" handled this, but the current build doesn't use it, and it doesn't seem time-efficient to fix that until after I have grokked how to properly re-assmenble the separated-out flies for production; using uglify's --wrap option looks like the right way.)

Update: rollup should be used when moving to ES6 modules.

This can't be fully implemented until I've found the idiomatic way to do exposing things for test, and for wrapping all the internal API stuff for minification/production.

Current constraints (using spec/AudioChart.spec.js as an example):

  • Jasmine can spy on getAudioContext() when it's declared as a var because it's on window. But I want to declare as const.
  • If I declare it as const then, if I could also run each (source script, test spec) pair of scripts in a separate environment, then I could easily stub out getAudioContext()—but Karma doesn't support this; all source files are included at once in the browser window, so getAudioContext() is already declared and I can't stub it out, as that's a redeclaration of a const.