How to use the universal-serialize/src.TYPE.PROMISE 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 / 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;
        }
    });
}