function isMessage(val) {
        if (isObject(val)) {
            // all messages must have the `type` prop
            if (!hasOwnStringProperty(val, 'type')) {
                return false;
            }
            // validate other properties depending on the `type`
            switch (val.type) {
                case exports.MessageType.ConnectionInit:
                    // the connection init message can have optional payload object
                    return (!hasOwnProperty(val, 'payload') ||
                        val.payload === undefined ||
                        isObject(val.payload));
                case exports.MessageType.ConnectionAck:
                    // the connection ack message can have optional payload object too
                    return (!hasOwnProperty(val, 'payload') ||
                        val.payload === undefined ||
                        isObject(val.payload));
                case exports.MessageType.Subscribe:
                    return (hasOwnStringProperty(val, 'id') &&
                        hasOwnObjectProperty(val, 'payload') &&
                        (!hasOwnProperty(val.payload, 'operationName') ||
                            val.payload.operationName === undefined ||
                            val.payload.operationName === null ||
                            typeof val.payload.operationName === 'string') &&
                        hasOwnStringProperty(val.payload, 'query') &&
                        (!hasOwnProperty(val.payload, 'variables') ||
                            val.payload.variables === undefined ||
                            val.payload.variables === null ||
                            hasOwnObjectProperty(val.payload, 'variables')) &&
                        (!hasOwnProperty(val.payload, 'extensions') ||
                            val.payload.extensions === undefined ||
                            val.payload.extensions === null ||
                            hasOwnObjectProperty(val.payload, 'extensions')));
                case exports.MessageType.Next:
                    return (hasOwnStringProperty(val, 'id') &&
                        hasOwnObjectProperty(val, 'payload'));
                case exports.MessageType.Error:
                    return hasOwnStringProperty(val, 'id') && areGraphQLErrors(val.payload);
                case exports.MessageType.Complete:
                    return hasOwnStringProperty(val, 'id');
                default:
                    return false;
            }
        }
        return false;
    }
/**
     * Checks if the provided value is a message.
     *
     * @category Common
     */
Checks if the provided value is a message.
@category Common
Checks if the provided value is a message . @category Common
function isMessage(val) {
        if (isObject(val)) {
            if (!hasOwnStringProperty(val, 'type')) {
                return false;
            }
            switch (val.type) {
                case exports.MessageType.ConnectionInit:
                    return (!hasOwnProperty(val, 'payload') ||
                        val.payload === undefined ||
                        isObject(val.payload));
                case exports.MessageType.ConnectionAck:
                    return (!hasOwnProperty(val, 'payload') ||
                        val.payload === undefined ||
                        isObject(val.payload));
                case exports.MessageType.Subscribe:
                    return (hasOwnStringProperty(val, 'id') &&
                        hasOwnObjectProperty(val, 'payload') &&
                        (!hasOwnProperty(val.payload, 'operationName') ||
                            val.payload.operationName === undefined ||
                            val.payload.operationName === null ||
                            typeof val.payload.operationName === 'string') &&
                        hasOwnStringProperty(val.payload, 'query') &&
                        (!hasOwnProperty(val.payload, 'variables') ||
                            val.payload.variables === undefined ||
                            val.payload.variables === null ||
                            hasOwnObjectProperty(val.payload, 'variables')) &&
                        (!hasOwnProperty(val.payload, 'extensions') ||
                            val.payload.extensions === undefined ||
                            val.payload.extensions === null ||
                            hasOwnObjectProperty(val.payload, 'extensions')));
                case exports.MessageType.Next:
                    return (hasOwnStringProperty(val, 'id') &&
                        hasOwnObjectProperty(val, 'payload'));
                case exports.MessageType.Error:
                    return hasOwnStringProperty(val, 'id') && areGraphQLErrors(val.payload);
                case exports.MessageType.Complete:
                    return hasOwnStringProperty(val, 'id');
                default:
                    return false;
            }
        }
        return false;
    }
function isMessage ( val ) { if ( isObject ( val ) ) { if ( ! hasOwnStringProperty ( val , 'type' ) ) { return false ; } switch ( val . type ) { case exports . MessageType . ConnectionInit : return ( ! hasOwnProperty ( val , 'payload' ) || val . payload === undefined || isObject ( val . payload ) ) ; case exports . MessageType . ConnectionAck : return ( ! hasOwnProperty ( val , 'payload' ) || val . payload === undefined || isObject ( val . payload ) ) ; case exports . MessageType . Subscribe : return ( hasOwnStringProperty ( val , 'id' ) && hasOwnObjectProperty ( val , 'payload' ) && ( ! hasOwnProperty ( val . payload , 'operationName' ) || val . payload . operationName === undefined || val . payload . operationName === null || typeof val . payload . operationName === 'string' ) && hasOwnStringProperty ( val . payload , 'query' ) && ( ! hasOwnProperty ( val . payload , 'variables' ) || val . payload . variables === undefined || val . payload . variables === null || hasOwnObjectProperty ( val . payload , 'variables' ) ) && ( ! hasOwnProperty ( val . payload , 'extensions' ) || val . payload . extensions === undefined || val . payload . extensions === null || hasOwnObjectProperty ( val . payload , 'extensions' ) ) ) ; case exports . MessageType . Next : return ( hasOwnStringProperty ( val , 'id' ) && hasOwnObjectProperty ( val , 'payload' ) ) ; case exports . MessageType . Error : return hasOwnStringProperty ( val , 'id' ) && areGraphQLErrors ( val . payload ) ; case exports . MessageType . Complete : return hasOwnStringProperty ( val , 'id' ) ; default : return false ; } } return false ; }
Checks if the provided value is a message.
Checks if the provided value is a message .
// all messages must have the `type` prop // validate other properties depending on the `type` // the connection init message can have optional payload object // the connection ack message can have optional payload object too