How to use the universal-serialize/src.TYPE.FUNCTION 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 / dist / module / lib / serialize.js View on Github external
export function serializeMessage(destination, domain, obj) {
    var _serialize;

    return serialize(obj, (_serialize = {}, _serialize[TYPE.PROMISE] = function (val, key) {
        return serializePromise(destination, domain, val, key);
    }, _serialize[TYPE.FUNCTION] = function (val, key) {
        return serializeFunction(destination, domain, val, key);
    }, _serialize));
}
github krakenjs / post-robot / src / serialize / serialize.js View on Github external
export function serializeMessage(destination : CrossDomainWindowType | ProxyWindow, domain : DomainMatcher, obj : T, { on, send } : { on : OnType, send : SendType }) : string {
    return serialize(obj, {
        [ TYPE.PROMISE ]:  (val : Thenable, key : string) : SerializedPromise => serializePromise(destination, domain, val, key, { on, send }),
        [ TYPE.FUNCTION ]: (val : Function, key : string) : SerializedFunction => serializeFunction(destination, domain, val, key, { on, send }),
        [ TYPE.OBJECT ]:   (val : CrossDomainWindowType) : Object | SerializedWindow => {
            return (isWindow(val) || ProxyWindow.isProxyWindow(val)) ? serializeWindow(destination, domain, val, { on, send }) : val;
        }
    });
}