Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
es.addEventListener('failure', msg => {
es.close()
const data = parseJson(msg.data, {})
const error = new Error(data.message)
Object.keys(data).forEach(key => {
error[key] = data[key]
})
reject(error)
})
})
es.addEventListener('message', msg => {
const data = parseJson(msg.data, {})
if (!wantedProps.includes(data.type)) {
return
}
values[data.type] = data[data.type]
if (++numProps === wantedProps.length) {
resolve(values)
}
})
})
es.addEventListener('success', msg => {
es.close()
const data = parseJson(msg.data, {})
resolve(data.token)
})