mirror of
https://github.com/danbulant/discord.js
synced 2026-06-17 13:41:29 +00:00
Attempt to fix cache crash
This commit is contained in:
parent
930f276828
commit
42bedbeee4
2 changed files with 26 additions and 36 deletions
|
|
@ -115,20 +115,18 @@ var Cache = (function (_Array) {
|
|||
};
|
||||
|
||||
Cache.prototype.update = function update(old, data) {
|
||||
var item = this.get(this[discrimS], old[this[discrimS]]);
|
||||
|
||||
if (item) {
|
||||
var index = this.indexOf(item);
|
||||
for (var dataIndex in data) {
|
||||
if (data.hasOwnProperty(dataIndex)) {
|
||||
this[index][dataIndex] = data[dataIndex];
|
||||
for (var i in this) {
|
||||
if (this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||
for (var key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
this[i][key] = data[key];
|
||||
}
|
||||
}
|
||||
this[discrimCacheS][data[this[discrimS]]] = this[i];
|
||||
return this[i];
|
||||
}
|
||||
this[discrimCacheS][data[this[discrimS]]] = this[index];
|
||||
return this[index];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Cache.prototype.random = function random() {
|
||||
|
|
@ -137,13 +135,10 @@ var Cache = (function (_Array) {
|
|||
|
||||
Cache.prototype.remove = function remove(data) {
|
||||
delete this[discrimCacheS][data[this[discrimS]]];
|
||||
var index = this.indexOf(data);
|
||||
if (~index) {
|
||||
this.splice(index, 1);
|
||||
} else {
|
||||
var item = this.get(this[discrimS], data[this[discrimS]]);
|
||||
if (item) {
|
||||
this.splice(this.indexOf(item), 1);
|
||||
for (var i in this) {
|
||||
if (this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||
this.splice(i, 1);
|
||||
return this[i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -79,20 +79,18 @@ export default class Cache extends Array {
|
|||
}
|
||||
|
||||
update(old, data) {
|
||||
var item = this.get(this[discrimS], old[this[discrimS]]);
|
||||
|
||||
if (item) {
|
||||
var index = this.indexOf(item);
|
||||
for (var dataIndex in data) {
|
||||
if (data.hasOwnProperty(dataIndex)) {
|
||||
this[index][dataIndex] = data[dataIndex];
|
||||
for(var i in this) {
|
||||
if(this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||
for (var key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
this[i][key] = data[key];
|
||||
}
|
||||
}
|
||||
this[discrimCacheS][data[this[discrimS]]] = this[i];
|
||||
return this[i];
|
||||
}
|
||||
this[discrimCacheS][data[this[discrimS]]] = this[index];
|
||||
return this[index];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
random() {
|
||||
|
|
@ -101,13 +99,10 @@ export default class Cache extends Array {
|
|||
|
||||
remove(data) {
|
||||
delete this[discrimCacheS][data[this[discrimS]]];
|
||||
var index = this.indexOf(data);
|
||||
if (~index) {
|
||||
this.splice(index, 1);
|
||||
} else {
|
||||
var item = this.get(this[discrimS], data[this[discrimS]]);
|
||||
if (item) {
|
||||
this.splice(this.indexOf(item), 1);
|
||||
for(var i in this) {
|
||||
if(this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||
this.splice(i, 1);
|
||||
return this[i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue