All files / src index.js

100% Statements 8/8
100% Branches 3/3
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                  1x 2x 2x   2x 11x 33x 11x         2x        
import JSONEngine from "./engines/json.js"
import markupEngine from "./engines/markup.js"
import SPAEngine from "./engines/spa.js"
 
/**
 * @param {Array<object>} schemas A list of schemas following the default and/or custom engines registered.
 * @param {Array<Promise>} customEngines A list of custom engines to be registered.
 * @return {Promise} Returns a promise with data sources.
 */
const Tatooine = (schemas, customEngines = []) => {
  const engines = [JSONEngine, markupEngine, SPAEngine, ...customEngines]
  let sources = []
 
  schemas.map((schema) => {
    engines.forEach(({ engine, run }) => {
      if (engine === schema.engine) {
        sources = [...sources, run(schema)]
      }
    })
  })
 
  return Promise.all(sources)
}
 
export default Tatooine