https://github.com/volijs/is-expected
Run-time asserts library
https://github.com/volijs/is-expected
Last synced: about 2 months ago
JSON representation
Run-time asserts library
- Host: GitHub
- URL: https://github.com/volijs/is-expected
- Owner: VoliJS
- License: mit
- Created: 2019-02-20T22:12:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-21T20:29:11.000Z (over 7 years ago)
- Last Synced: 2025-01-10T09:41:30.709Z (over 1 year ago)
- Language: TypeScript
- Size: 57.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Asserts
Assert must start with `is(x)` followed by the sequence of checks. First failed assert in sequence will throw an exception.
is(x).check1.check2...
## Checks
Check is a function taking the value and returning boolean. Checks can be created with the same sequence of checks starting with `is`.
const { check } = is.check1.check2...
### Simple type checks
- `is.undefined`
- `is.integer`
- `is.number`
- `is.string`
- `is.boolean`
- `is.symbol`
- `is.function`
- `is.object`
- `is.array`
- `is.plainObject`
- `is.instanceOf( T )`
### Simple comparisons
- `is.empty` - x is null or undefined.
- `is.falsy` - !x.
- `is.truthy` - !!x.
- `is.eq( y )`
- `is.le( y )`
- `is.lt`
- `is.ge`
- `is.gt`
- `is.stringLike( /regexp/ )`
### Deep object checks
- `is.arrayOf( check )`
- `is.objectOf( check )`
- `is.shape( { a : check, b : value, ... } )`
### Combinators
- `is.either( is.string, is.number, ... )`