Skip to content

v1.1.1

Compare
Choose a tag to compare
@billba billba released this 14 Sep 05:55
· 20 commits to master since this release

In this release handling of multiple results changed, and typing was improved.

Multiple results

In 1.0.x you used the multiple helper to construct an array of results. But sometimes it returned null or a non-array. This was meant to be a convenience, but it mostly just causes confusion.

In 1.1.1 the multiple helper is gone, replaced by toArray and fromArray. toArray does a very similar job to multiple, but it always returns an array.

toArray(
    () => null
)(); // Promise<[]>

toArray(
    () => "Hi"
)(); //  Promise<["Hi"]>

toArray(
    () => "Hi",
    () => null
)(); //  Promise<["Hi"]>

toArray(
    () => "Hi",
    () => "Bye",
)(); //  Promise<["Hi", "Bye"]>

toArray's companion fromArray removes the first element of any arrays:

fromArray(
    []
)(); // Promise<null>

fromArray(
    ["Hi"]
)(); // Promise<"Hi">

fromArray(
    ["Hi", "Bye"]
)(); // Promise<"Hi">

fromArray(
    "Hi"
)(); // Promise<"Hi">

top similarly always returns an array now.

Typing

Typing is considerably improved in v1.1.1 across the board, especially for first, pipe, toArray, best, and sort.