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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 2x 1x 1x 3x 3x 2x 3x 1x 2x 2x 2x 4x 2x | "use strict"; /** * Steps loader. * * @module */ var U = require("glace-utils"); var CONF = require("./config"); var Step = require("./step"); var utils = require("./utils"); /** * Loads steps from file. * * @function * @arg {string} filePaths - List of file paths. * @return {Step[]} List of steps. */ exports.loadSteps = filePaths => { filePaths = U.defVal(filePaths, CONF.gen.stepsFiles); Iif (!filePaths) { throw new U.GlaceError("Source file(s) with steps are not passed"); } var bucket = []; for (var filePath of filePaths.reverse()) { var data = utils.loadFile(filePath).reverse(); checkData(filePath, data); mergeSteps(bucket, data); } return getSteps(bucket.reverse()); }; var mergeSteps = (ss1, ss2) => { var s; var names = ss1.map(s => s.name); for (s of ss2) { Iif (names.includes(s.name)) continue; ss1.push(s); } }; /** * Checks steps consistency. * * @ignore */ var checkData = (file, data) => { var dups = utils.getDups(data.map(d => d.name)); Iif (dups.length) { throw new Error(`${file} contains duplicated steps: ${dups.join(", ")}`); } }; /** * Gets steps. * * @ignore * @function * @arg {object[]} data * @return {Step[]} */ var getSteps = data => { var ss = []; for (var d of data) { ss.push(new Step(d.name, d.weight, d.income, d.outcome, d.usage, d.do, d.expected, d.complete, d.incomplete, d.before, d.after)); }; return ss; }; |