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
Evaluationobject. - 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_VERSIONof@nanoflags/engine). - undefined → const Object
-
The single
undefinedvalue.
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;nullfor "no configuration loaded"). -
fmt(
Object? v) → String -
The engine's
fmt(v): strings as they are, everything else as JSON (undefinedprints as such). -
hashInput(
String input) → List< int> -
TextEncoder.encode(input.normalize("NFC")): lone surrogates become U+FFFD (asutf8.encodedoes). -
isBundle(
Object? v) → bool -
Structural check of a configuration bundle:
schema1, numericrevision,flagsobject andsegmentsobject (the JS SDK'sisBundle). -
isUndefined(
Object? v) → bool -
jsNumberToString(
num value) → String -
ECMAScript
Number::toString(x)for radix 10 (whatString(n)andJSON.stringifyprint). -
jsString(
Object? v) → String -
String(v)(also what a template literal produces). -
jsStringify(
Object? v) → String? -
JSON.stringify(v), ornullwhere JavaScript returnsundefined. -
matchCondition(
Object? c, Map< String, Object?> ctx, Object? segments, [int depth = 0]) → bool -
Whether one condition matches
ctx(matchConditionof the TypeScript engine). May throw aJsTypeErrorfor malformed configuration, as the TypeScript engine does. -
matchSegment(
Map< String, Object?> segment, Map<String, Object?> ctx, [Map<String, Object?> segments = const {}]) → bool -
Whether
ctxis insegment(matchSegmentof 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(itsengineis absent or not newer than engineVersion). -
typeName(
Object? v) → String -
null,array, or the JavaScripttypeofofv(the SDK'stypeOf).