Changelog
8.5.0 (2025-01-25)
Adds a powerful Task.withRetries
utility for retrying tasks, along with a new module, true-myth/task/delay
, which provides a bunch of useful strategies for retries. See the docs for more details, and thanks to @alfierivera for [suggesting it][discussion]!
withRetries
function (@chriskrycho)Changelog
8.4.0 (2025-01-11)
Highlight: adds auto-curried, module-scope versions of all the Task
instance methods like map
and andThen
and more. Hot on the heels of 8.3.0, with what we think is probably the last set of features for this release!
console.log
(@chriskrycho)Changelog
8.3.0 (2025-01-10)
Highlights:
Task
combinators that weren’t part of v8.3.0: all
, allSettled
, any
, race
, as well as fancy new timer
and timeout
functions.safe
functions in the Result
and Task
modules, for transforming a throwing function into one you can call safely and get a Result
or Task
instead.Task
constructors.wrapReturn
function in the Maybe
module, safe
, to match the same function in the Result
and Task
modulesThis release also introduces some deprecations to tackle some mistakes we (read: @chriskrycho) made in the initial release of Task
in v8.2.0.
[!NOTE] We will be releasing v9.0.0 very soon, removing those deprecations and updating our TypeScript support matrix. However, we expect 8.3 to be stable enough that you could stay on it without issues—potentially for years. If there are any showstopper bugs, we will of course backport a fix for them, but there shouldn’t be any!
resolve
, reject
, and withResolvers
(@chriskrycho)wrapReturn
to safe
(@chriskrycho)all
, allSettled
, any
, race
, timer
, and timeout
(@chriskrycho)transposeArray
(@chriskrycho)Task
in README (@chriskrycho)safelyTryOr
and safelyTryOrElse
(@chriskrycho)wrapReturn
to safe
(@chriskrycho)Task.try
, Task.tryOr
, and Task.tryOrElse
(@chriskrycho)fromResult
, fromPromise
, and fromUnsafePromise
Changelog
8.2.0 (2025-01-03)
Finally—finally!—True Myth get a Task
type! A Task<T, E>
is like a Promise<Result<T, E>>
. In fact, under the hood, it is exactly a Promise<Result<T, E>>
, but in general you do not need to think about that layering. Instead, you get a nice type-safe API for fallible async operations. (It’s what Promise
should have been!)
Task
type (@chriskrycho)@class
(@chriskrycho)Changelog
8.2.0-beta.1 (2024-12-31)
Beta release with Task
, so folks can easily test it out!
static err
constructor (@chriskrycho)Task
-inspired improvements (@chriskrycho)new
from Result.(ok|err)
(@chriskrycho)Task
-inspired improvements (@chriskrycho)Changelog
8.1.0 (2024-12-04)
The big feature: a new module just for test support, with two functions in it: unwrap
and unwrapErr
. You can now write this:
import { expect, test } from 'vitest'; // or your testing library of choice
import Maybe from 'true-myth/maybe';
import Result from 'true-myth/result';
import { unwrap, unwrapErr } from 'true-myth/test-helpers';
import { producesMaybe, producesResult } from 'my-library';
test('using this new helper', () => {
expect(unwrap(producesMaybe())).toBe(true);
expect(unwrap(producesResult('valid'))).toBe('cool');
expect(unwrapErr(producesResult('invalid')).toBe('oh teh noes');
});
See [the docs][docs] for more!
unwrap
and unwrapErr
test helpers (@chriskrycho)Changelog
8.0.1 (2024-08-22)
Changelog
8.0.0 (2024-08-11)
This is a pretty small “breaking” release: it makes a change so True Myth is more type safe than it was before, specifically when constructing known-Ok
or known-Err
types with Result.ok
and Result.err
. In earlier versions, if you wrote Result.ok(123)
, the type would be Result<number, unknown>
. New contributor @auvred pointed out that in that case, we know there is never an error type, though, so we can use [the never
type][never]. This is breaking in that you may have to explicitly annotate some types where you did not before, because of [the assignability rules][assignability] for unknown
and never
(cf. [this playground][play]).
Net, very little of your code should have to change, but where it does, it will be safer than it was before! Thanks to @auvred for the improvement!
Changelog
7.4.0 (2024-07-10)
toString()
(@chriskrycho)Changelog
7.3.0 (2024-05-26)
null
and undefined
as arguments to Maybe.just
(@chriskrycho)