engine library

The NanoFlags evaluation engine on its own: a Dart port of @nanoflags/engine with identical results (asserted by the shared parity fixtures). Most applications use package:nanoflags/nanoflags.dart instead.

Classes

Evaluation
The full outcome of evaluate, mirroring the engine's Evaluation object.
Reasons
Why an evaluation produced its value.
TraceStep
One line of the human-readable explanation of an evaluation.

Constants

engineVersion → const int
Version of the evaluation semantics implemented here (ENGINE_VERSION of @nanoflags/engine).
undefined → const Object
The single undefined value.

Functions

bucketOf(String seed, String identity) → double
Bucket in [0, 100) with two decimals of resolution. Stable for a given seed + identity.
clientBundle(Map<String, Object?> bundle) → Map<String, Object?>
The browser-key view: client-exposed flags and only the segments they reference (transitively).
describeCondition(Object? c) → String
Human-readable condition, as shown in traces (describeCondition).
evaluate(Object? bundle, String flagKey, Map<String, Object?> ctx, Object? fallback) → Evaluation
Evaluates one flag of bundle (a parsed bundle document; null for "no configuration loaded").
fmt(Object? v) → String
The engine's fmt(v): strings as they are, everything else as JSON (undefined prints as such).
hashInput(String input) → List<int>
TextEncoder.encode(input.normalize("NFC")): lone surrogates become U+FFFD (as utf8.encode does).
isBundle(Object? v) → bool
Structural check of a configuration bundle: schema 1, numeric revision, flags object and segments object (the JS SDK's isBundle).
isUndefined(Object? v) → bool
jsNumberToString(num value) → String
ECMAScript Number::toString(x) for radix 10 (what String(n) and JSON.stringify print).
jsString(Object? v) → String
String(v) (also what a template literal produces).
jsStringify(Object? v) → String?
JSON.stringify(v), or null where JavaScript returns undefined.
matchCondition(Object? c, Map<String, Object?> ctx, Object? segments, [int depth = 0]) → bool
Whether one condition matches ctx (matchCondition of the TypeScript engine). May throw a JsTypeError for malformed configuration, as the TypeScript engine does.
matchSegment(Map<String, Object?> segment, Map<String, Object?> ctx, [Map<String, Object?> segments = const {}]) → bool
Whether ctx is in segment (matchSegment of the TypeScript engine).
murmur3(String input, [int seed = 0]) → int
MurmurHash3 x86 32-bit over the UTF-8 bytes of the NFC-normalised input. Used for distribution only — never for security.
supportsEngine(Object? bundle) → bool
True when this engine can evaluate bundle (its engine is absent or not newer than engineVersion).
typeName(Object? v) → String
null, array, or the JavaScript typeof of v (the SDK's typeOf).