Skip to content
meeDamianPublic

About

Examples of different JS flows.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

JavaScript Flows

The same behavior implemented in different "flavors" of JavaScript.

Behavior

Each implementation:

  1. exposes one function that takes one argument div - a reference to DOM node to be populated.
  2. populates div with contents of files listed in data/list.json proxied through SPEC.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

Implementations

Run

Online

Go to https://meedamian.com/js-flows

Locally

$ git clone [email protected]:chester1000/js-flows.git
$ cd js-flows
$ python -m SimpleHTTPServer 8008

# In browser open http://localhost:8008

Usage

In Developer's Console (⌘⇧J for Chrome on Mac):

// 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;

In browser

Press buttons to trigger execution of flows. First button enables/disables artificial delay.

Notes

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

About

Examples of different JS flows.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages