How to use the universal-serialize/src.serializeType function in universal-serialize

To help you get started, we’ve selected a few universal-serialize 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 krakenjs / post-robot / src / serialize / function.js View on Github external
if (typeof name === 'string' && typeof name.indexOf === 'function' && name.indexOf('anonymous::') === 0) {
        name = name.replace('anonymous::', `${ key }::`);
    }

    if (ProxyWindow.isProxyWindow(destination)) {
        addMethod(id, val, name, destination, domain);

        // $FlowFixMe
        destination.awaitWindow().then(win => {
            addMethod(id, val, name, win, domain);
        });
    } else {
        addMethod(id, val, name, destination, domain);
    }

    return serializeType(SERIALIZATION_TYPE.CROSS_DOMAIN_FUNCTION, { id, name });
}
github krakenjs / post-robot / dist / module / lib / serialize.js View on Github external
function serializePromise(destination, domain, val, key) {
    return serializeType(CUSTOM_TYPE.CROSS_DOMAIN_ZALGO_PROMISE, {
        then: serializeFunction(destination, domain, function (resolve, reject) {
            return val.then(resolve, reject);
        }, key)
    });
}
github krakenjs / post-robot / dist / module / lib / serialize.js View on Github external
function serializeFunction(destination, domain, val, key) {
    var id = uniqueID();

    var methods = global.methods.get(destination);

    if (!methods) {
        methods = {};
        global.methods.set(destination, methods);
    }

    methods[id] = { domain: domain, val: val };

    listenForFunctionCalls();

    return serializeType(CUSTOM_TYPE.CROSS_DOMAIN_FUNCTION, { id: id, name: val.name || key });
}
github krakenjs / post-robot / src / serialize / promise.js View on Github external
export function serializePromise(destination : CrossDomainWindowType | ProxyWindow, domain : DomainMatcher, val : Thenable, key : string, { on, send } : { on : OnType, send : SendType }) : SerializedPromise {
    return serializeType(SERIALIZATION_TYPE.CROSS_DOMAIN_ZALGO_PROMISE, {
        then: serializeFunction(destination, domain, (resolve, reject) => val.then(resolve, reject), key, { on, send })
    });
}
github krakenjs / post-robot / src / serialize / window.js View on Github external
export function serializeWindow(destination : CrossDomainWindowType | ProxyWindow, domain : DomainMatcher, win : CrossDomainWindowType, { send } : { send : SendType }) : SerializedWindow {
    return serializeType(SERIALIZATION_TYPE.CROSS_DOMAIN_WINDOW, ProxyWindow.serialize(win, { send }));
}