root / HServer / 00.Server / 00.Program / node_modules / better-assert / Readme.md
이력 | 보기 | 이력해설 | 다운로드 (2.06 KB)
| 1 |
|
|---|---|
| 2 |
# better-assert |
| 3 |
|
| 4 |
Better c-style assertions using [callsite](https://github.com/visionmedia/callsite) for |
| 5 |
self-documenting failure messages. |
| 6 |
|
| 7 |
## Installation |
| 8 |
|
| 9 |
$ npm install better-assert |
| 10 |
|
| 11 |
## Example |
| 12 |
|
| 13 |
By default assertions are enabled, however the __NO_ASSERT__ environment variable |
| 14 |
will deactivate them when truthy. |
| 15 |
|
| 16 |
```js |
| 17 |
var assert = require('better-assert');
|
| 18 |
|
| 19 |
test(); |
| 20 |
|
| 21 |
function test() {
|
| 22 |
var user = { name: 'tobi' };
|
| 23 |
assert('tobi' == user.name);
|
| 24 |
assert('number' == typeof user.age);
|
| 25 |
} |
| 26 |
|
| 27 |
AssertionError: 'number' == typeof user.age |
| 28 |
at test (/Users/tj/projects/better-assert/example.js:9:3) |
| 29 |
at Object.<anonymous> (/Users/tj/projects/better-assert/example.js:4:1) |
| 30 |
at Module._compile (module.js:449:26) |
| 31 |
at Object.Module._extensions..js (module.js:467:10) |
| 32 |
at Module.load (module.js:356:32) |
| 33 |
at Function.Module._load (module.js:312:12) |
| 34 |
at Module.runMain (module.js:492:10) |
| 35 |
at process.startup.processNextTick.process._tickCallback (node.js:244:9) |
| 36 |
``` |
| 37 |
|
| 38 |
## License |
| 39 |
|
| 40 |
(The MIT License) |
| 41 |
|
| 42 |
Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca> |
| 43 |
|
| 44 |
Permission is hereby granted, free of charge, to any person obtaining |
| 45 |
a copy of this software and associated documentation files (the |
| 46 |
'Software'), to deal in the Software without restriction, including |
| 47 |
without limitation the rights to use, copy, modify, merge, publish, |
| 48 |
distribute, sublicense, and/or sell copies of the Software, and to |
| 49 |
permit persons to whom the Software is furnished to do so, subject to |
| 50 |
the following conditions: |
| 51 |
|
| 52 |
The above copyright notice and this permission notice shall be |
| 53 |
included in all copies or substantial portions of the Software. |
| 54 |
|
| 55 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
| 56 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 57 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 58 |
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 59 |
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 60 |
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 61 |
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |