Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const createLazyDeferred = () => {
let state;
let resolvedWith;
let rejectedWith;
let resolveCallback;
let rejectCallback;
const promise = new pLazy((resolve, reject) => {
if (state === 'resolved') {
resolve(resolvedWith);
} else if (state === 'rejected') {
reject(rejectedWith);
} else {
resolveCallback = resolve;
rejectCallback = reject;
}
});
return {
promise,
resolve: val => {
if (resolveCallback) {
resolveCallback(val);
} else {