non-maybe

2.0.3 • Public • Published

non-maybe

Self-explanatory spec: test.js

This is designed to be used with flowtype. It asserts that an object is not a maybe type. In other words, if an object is of type ?User, then passing that object into nonMaybe will assert that it is of type User.

It will also throw an error at runtime if the object is null or undefined.

Example:

type User = {
  userId: string
}

async function example(userId: string): Promise<User> {
  const user = await DB.getUser(userId) // DB.getUser returns Promise<?User>
  return nonMaybe(user)
} 

Use version 1.. for commonJS. Higher versions are ESM.

MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i non-maybe

Weekly Downloads

1

Version

2.0.3

License

MIT

Unpacked Size

2.06 kB

Total Files

4

Last publish

Collaborators

  • taylorgoolsby