analyze-es6-modules
Version:
Performs static analysis of ES6 modules in your codebase.
54 lines (45 loc) • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var StringMultiSet = function () {
function StringMultiSet(strings) {
_classCallCheck(this, StringMultiSet);
this.strings = {};
strings.forEach(this.add.bind(this));
}
_createClass(StringMultiSet, [{
key: "add",
value: function add(string) {
if (this.strings[string]) {
this.strings[string] += 1;
} else {
this.strings[string] = 1;
}
}
}, {
key: "has",
value: function has(string) {
return this.strings[string] && this.strings[string] > 0;
}
}, {
key: "count",
value: function count(string) {
return this.strings[string] || 0;
}
}, {
key: "items",
get: function get() {
return Object.keys(this.strings);
}
}, {
key: "size",
get: function get() {
return this.items.length;
}
}]);
return StringMultiSet;
}();
exports.default = StringMultiSet;