Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

c-style assert() for nodejs, reporting the expression string as the error message

License

NotificationsYou must be signed in to change notification settings

tj/better-assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Better c-style assertions usingcallsite forself-documenting failure messages.

Installation

$ npm install better-assert

Example

By default assertions are enabled, however theNO_ASSERT environment variablewill deactivate them when truthy.

varassert=require('better-assert');test();functiontest(){varuser={name:'tobi'};assert('tobi'==user.name);assert('number'==typeofuser.age);}AssertionError:'number'==typeofuser.ageattest(/Users/tj/projects/better-assert/example.js:9:3)atObject.<anonymous>(/Users/tj/projects/better-assert/example.js:4:1)atModule._compile(module.js:449:26)atObject.Module._extensions..js(module.js:467:10)atModule.load(module.js:356:32)atFunction.Module._load(module.js:312:12)atModule.runMain(module.js:492:10)atprocess.startup.processNextTick.process._tickCallback(node.js:244:9)

Browser support

See this fork for use in the browser:https://github.com/devinrhode2/better-assert-browser

License

(The MIT License)

Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>

Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the'Software'), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:

The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

c-style assert() for nodejs, reporting the expression string as the error message

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp