All files / src/toOpts addRestOpts.js

100% Statements 13/13
100% Branches 6/6
100% Functions 4/4
100% Lines 10/10

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 2281x 81x 81x   81x 246x   246x 178x       81x     5x         830x  
const addRestOpts = (opts = []) => ({errs = [], opts: opts2 = []} = {}) => {
  const errs2 = []
  const opts3 = opts2
 
  for (let i = 0; i < opts.length; i++) {
    const opt = opts[i]
 
    if (!optsContainsOpt(opt, opts2)) {
      opts3.push(opt)
    }
  }
 
  return {errs: errs.concat(errs2), opts: opts3}
}
 
module.exports = {
  addRestOpts
}
 
function optsContainsOpt (opt, opts) {
  return opts.find(opt2 => opt2.key === opt.key)
}