assert
Functions
- equal(a, b, [m])
- notEqual(a, b, [m])
- notOk(t, [m])
- logicalEquals(a, b, [m])
- assert(t, [m])
- greaterThan(a, b, [m])
- lessThan(a, b, [m])
- greaterThanOrEqual(a, b, [m])
- lessThanOrEqual(a, b, [m])
- isOneOf(value, options, [name])
- typeOf(value, type, valueName)
Perform a value typeof === type check and throw an error if the type does not match.
For static cases, prefer to use specific type-checking functions such as isString or isNumber.
- arrayHas(haystack, needle, [message])
- arrayHasNo(haystack, needle, [message])
- arrayEqual(a, b, [message])
equal(a, b, [m])
Kind: global function
| Param | Type |
|---|---|
| a | T |
| b | T |
| [m] | string |
notEqual(a, b, [m])
Kind: global function
| Param | Type |
|---|---|
| a | T |
| b | T |
| [m] | string |
notOk(t, [m])
Kind: global function
| Param | Type |
|---|---|
| t | boolean |
| [m] | string |
logicalEquals(a, b, [m])
Kind: global function
| Param | Type |
|---|---|
| a | object |
| b | object |
| [m] | string |
assert(t, [m])
Kind: global function
| Param | Type |
|---|---|
| t | boolean |
| [m] | string |
- assert(t, [m])
.isFiniteNumber- .enum(value, enumerable, [name])
- .isInstanceOf(value, klass, [value_name], [class_name])
- .isNumber(value, [name])
- .isString(value, [name])
- .isBoolean(value, [name])
- .isFunction(value, [name])
- .isObject(value, [name])
- .isInteger(value, [name])
- .isNonNegativeInteger(value, [name])
- .isArray(value, name)
- .isArrayLike(value, name)
- .defined(value, [name])
- .undefined(value, [name])
- .isNull(value, [name])
- .notNull(value, [name])
- .notNaN(value, name)
- .isFinite(value, [name])
- .that(value, name, matcher)
assert.isFiniteNumber
use isFinite instead
Alias
Kind: static property of assert
assert.enum(value, enumerable, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | T |
| enumerable | Object.<T> |
| [name] | string |
assert.isInstanceOf(value, klass, [value_name], [class_name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | * |
| klass | Class |
| [value_name] | string |
| [class_name] | string |
assert.isNumber(value, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | number | * |
| [name] | string |
assert.isString(value, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | string | * |
| [name] | string |
assert.isBoolean(value, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | boolean | * |
| [name] | string |
assert.isFunction(value, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | function | * |
| [name] | string |
assert.isObject(value, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | Object | * |
| [name] | string |
assert.isInteger(value, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | number | * |
| [name] | string |
assert.isNonNegativeInteger(value, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | number | * |
| [name] | string |
assert.isArray(value, name)
Kind: static method of assert
| Param | Type |
|---|---|
| value | Array.<T> |
| name | string |
assert.isArrayLike(value, name)
Kind: static method of assert
| Param | Type |
|---|---|
| value | ArrayLike.<T> | Array.<T> | Uint32Array | Float32Array |
| name | string |
assert.defined(value, [name])
Check for value !== undefined, throws exception if value is undefined
Kind: static method of assert
| Param | Type |
|---|---|
| value | * |
| [name] | String |
assert.undefined(value, [name])
Checks for value === undefined, throws exception if value is NOT undefined
Kind: static method of assert
| Param | Type |
|---|---|
| value | * |
| [name] | String |
assert.isNull(value, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | * |
| [name] | String |
assert.notNull(value, [name])
Kind: static method of assert
| Param | Type |
|---|---|
| value | * |
| [name] | String |
assert.notNaN(value, name)
Kind: static method of assert
| Param | Type |
|---|---|
| value | number |
| name | string |
assert.isFinite(value, [name])
Is the given number finite?
Will trigger if the number is infinite, i.e. fails the Number.isFinite test
Kind: static method of assert
| Param | Type | Description |
|---|---|---|
| value | number | |
| [name] | string | optional name for the value being checked |
assert.that(value, name, matcher)
More powerful and flexible assertion API based on matchers. Allows complex matching criteria to be constructed.
see Matcher
Kind: static method of assert
| Param | Type |
|---|---|
| value | T |
| name | string |
| matcher | Matcher.<T> |
Example
assert.that(value,'value', anyOf(isNull(),isUndefined())); // will trigger iff !(value === undefined || value === null)
assert.that(value, 'value', isOneOf([3,7])); // will only trigger iff !(value === 3 || value === 7)
greaterThan(a, b, [m])
Kind: global function
| Param | Type |
|---|---|
| a | number |
| b | number |
| [m] | string |
lessThan(a, b, [m])
Kind: global function
| Param | Type |
|---|---|
| a | number |
| b | number |
| [m] | string |
greaterThanOrEqual(a, b, [m])
Kind: global function
| Param | Type |
|---|---|
| a | number |
| b | number |
| [m] | string |
lessThanOrEqual(a, b, [m])
Kind: global function
| Param | Type |
|---|---|
| a | number |
| b | number |
| [m] | string |
isOneOf(value, options, [name])
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| value | T | ||
| options | Array.<T> | must be string-serializable for useful error messages | |
| [name] | string | "value" | optional name for a better error message |
typeOf(value, type, valueName)
Perform a value typeof === type check and throw an error if the type does not match.
For static cases, prefer to use specific type-checking functions such as isString or isNumber.
Kind: global function
| Param | Type | Default |
|---|---|---|
| value | * | |
| type | string | |
| valueName | string | "value" |
arrayHas(haystack, needle, [message])
Kind: global function
| Param | Type | Default |
|---|---|---|
| haystack | Array.<T> | |
| needle | T | |
| [message] | string | "Array does not contain the item" |
arrayHasNo(haystack, needle, [message])
Kind: global function
| Param | Type | Default |
|---|---|---|
| haystack | Array.<T> | |
| needle | T | |
| [message] | string | "Array contains the item" |
arrayEqual(a, b, [message])
Kind: global function
| Param | Type | Default |
|---|---|---|
| a | Array.<T> | ArrayLike.<T> | Float32Array | Int32Array | |
| b | Array.<T> | ArrayLike.<T> | Float32Array | Int32Array | |
| [message] | string | "Arrays are not equal" |