Files
discord.js/src/structures/Base.js
Crawl c065156a88 chore: consistency/prettier (#3852)
* chore: consistency/prettier

* chore: rebase

* chore: rebase

* chore: include typings

* fix: include typings file in prettier lint-staged
2020-02-29 14:35:57 +01:00

43 lines
720 B
JavaScript

'use strict';
const Util = require('../util/Util');
/**
* Represents a data model that is identifiable by a Snowflake (i.e. Discord API data models).
*/
class Base {
constructor(client) {
/**
* The client that instantiated this
* @name Base#client
* @type {Client}
* @readonly
*/
Object.defineProperty(this, 'client', { value: client });
}
_clone() {
return Object.assign(Object.create(this), this);
}
_patch(data) {
return data;
}
_update(data) {
const clone = this._clone();
this._patch(data);
return clone;
}
toJSON(...props) {
return Util.flatten(this, ...props);
}
valueOf() {
return this.id;
}
}
module.exports = Base;