All files / serialization/utils prepost-array-of.js

40% Statements 6/15
29.41% Branches 5/17
57.14% Functions 4/7
50% Lines 5/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 22 23  156x                     234x 12x 78x         12x      
export function preArrayOf (index, detect, convert) {
  return (...args) => {
    if (Array.isArray(args[index])) {
      args[index] = args[index].map((item) => detect(item) ? convert(item) : item)
    }
 
    return args
  }
}
 
// specify falsey prop for root
export function postArrayOf (prop, detect, convert) {
  return (res) => {
    Eif (prop && res && Array.isArray(res[prop])) {
      res[prop] = res[prop].map((item) => detect(item) ? convert(item) : item)
    } else if (!prop && Array.isArray(res)) {
      res = res.map((item) => detect(item) ? convert(item) : item)
    }
 
    return res
  }
}