mirror of
https://github.com/danbulant/discord.js
synced 2026-07-04 18:50:40 +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) {
|
Cache.prototype.update = function update(old, data) {
|
||||||
var item = this.get(this[discrimS], old[this[discrimS]]);
|
for (var i in this) {
|
||||||
|
if (this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||||
if (item) {
|
for (var key in data) {
|
||||||
var index = this.indexOf(item);
|
if (data.hasOwnProperty(key)) {
|
||||||
for (var dataIndex in data) {
|
this[i][key] = data[key];
|
||||||
if (data.hasOwnProperty(dataIndex)) {
|
}
|
||||||
this[index][dataIndex] = data[dataIndex];
|
|
||||||
}
|
}
|
||||||
|
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() {
|
Cache.prototype.random = function random() {
|
||||||
|
|
@ -137,13 +135,10 @@ var Cache = (function (_Array) {
|
||||||
|
|
||||||
Cache.prototype.remove = function remove(data) {
|
Cache.prototype.remove = function remove(data) {
|
||||||
delete this[discrimCacheS][data[this[discrimS]]];
|
delete this[discrimCacheS][data[this[discrimS]]];
|
||||||
var index = this.indexOf(data);
|
for (var i in this) {
|
||||||
if (~index) {
|
if (this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||||
this.splice(index, 1);
|
this.splice(i, 1);
|
||||||
} else {
|
return this[i];
|
||||||
var item = this.get(this[discrimS], data[this[discrimS]]);
|
|
||||||
if (item) {
|
|
||||||
this.splice(this.indexOf(item), 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -79,20 +79,18 @@ export default class Cache extends Array {
|
||||||
}
|
}
|
||||||
|
|
||||||
update(old, data) {
|
update(old, data) {
|
||||||
var item = this.get(this[discrimS], old[this[discrimS]]);
|
for(var i in this) {
|
||||||
|
if(this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||||
if (item) {
|
for (var key in data) {
|
||||||
var index = this.indexOf(item);
|
if (data.hasOwnProperty(key)) {
|
||||||
for (var dataIndex in data) {
|
this[i][key] = data[key];
|
||||||
if (data.hasOwnProperty(dataIndex)) {
|
}
|
||||||
this[index][dataIndex] = data[dataIndex];
|
|
||||||
}
|
}
|
||||||
|
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() {
|
random() {
|
||||||
|
|
@ -101,13 +99,10 @@ export default class Cache extends Array {
|
||||||
|
|
||||||
remove(data) {
|
remove(data) {
|
||||||
delete this[discrimCacheS][data[this[discrimS]]];
|
delete this[discrimCacheS][data[this[discrimS]]];
|
||||||
var index = this.indexOf(data);
|
for(var i in this) {
|
||||||
if (~index) {
|
if(this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||||
this.splice(index, 1);
|
this.splice(i, 1);
|
||||||
} else {
|
return this[i];
|
||||||
var item = this.get(this[discrimS], data[this[discrimS]]);
|
|
||||||
if (item) {
|
|
||||||
this.splice(this.indexOf(item), 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue