File size: 655 Bytes
e7c953d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 'use strict';
var BaseCollection = require('./baseCollection.js');
function QueueCollection() {
//Nothing to do
}
QueueCollection.prototype = Object.create(BaseCollection.prototype);
QueueCollection.prototype.indexWhere = function(attrs) {
var keys = Object.keys(attrs);
for (var itemIndex = 0; itemIndex < this.length; itemIndex++) {
for (var itemKey = 0; itemKey < keys.length; itemKey++) {
if (this[itemIndex][keys[itemKey]] !== attrs[keys[itemKey]]) break;
if (itemKey === keys.length - 1) return itemIndex;
}
}
return -1;
};
module.exports = QueueCollection;
|