Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertions and error handling #18

Open
lazarljubenovic opened this issue Nov 5, 2023 · 1 comment
Open

Assertions and error handling #18

lazarljubenovic opened this issue Nov 5, 2023 · 1 comment

Comments

@lazarljubenovic
Copy link
Owner

Something like this?

j.pipe(
  source,
  // definitely an `assert` namespace
  j.assert.notEmpty(),
  // maybe a few more inner namespaces for groups of related functions
  j.assert.length.atLeast(3),
  j.assert.each.satisfies(tg.isNumber), // type guards
  // not entirely sure what's needed here without some case studies
  j.catchError((error) => j.Empty()), // also not entirely sure if this is even possible
)

Assertions would be partial triggers -- they would never yield values through before understanding that the condition is satisfied. In other words, they should either behave like passThrough or throw an error. They can tweak the type information though (e.g. the satisfies from the example above.

@lazarljubenovic
Copy link
Owner Author

j.assert.each.satisfies would also be a great start of a chain when defining a custom operator using the point-free style (see #16). It will be possible to avoid the awkwardly placed type inside the first operator, and provide inline documentation.

Of course, it adds some overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant