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 500x 500x 500x 500x 2599x 2599x 2599x 2599x 2599x 1422x 1177x 1177x 1177x 1177x 500x | module.exports = {
name: 'map',
desc: 'applies f to each parsed JSON element and replaces it with f\'s result.',
func: (fs, {verbose}) => (jsons, lines) => {
let jsons2 = []
let err = []
for (let index = 0; index < jsons.length; index++) {
let obj = jsons[index]
try {
for (let jndex = 0; jndex < fs.length; jndex++) {
const f = fs[jndex]
if (typeof obj !== 'undefined') obj = f(obj)
}
jsons2.push(obj)
} catch (e) {
const msg = {msg: e.message}
const line = verbose > 0 ? {line: lines[index]} : {}
const info = verbose > 1 ? {info: JSON.stringify(obj, null, 0)} : {}
err.push(Object.assign(msg, line, info))
}
}
return {err, jsons: jsons2}
}
} |