LandRover/YowJS

View on GitHub
src/message/message_base.js

Summary

Maintainability
A
0 mins
Test Coverage
'use strict';

const TYPES = require('./../consts/types');


/**
 * MessageBase.
 *
 * Shared logic between all message types is represented here.
 */
class MessageBase {
    /**
     * Stores payload message on object
     */
    constructor(rawPayload) {
        this.rawPayload = rawPayload;
    }


    /**
     * Getter for the message type. If nothing found defaults to UNKNOWN message type.
     *
     * @return {Object} Symbol referance of that type.
     */
    getType() {
        return 'undefined' === typeof this.type || null === this.type ? TYPES.UNKNOWN : this.type;
    }
}

module.exports = MessageBase;