Comparing version 1.0.0 to 1.1.0
@@ -5,4 +5,6 @@ export function deprecate(fn) { | ||
export function equal() {} | ||
export function ok() {} | ||
export function equal() {} | ||
export function unreachable() {} |
@@ -71,1 +71,15 @@ /** | ||
): asserts value | ||
/** | ||
* Assert that a code path never happens. | ||
* | ||
* > 👉 **Important**: only asserts when the `development` condition is used, | ||
* > does nothing in production. | ||
* | ||
* @param {Error | string | null | undefined} [message] | ||
* Message for assertion error (default: `'Unreachable'`). | ||
* @returns {never} | ||
* Nothing; always throws. | ||
* @throws {AssertionError} | ||
* Throws when `value` is falsey. | ||
*/ | ||
export function unreachable(message?: Error | string | null | undefined): never |
@@ -193,2 +193,19 @@ import {dequal} from 'dequal' | ||
/** | ||
* Assert that a code path never happens. | ||
* | ||
* > 👉 **Important**: only asserts when the `development` condition is used, | ||
* > does nothing in production. | ||
* | ||
* @param {Error | string | null | undefined} [message] | ||
* Message for assertion error (default: `'Unreachable'`). | ||
* @returns {never} | ||
* Nothing; always throws. | ||
* @throws {AssertionError} | ||
* Throws when `value` is falsey. | ||
*/ | ||
export function unreachable(message) { | ||
assert(false, false, true, 'ok', 'Unreachable', message) | ||
} | ||
/** | ||
* @param {boolean} bool | ||
@@ -195,0 +212,0 @@ * Whether to skip this operation. |
{ | ||
"name": "devlop", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Do things in development and nothing otherwise", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -20,2 +20,3 @@ # devlop | ||
* [`ok(value[, message])`](#okvalue-message) | ||
* [`unreachable(message?)`](#unreachablemessage) | ||
* [Types](#types) | ||
@@ -60,3 +61,3 @@ * [Compatibility](#compatibility) | ||
```js | ||
import {deprecate, equal, ok} from 'https://esm.sh/devlop@1' | ||
import {deprecate, equal, ok, unreachable} from 'https://esm.sh/devlop@1' | ||
// For development code: | ||
@@ -70,3 +71,3 @@ // import {deprecate, equal, ok} from 'https://esm.sh/devlop@1?conditions=development' | ||
<script type="module"> | ||
import {deprecate, equal, ok} from 'https://esm.sh/devlop@1?bundle' | ||
import {deprecate, equal, ok, unreachable} from 'https://esm.sh/devlop@1?bundle' | ||
// For development code: | ||
@@ -175,3 +176,3 @@ // import {deprecate, equal, ok} from 'https://esm.sh/devlop@1?bundle&conditions=development' | ||
This package exports the identifiers [`deprecate`][api-deprecate], | ||
[`equal`][api-equal], and [`ok`][api-ok]. | ||
[`equal`][api-equal], [`ok`][api-ok], and [`unreachable`][api-unreachable]. | ||
There is no default export. | ||
@@ -244,6 +245,3 @@ | ||
— value to assert | ||
* `expected` (`unknown`) | ||
— baseline | ||
* `message` (`Error` or `string`, default: default: `'Expected value to be | ||
truthy'`) | ||
* `message` (`Error` or `string`, default: `'Expected value to be truthy'`) | ||
— message for assertion error | ||
@@ -259,2 +257,22 @@ | ||
### `unreachable(message?)` | ||
Assert that a code path never happens. | ||
> 👉 **Important**: only asserts when the `development` condition is used, | ||
> does nothing in production. | ||
###### Parameters | ||
* `message` (`Error` or `string`, default: `'Unreachable'`) | ||
— message for assertion error | ||
###### Returns | ||
Never (`never`). | ||
###### Throws | ||
Throws (`AssertionError`), always. | ||
## Types | ||
@@ -347,1 +365,3 @@ | ||
[api-ok]: #okvalue-message | ||
[api-unreachable]: #unreachablemessage |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22010
306
361