Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gavinning/assert
断言,失败信息支持携带err-code
https://github.com/gavinning/assert
assert err-code error-code verify
Last synced: about 2 months ago
JSON representation
断言,失败信息支持携带err-code
- Host: GitHub
- URL: https://github.com/gavinning/assert
- Owner: gavinning
- Created: 2019-10-09T14:46:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T19:46:59.000Z (about 2 years ago)
- Last Synced: 2024-05-30T01:54:57.638Z (8 months ago)
- Topics: assert, err-code, error-code, verify
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
assert
---
断言,失败信息支持携带err-code### Install
```sh
npm i @4a/assert
```### Usage
```js
const assert = require('@4a/assert')try {
assert.ok(0, 100, 'error code 100')
}
catch(err) {
console.log({
code: err.code,
message: err.message
})
}try {
assert.fail(1, 200, 'error code 200')
}
catch(err) {
console.log({
code: err.code,
message: err.message
})
}
```