'use strict'module.exports=parseJsonfunctionparseJson(txt,reviver,context){context=context||20try{returnJSON.parse(txt,reviver)}catch(e){if(typeoftxt!=='string'){constisEmptyArray=Array.isArray(txt)&&txt.length===0consterrorMessage='Cannot parse '+(isEmptyArray?'an empty array':String(txt))thrownewTypeError(errorMessage)}constsyntaxErr=e.message.match(/^Unexpected token.*position\s+(\d+)/i)consterrIdx=syntaxErr?+syntaxErr[1]:e.message.match(/^Unexpected end of JSON.*/i)?txt.length-1:nullif(errIdx!=null){conststart=errIdx<=context?0:errIdx-contextconstend=errIdx+context>=txt.length?txt.length:errIdx+contexte.message+=` while parsing near '${start===0?'':'...'}${txt.slice(start,end)}${end===txt.length?'':'...'}'`}else{e.message+=` while parsing '${txt.slice(0,context*2)}'`}throwe}}