@flaggr/evaluator
v0.1.0
Published
Standalone flag evaluator for Flaggr - zero dependencies, pure TypeScript
Maintainers
Readme
@flaggr/evaluator
Standalone flag evaluation engine for Flaggr. Zero dependencies, pure TypeScript.
Use this package for local/edge evaluation when you want to evaluate feature flags without making API calls. The evaluation rules are cached locally and evaluated in-process for sub-millisecond latency.
Installation
npm install @flaggr/evaluatorUsage
import { evaluate } from '@flaggr/evaluator'
const result = evaluate({
flag: {
key: 'checkout-v2',
type: 'boolean',
enabled: true,
defaultValue: false,
targetingRules: [
{
conditions: [{ attribute: 'plan', operator: 'equals', value: 'enterprise' }],
value: true,
},
],
},
context: {
targetingKey: 'user-123',
plan: 'enterprise',
},
})
console.log(result.value) // true
console.log(result.reason) // "TARGETING_MATCH"Features
- Zero dependencies
- Supports all 16 targeting operators
- Percentage rollouts with deterministic hashing
- Variant assignment for experiments
- Type-safe evaluation (boolean, string, number, object)
