function njsFactory(scope = {}) {
const utilName = 'NewJavaScript'
const errorMessageRegext = new RegExp(`^${utilName}`)
window.addEventListener('error', e => {
if (!errorMessageRegext.test(e.error)) return
e.preventDefault()
e.stopPropagation()
})
function getThrowMessage(msg) {
return `${utilName}:${msg}`
}
scope.whenReturn = function (expression) {
if (expression) {
throw getThrowMessage('whenReturn')
}
}
return scope
}
const njs = njsFactory({})
void function () {
console.log('ajax')
njs.whenReturn(1 !== 200)
console.log('do..')
}()
console