Source: structures/Base.js

'use strict';

const { normalizeWid } = require('../util/MessageId');

/**
 * Represents a WhatsApp data structure
 */
class Base {
    constructor(client) {
        /**
         * The client that instantiated this
         * @readonly
         */
        Object.defineProperty(this, 'client', { value: client });
    }

    _clone() {
        return Object.assign(Object.create(this), this);
    }

    _patch(data) {
        return data;
    }

    /**
     * Restores the public `_serialized` field when WhatsApp Web exposes a WID
     * through its current minified `$1` field.
     * @param {object} id
     * @returns {object}
     */
    static _normalizeId(id) {
        return normalizeWid(id);
    }
}

module.exports = Base;