Skip to content

Commit

Permalink
Adding check for incorrect Array caching.
Browse files Browse the repository at this point in the history
  • Loading branch information
probityrules committed Jul 19, 2019
1 parent 911cfed commit 8a8e626
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion recycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,21 @@ export default {

cache.recycle = function (recycle, instance, ...args) {
if (instance.recycled) {
console.warn('WHOA! I have already been recycled!', instance);
console.warn('Recycle: WHOA! I have already been recycled!', instance);
} else {
instance.recycled = true;
recycle(instance, ...args);
}
}.bind(cache, cache.recycle.bind(cache));

if (isArray) {
cache.recycle = function (recycle, instance, ...args) {
if (!Array.isArray(instance)) {
console.warn('Recycle: Adding a non-Array to the array cache!');
}
recycle(instance, ...args);
}.bind(cache, cache.recycle.bind(cache));
}
}

if (mixinMethods) {
Expand Down

0 comments on commit 8a8e626

Please sign in to comment.