https://github.com/rzning/is-assert
Type check and assert
https://github.com/rzning/is-assert
Last synced: 9 months ago
JSON representation
Type check and assert
- Host: GitHub
- URL: https://github.com/rzning/is-assert
- Owner: rzning
- License: mit
- Created: 2021-06-09T12:46:38.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-04T09:50:21.000Z (about 4 years ago)
- Last Synced: 2025-02-28T06:09:21.769Z (10 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-assert
Type check and assert
类型检查和断言
## Install
```sh
$ npm install is-assert
# OR
$ yarn add is-assert
```
## Usage
```js
import { assert, isNum, isStr } from 'is-assert'
function demo(name, value) {
assert(isStr(name, true), 'name 必须为字符串。')
assert(isNum(value), 'value 必须为数字。')
// ...
}
```
```js
import { assertVar } from 'is-assert'
function demo2(name, value) {
assertVar(name).isStr(true)
assertVar(value).isNum()
// ...
}
```