[ANN] The first ReScript decoding library with async refinements and transforms support

I’ve released rescript-struct@0.23.0 with the support for asynchronous refinements and transforms.

let userIdStruct = S.string()->S.asyncRefine(~parser=string =>
  verfiyUserExistsInDb(~userId=string)->Promise.thenResolve(isExistingUser =>
    if not(isExistingUser) {
      S.Error.raise("User doesn't exist")
    }
  )
, ())

"1234"->S.parseAsyncWith(userIdStruct)

Also, this release brought a noticeable boost of performance, making rescript-struct just a little bit slower than decco (benchmark).

5 Likes

Congrats!

I don’t think this claim is true though. bs-json, the first such library for BuckleScript, has had both map and andThen combinators since the very beginning. rescript-json-combinators also has map. I’m sure others do as well as it’s pretty easy to add and quite useful!

Async I’m sure is new though :slight_smile:

1 Like

Thank you for letting me know, I’ve missed them in the source code. I’ll fix the post.

1 Like