Repository navigation
0.9.2
Features
Task.deferred(): This new static factory method allows for the creation of a deferredTask<T, E>. This may come in handy when working with push-based APIs such asEventTargetor when trying to emulate a timeout-behaviour, e.g:
class TimeoutError extends Error {}
const { task, succeed, fail } = Task.deferred<number, TimeoutError>();
const okTimerId = setTimeout(() => succeed(21), Math.random() * 1000);
const errTimerId = setTimeout(() => fail(new TimeoutError()), Math.randon() * 1000);
const timers = [ okTimerId, errTimerId ];
task
.map((n) => n * 2)
.inspect(console.log)
.inspectErr(console.error)
.finally(() => timers.forEach((id) => clearTimeout(id)) )Fixes
- Pinned
denoversion because of an upstreamswcbug
Misc
- As the implementation of
Task.deferred()is not dependent upon the newPromise.withResolvers()method, this change is fully backwards compatible, also with regards to the minimum supported runtime versions.
Changes
- feat(task): create deferred task by @realpha in #31
- fix(ci): pin deno version in release workflow by @realpha in #32
- feat(task): made deferred backwards compatible with version constraints by @realpha in #33
Full Changelog: 0.8.0...0.9.2