Releases: billba/prague
v1.3.1
This release embraces the latest version of TypeScript instead of the overnight build it had previously relied on.
In addition, there is a breaking change. pipe
has become tube
and combine
has become pipe
. This brings the semantics of pipe
in line with other libraries.
(tube
is easy to understand if you ever traveled the London Underground. Just remember: "you can get off the tube
at any time").
v1.2.0
In this release there were minor miscellaneous typing improvements, but the bigger change is the way functions are normalized and typed.
Previously most Prague helpers returned a type of the form Transform<ARGS, RESULT>
which really meant (...args: ARGS) => Promise<RESULT>
. It was unwieldy to support a type name for such a simple concept, and ultimately unnecessary. Goodbye, Transform
, we hardly knew ya.
In addition, there was a change to the handling of undefined
results from Prague transforms. Previously these were normalized to null
via the from
function. Now they pass through unchanged. That means if your code used to say:
if (result === null)
// do something
You now need to say:
if (result == null)
// do something
This is a shorter way of saying:
if (result === null || result === undefined)
// do something
The from
function now just ensures that your function returns a Promise
.
v1.1.1
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
.