Methods
assert(condition, messageopt, nullable)
Classical assert method. If condition is falsy, throw assert exception.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
condition |
Boolean | defines if an assertion is successful |
||
message |
String |
<optional> <nullable> |
'assert exception: assertion failed' | to display if assertion fails |
Throws:
assert exception
Example
function set(name, value){
assert(name.length > 0);
assert(isPlainObject(value), 'error: value must be plain object');
...
}