all files / mapbox-gl-draw/src/lib/ simple_set.js

100% Statements 22/22
100% Branches 6/6
100% Functions 6/6
100% Lines 18/18
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 26 27 28 29 30 31 32  74×     511× 261× 261×     144× 144× 105× 105×     333×     465×     97× 97×      
function SimpleSet(items) {
  this._items = (items) ? items.slice() : [];
}
 
SimpleSet.prototype.add = function(item) {
  if (this._items.indexOf(item) !== -1) return;
  this._items.push(item);
  return this;
};
 
SimpleSet.prototype.delete = function(item) {
  var itemIndex = this._items.indexOf(item);
  if (itemIndex === -1) return;
  this._items.splice(itemIndex, 1);
  return this;
};
 
SimpleSet.prototype.has = function(item) {
  return this._items.indexOf(item) !== -1;
};
 
SimpleSet.prototype.values = function() {
  return this._items.slice();
};
 
SimpleSet.prototype.clear = function() {
  this._items = [];
  return this;
};
 
module.exports = SimpleSet;