Set.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. var root_1 = require('./root');
  3. function minimalSetImpl() {
  4. // THIS IS NOT a full impl of Set, this is just the minimum
  5. // bits of functionality we need for this library.
  6. return (function () {
  7. function MinimalSet() {
  8. this._values = [];
  9. }
  10. MinimalSet.prototype.add = function (value) {
  11. if (!this.has(value)) {
  12. this._values.push(value);
  13. }
  14. };
  15. MinimalSet.prototype.has = function (value) {
  16. return this._values.indexOf(value) !== -1;
  17. };
  18. Object.defineProperty(MinimalSet.prototype, "size", {
  19. get: function () {
  20. return this._values.length;
  21. },
  22. enumerable: true,
  23. configurable: true
  24. });
  25. MinimalSet.prototype.clear = function () {
  26. this._values.length = 0;
  27. };
  28. return MinimalSet;
  29. }());
  30. }
  31. exports.minimalSetImpl = minimalSetImpl;
  32. exports.Set = root_1.root.Set || minimalSetImpl();
  33. //# sourceMappingURL=Set.js.map