Reduce memory usage by dynamically creating Dates

This commit is contained in:
Amish Shah
2016-09-02 13:18:15 +01:00
parent b8a5669fda
commit ae17a89191
6 changed files with 49 additions and 32 deletions

View File

@@ -47,12 +47,7 @@ class Invite {
* @type {String}
*/
this.code = data.code;
/**
* The creation date of the invite
* @type {Date}
*/
this.creationDate = new Date(data.created_at);
this._creationDate = new Date(data.created_at).getTime();
/**
* Whether or not this invite is temporary
@@ -93,6 +88,14 @@ class Invite {
this.channels = this.client.channels.get(data.channel.id) || new PartialGuildChannel(this.client, data.channel);
}
/**
* The creation date of the invite
* @type {Date}
*/
get creationDate() {
return new Date(this._creationDate);
}
/**
* Deletes this invite
* @returns {Promise<Invite, Error>}