The same behavior implemented in different "flavors" of JavaScript.
Each implementation:
- exposes one function that takes one argument
div- a reference to DOM node to be populated. - populates
divwith contents of files listed indata/list.jsonproxied throughSPEC.getHtml()function
## pseudocode ##
execute = (div) =>
list = download('data/list.json')
if error
console.error('list DL failed', error¹)
div.innerHTML = 'list DL failed'
return
# must keep list.json order
for(index, fileContent of list)
if error
console.error("file(#{index}) DL failed", error¹)
div.innerHTML += SPEC.getHtml(i, SPEC.errorContent)
else
div.innerHTML += SPEC.getHtml(i, fileContent)
# ¹ - optional- JavaScript (es5, sync)
- JavaScript (es5, callbacks)
- JavaScript (es6, +promise)
- JavaScript (es6, +yield)
- JavaScript (es7, +async, +await)
- CoffeeScript
- Iced CoffeeScript
- Literate CoffeeScript
Go to https://meedamian.com/js-flows
$ git clone [email protected]:chester1000/js-flows.git
$ cd js-flows
$ python -m SimpleHTTPServer 8008
# In browser open http://localhost:8008// Execute specific flow:
execute('sync'); // or
execute('iced'); // etc
// See available flows:
execute('help');
// enable | disable artificial, random delay for each file download
DELAY_ENABLED = true | false;Press buttons to trigger execution of flows. First button enables/disables artificial delay.
At the time of publish no browser supported ES7 async functions, so pre-compiled fallback is provided (and loaded automatically).
Babel command used:
# From repo root:
$ npm i -g babel
$ npm i babel-preset-stage-0
$ babel --presets stage-0 main.es7.js -o main.es7.babel.js