unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
16 lines • 646 B
JavaScript
import { Strategy } from './strategy.js';
export default class GradualRolloutRandomStrategy extends Strategy {
constructor(randomGenerator) {
super('gradualRolloutRandom');
this.randomGenerator = () => Math.floor(Math.random() * 100) + 1;
this.randomGenerator = randomGenerator || this.randomGenerator;
}
isEnabled(parameters,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_context) {
const percentage = Number(parameters.percentage);
const random = this.randomGenerator();
return percentage >= random;
}
}
//# sourceMappingURL=gradual-rollout-random.js.map