asarfuckery/appasar/canary/common/FeatureFlags.js

29 lines
542 B
JavaScript
Raw Normal View History

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