Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const receiveMessage = (type, args) => {
const isError = type === nativeErrorType;
for (let i = 0; i < queue.length; i++) {
const item = queue[i];
if (
(isError || item.type === type) &&
(!item.condition || item.condition(...args))
) {
if (isError) {
const { error, isFatal } = args[0];
item.reject(new NativeError(error.message, error.stack, isFatal));
} else {
item.resolve(args[0]);
}
queue.splice(i, 1);
break;
}
}
};