asarfuckery/appasar/stable/common/FeatureFlags.js

29 lines
539 B
JavaScript
Raw Normal View History

2019-01-17 18:22:05 +00:00
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
2019-03-12 17:01:00 +00:00
class FeatureFlags {
constructor() {
2019-01-17 18:22:05 +00:00
this.flags = new Set();
}
2019-03-12 17:01:00 +00:00
getSupported() {
return Array.from(this.flags);
}
2019-01-17 18:22:05 +00:00
2019-03-12 17:01:00 +00:00
supports(feature) {
return this.flags.has(feature);
}
2019-01-17 18:22:05 +00:00
2019-03-12 17:01:00 +00:00
declareSupported(feature) {
if (this.supports(feature)) {
console.error('Feature redeclared; is this a duplicate flag? ', feature);
return;
}
2019-01-17 18:22:05 +00:00
2019-03-12 17:01:00 +00:00
this.flags.add(feature);
}
}
2019-01-17 18:22:05 +00:00
exports.default = FeatureFlags;
2020-02-25 18:24:06 +00:00
module.exports = exports.default;