npm)
underscore.assert (🔨 Plugin for Underscore.js: add method "_.assert", which simplify checking states
_
| |
__ _ ___ ___ ___ _ __| |_
/ _` / __/ __|/ _ \ '__| __|
| (_| \__ \__ \ __/ | | |_
\__,_|___/___/\___|_| \__|
Warning!
Probably, better option foy you is use assert package from npm.
But if you insist I will be happy to hear that you use my package
Please give me any feedback @piecioshka.
Install
$ npm install underscore.assert
Usage
var _ = ;var assert = ;_; _; // throws AssertionError_; // thows ONLY when list is empty_; // => throw `AssertionError`_assertErrorConstructor = MyCustomError;_; // => throw `MyCustomError`
Example
Instead of this:
{ if typeof url === 'string' throw 'URL should be a *string* value'; // ... URL validation}
... you can that:
{ _; // ... URL validation}
There is a shorter, nicer and better experience for developer 😄
Proposals
- This is not for tests files in project...
- This is not instead of Jasmine or any test framework...
- This is inline code for testing production code!
License
The MIT License @ 2013