df_safer_dart 0.21.0
df_safer_dart: ^0.21.0 copied to clipboard
A package inspired by functional programming, designed to enhance the structure, safety, and debuggability of mission-critical code.
Changelog #
0.21.0 #
- feat:
df_safer_dartnow re-exportsdf_safer_dart_annotations. Consumers can use@sendable,@noFutures,@mustBeAnonymous, etc. without adding a separate dependency. - feat: new
Resolvable.flatMap(...)— monadic bind that absorbs throws and short-circuits onErr. - feat: new
Option.mapNone,Resolvable.mapSync,Resolvable.mapAsync(all@visibleForTesting) for pair-axis symmetry withmapSome/mapOk/mapErr. - fix: user-thrown
Erris now preserved verbatim (statusCode and breadcrumbs intact) across every transform method —mapOk,mapErr,mapSome,transf,flatMap,ifOk/ifErr,ifSync/ifAsync,whenComplete,resultMap,Outcome.reduce,SafeCompleter.transf,ConcurrentTaskBatch.onError,TaskSequencer. Previously these would re-wrap theErrand drop its metadata. - fix:
onFinalizethrows inSync(...),Async(...), andResolvable(...)are now absorbed into the result instead of escaping the factory or rejectingAsync.valuewith an uncaught error. - fix:
letIntOrNone(...)now correctly rejectsdouble.infinityand out-of-range doubles on dart2js (whereis intaccepts integer-valued doubles). - fix:
combineSync(...)andcombineAsync(...)now consume their iterable input exactly once — single-pass generators no longer silently lose all elements. - fix:
Lazy.singletonandLazy.factorynow absorb constructor throws intoSync.err(...)and detect re-entrant access, returning a structuredErrinstead of a stack overflow. - fix:
SafeCompleter.transf(...)now forwards errors from the source completer — anErrsource no longer leaves the derived completer dangling forever. - fix:
Stream.toSafe()now preserves the upstreamstackTraceonErrinstead of capturing a new one at the wrapper call site. - fix:
Err(...),Err.toString(), andHere.call()/basepath/locationno longer crash on dart2wasm — the WASM-host trap inpath.Style.platformis caught and falls back to an empty trace /None. - fix:
Async.end()is now guaranteed not to throw, even on hosts where the underlying future chain could surface an error synchronously. - perf:
Async.valueskips an unnecessaryFuture.value(...)wrap forAsync.new-constructed instances. - perf:
combineResult(...)fast path skips the materialized-list allocation when noonErraggregator is configured. - perf: many hot helpers (
combineOutcome,flatten,named,noneIfEmpty, iterable filters,SafeCompleter.resolvable, task-batch queue methods) gained@pragma('vm:prefer-inline')and shed per-call closure allocations. Outcome.raw(...)is now annotated@unsafeOrError—df_safer_dart_lintswill flag direct call sites that aren't inside anUNSAFE(...)block. UserawSync/rawAsyncfor the safe variants.Sync/Asyncconstructors andtoAsync/toSync/UNSAFE/asyncSomeassertions now correctly allowNevertype arguments.
0.20.0 #
- breaking:
Outcome.end()now returnsvoideverywhere (previouslyFutureOr<void>, withAsync.end()returningFuture<void>). Calling.end()is the "intentionally discarding this Outcome" marker — there is no longer a Future to await.Async.end()detaches its internal cleanup viaunawaited(...). If you actually need the async value, use.value.