How to use the zalgo-promise/src.ZalgoPromise.hash 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 / src / button / button.js View on Github external
const setupPrerenderTask = initPromise.then(() => {
        return ZalgoPromise.hash({ prerenderDetails: getPrerenderDetails(), initPromise }).then(({ prerenderDetails }) => {
            if (!prerenderDetails) {
                return;
            }

            const { win, fundingSource, card } = prerenderDetails;
            const button = document.querySelector(`[${ DATA_ATTRIBUTES.FUNDING_SOURCE }=${ fundingSource }]`);

            if (!button) {
                throw new Error(`Can not find button element`);
            }

            const payment = { win, button, fundingSource, card };
            const payPromise = initiatePayment({ payment });

            // $FlowFixMe
            button.payPromise = payPromise;
github krakenjs / post-robot / src / serialize / window.js View on Github external
focus() : ZalgoPromise {
        const isPopupPromise = this.isPopup();
        const getNamePromise = this.getName();

        const reopenPromise = ZalgoPromise.hash({ isPopup: isPopupPromise, name: getNamePromise }).then(({ isPopup, name }) => {
            if (isPopup && name) {
                window.open('', name);
            }
        });
        const focusPromise = this.serializedWindow.focus();

        return ZalgoPromise.all([
            reopenPromise,
            focusPromise
        ]).then(() => this);
    }
github paypal / paypal-smart-payment-buttons / src / payment-flows / native.js View on Github external
const getSDKProps = () : ZalgoPromise => {
        return ZalgoPromise.hash({
            orderID: createOrder(),
            pageUrl: getPageUrl()
        }).then(({ orderID, pageUrl }) => {
            const userAgent = getUserAgent();
            const webCheckoutUrl = getWebCheckoutUrl({ orderID });
            const forceEligible = isNativeOptedIn({ props });

            return {
                orderID, facilitatorAccessToken, pageUrl, commit, webCheckoutUrl,
                userAgent, buttonSessionID, env, stageHost, apiStageHost, forceEligible
            };
        });
    };
github krakenjs / zoid / dist / module / component / parent / index.js View on Github external
tasks.loadUrl = ZalgoPromise.all([tasks.open, tasks.buildUrl, tasks.setWindowName]).then(function (_ref5) {
                var proxyWin = _ref5[0],
                    url = _ref5[1];

                return _this2.loadUrl(proxyWin, url);
            });

            tasks.switchPrerender = ZalgoPromise.all([tasks.prerender, _this2.onInit]).then(function () {
                return _this2.switchPrerender();
            });

            tasks.runTimeout = tasks.loadUrl.then(function () {
                return _this2.runTimeout();
            });

            return ZalgoPromise.hash(tasks);
        }).then(function () {
            return _this2.props.onEnter();
github paypal / paypal-smart-payment-buttons / src / flows / checkout.js View on Github external
export function setupCheckout() : ZalgoPromise {
    checkoutOpen = false;

    const [ parent, top ] = [ getParent(window), getTop(window) ];

    const tasks = {};

    if (top && parent && parent !== top) {
        tasks.canRenderTo = window.paypal.Checkout.canRenderTo(top).then(result => {
            canRenderTop = result;
        });
    }

    return ZalgoPromise.hash(tasks).then(noop);
}
github krakenjs / zoid / src / component / parent / index.js View on Github external
tasks.open,
                tasks.buildUrl,
                tasks.setWindowName
            ]).then(([ proxyWin, url ]) => {
                return this.loadUrl(proxyWin, url);
            });

            tasks.switchPrerender = ZalgoPromise.all([ tasks.prerender, this.onInit ]).then(() => {
                return this.switchPrerender();
            });

            tasks.runTimeout = tasks.loadUrl.then(() => {
                return this.runTimeout();
            });

            return ZalgoPromise.hash(tasks);

        }).then(() => {
            return this.props.onEnter();
github paypal / paypal-smart-payment-buttons / src / button.js View on Github external
if (prerenderDetails) {
                const { win, fundingSource, card } = prerenderDetails;
                return checkout({ win, fundingSource, card });
            }
        });
    });

    tasks.remember = ZalgoPromise.try(() => {
        if (fundingEligibility && fundingEligibility.venmo && fundingEligibility.venmo.eligible) {
            return window.xprops.remember([ FUNDING.VENMO ]);
        }
    });

    tasks.setupCheckout = setupCheckout();

    return ZalgoPromise.hash(tasks).then(noop);
}
github krakenjs / post-robot / src / serialize / window.js View on Github external
return ZalgoPromise.try(() => {
            if (this.actualWindow) {
                return win === this.actualWindow;
            }
            
            return ZalgoPromise.hash({
                proxyInstanceID:       this.getInstanceID(),
                knownWindowInstanceID: getWindowInstanceID(win, { send })
            }).then(({ proxyInstanceID, knownWindowInstanceID }) => {
                const match = proxyInstanceID === knownWindowInstanceID;

                if (match) {
                    this.setWindow(win, { send });
                }

                return match;
            });
        });
    }
github paypal / paypal-smart-payment-buttons / src / payment-flows / checkout.js View on Github external
function setupCheckout({ components } : { components : Components }) : ZalgoPromise {
    const { Checkout } = components;

    checkoutOpen = false;

    const [ parent, top ] = [ getParent(window), getTop(window) ];

    const tasks = {};

    if (top && parent && parent !== top) {
        tasks.canRenderTo = Checkout.canRenderTo(top).then(result => {
            canRenderTop = result;
        });
    }

    return ZalgoPromise.hash(tasks).then(noop);
}
github krakenjs / zoid / src / parent / index.js View on Github external
return this.event.trigger(EVENT.DISPLAY);
            });

            const openBridge = open.then(proxyWin => {
                return this.openBridge(proxyWin, childDomain, context);
            });

            const runTimeout = loadUrl.then(() => {
                return this.runTimeout();
            });

            const onRendered = init.then(() => {
                return this.event.trigger(EVENT.RENDERED);
            });

            return ZalgoPromise.hash({
                init, buildUrl, onRender, getProxyContainer, openFrame, openPrerenderFrame, renderContainer, open,
                openPrerender, setState, prerender, loadUrl, buildWindowName, setWindowName, watchForClose, onDisplay,
                openBridge, runTimeout, onRendered
            });
            
        }).catch(err => {
            return ZalgoPromise.all([