How to use the zalgo-promise.ZalgoPromise.try function in zalgo-promise

To help you get started, we’ve selected a few zalgo-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paypal / paypal-smart-payment-buttons / test / client / mocks.js View on Github external
}

        for (const listener of listeners) {
            if (listener.name !== name) {
                continue;
            }

            if (win && listener.options.window && listener.options.window !== win) {
                continue;
            }

            if (domain && listener.options.domain && listener.options.domain !== domain) {
                continue;
            }

            return ZalgoPromise.try(() => listener.handler({ source: win, origin: domain, data }))
                .then(res => {
                    if (listener.promise) {
                        listener.promise.resolve(res || data);
                    }
                    return res;
                }, err => {
                    if (listener.promise) {
                        listener.promise.reject(err);
                    }
                    throw err;
                });
        }

        throw new Error(`No postRobot handler found for message name: ${ name }`);
    };