Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 715 Bytes

File metadata and controls

19 lines (14 loc) · 715 Bytes

assert

import {assert, validURL} from '@muze-nl/assert'

function example(url) {
    assert(url, validURL)
    return fetch(url)
}

This will call fails(). If any assertion fails, it will throw an error with all failed assertions. The thrown error contains the original problems and normalized structured issues on error.cause. It also logs concise one-line messages to the console, for example:

  - foo: data is not a string
  - bar: expected 'baz', found 'bax'

If assert is disabled--the default state--no assertions will be checked. See fails() for a list of possible assertions and issues() for path-aware issue objects.