UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

38 lines (37 loc) 996 B
//#region src/FeatureFlags/FeatureFlagScope.ts var FeatureFlagScope = class FeatureFlagScope { static create(flags) { return new FeatureFlagScope(flags); } static merge(a, b) { const merged = new FeatureFlagScope(); for (const [key, value] of a.flags) merged.flags.set(key, value); for (const [key, value] of b.flags) merged.flags.set(key, value); return merged; } constructor(flags = {}) { this.flags = /* @__PURE__ */ new Map(); for (const [key, value] of Object.entries(flags)) this.flags.set(key, value !== null && value !== void 0 ? value : false); } /** * Enable a feature flag */ enable(name) { this.flags.set(name, true); } /** * Disable a feature flag */ disable(name) { this.flags.set(name, false); } /** * Check if a feature flag is enabled */ enabled(name) { var _this$flags$get; return (_this$flags$get = this.flags.get(name)) !== null && _this$flags$get !== void 0 ? _this$flags$get : false; } }; //#endregion export { FeatureFlagScope };