1.1.2 • Published 2 years ago

thrw v1.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

thrw

This is a tiny replacement for throw expressions. With it, you can replace this code:

const value: number|null = getValue()
if (value === null) {
	throw new Error(`couldn't get value`)
}

With this:

const value: number = getValue() || thrw(`couldn't get value`)

thrw is a function that of never type because it never actually returns anything — it just throws an error. This allows you to use it in place of any other type. You can use thrw with an instance of an error you want to throw, or with just a string, in which case it will create an instance of Error itself.

1.1.1

2 years ago

1.1.0

2 years ago

1.1.2

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago