feature-toggle-package
Version:
A lightweight and flexible feature toggle (feature flag) implementation for JavaScript/TypeScript applications
21 lines (20 loc) • 718 B
JavaScript
import { FeatureToggleError } from '../types/errors.js';
import { FeatureToggleService } from '../service/feature-toggle.service.js';
export class FeatureToggle {
constructor(config) {
this.featureService = new FeatureToggleService();
this.config = config;
}
isFeatureEnabled(moduleName, submoduleName, featureName) {
try {
if (!moduleName) {
throw new FeatureToggleError('Module name is required');
}
return this.featureService.isEnabled(this.config, moduleName, submoduleName, featureName);
}
catch (error) {
console.error('Feature check failed:', error);
return false;
}
}
}