@types/assert-plus
- Version 1.0.8
- Published
- 15.4 kB
- 1 dependency
- MIT license
Install
npm i @types/assert-plusyarn add @types/assert-pluspnpm add @types/assert-plusOverview
TypeScript definitions for assert-plus
Index
Functions
- array()
- arrayOfArray()
- arrayOfBool()
- arrayOfBuffer()
- arrayOfDate()
- arrayOfFinite()
- arrayOfFunc()
- arrayOfNumber()
- arrayOfObject()
- arrayOfRegexp()
- arrayOfStream()
- arrayOfString()
- arrayOfUuid()
- AssertionError()
- bool()
- buffer()
- date()
- deepEqual()
- doesNotThrow()
- equal()
- fail()
- finite()
- func()
- ifError()
- notDeepEqual()
- notEqual()
- notStrictEqual()
- number()
- object()
- ok()
- optionalArray()
- optionalArrayOfArray()
- optionalArrayOfBool()
- optionalArrayOfBuffer()
- optionalArrayOfDate()
- optionalArrayOfFinite()
- optionalArrayOfFunc()
- optionalArrayOfNumber()
- optionalArrayOfObject()
- optionalArrayOfRegexp()
- optionalArrayOfStream()
- optionalArrayOfString()
- optionalArrayOfUuid()
- optionalBool()
- optionalBuffer()
- optionalDate()
- optionalFinite()
- optionalFunc()
- optionalNumber()
- optionalObject()
- optionalRegexp()
- optionalStream()
- optionalString()
- optionalUuid()
- regexp()
- stream()
- strictEqual()
- string()
- throws()
- uuid()
Functions
function array
array: (arr: any[], message?: string) => asserts arr is any[];function arrayOfArray
arrayOfArray: (arr: any[][], message?: string) => asserts arr is any[][];function arrayOfBool
arrayOfBool: (arr: boolean[], message?: string) => asserts arr is boolean[];function arrayOfBuffer
arrayOfBuffer: (arr: Buffer[], message?: string) => asserts arr is Buffer[];function arrayOfDate
arrayOfDate: (arr: Date[], message?: string) => asserts arr is Date[];function arrayOfFinite
arrayOfFinite: (arr: number[], message?: string) => asserts arr is number[];function arrayOfFunc
arrayOfFunc: (arr: Func[], message?: string) => asserts arr is Func[];function arrayOfNumber
arrayOfNumber: (arr: number[], message?: string) => asserts arr is number[];function arrayOfObject
arrayOfObject: <T extends object = any>( arr: T[], message?: string) => asserts arr is T[];function arrayOfRegexp
arrayOfRegexp: (arr: RegExp[], message?: string) => asserts arr is RegExp[];function arrayOfStream
arrayOfStream: (arr: Stream[], message?: string) => asserts arr is Stream[];function arrayOfString
arrayOfString: (arr: string[], message?: string) => asserts arr is string[];function arrayOfUuid
arrayOfUuid: (arr: string[], message?: string) => asserts arr is string[];function AssertionError
AssertionError: (options: any, message?: string) => void;function bool
bool: (bool: boolean, message?: string) => asserts bool is boolean;function buffer
buffer: (buffer: Buffer, message?: string) => asserts buffer is Buffer;function date
date: (date: Date, message?: string) => asserts date is Date;function deepEqual
deepEqual: <T>(actual: T, expected: T, message?: string) => void;Tests for deep equality between the
actualandexpectedparameters. Primitive values are compared with the equal comparison operator (==).Only enumerable "own" properties are considered. The
deepEqual()implementation does not test object prototypes, attached symbols, or non-enumerable properties. This can lead to some potentially surprising results. For example, the following example does not throw anAssertionErrorbecause the properties on the Error object are non-enumerable:// WARNING: This does not throw an AssertionError!assert.deepEqual(Error('a'), Error('b'));"Deep" equality means that the enumerable "own" properties of child objects are evaluated also.
If the values are not equal, an
AssertionErroris thrown with amessageproperty set equal to the value of themessageparameter. If themessageparameter is undefined, a default error message is assigned.
function doesNotThrow
doesNotThrow: (block: any, error?: any, message?: string) => void;Asserts that the function
blockdoes not throw an error. Seeassert.throws()for more details.When
assert.doesNotThrow()is called, it will immediately call theblockfunction.If an error is thrown and it is the same type as that specified by the
errorparameter, then anAssertionErroris thrown. If the error is of a different type, or if theerrorparameter is undefined, the error is propagated back to the caller.The following, for instance, will throw the TypeError because there is no matching error type in the assertion:
assert.doesNotThrow(() => {throw new TypeError('Wrong value');},SyntaxError);However, the following will result in an
AssertionErrorwith the message 'Got unwanted exception (TypeError)..':assert.doesNotThrow(() => {throw new TypeError('Wrong value');},TypeError);If an
AssertionErroris thrown and a value is provided for themessageparameter, the value ofmessagewill be appended to theAssertionErrormessage:assert.doesNotThrow(() => {throw new TypeError('Wrong value');},TypeError,'Whoops');// Throws: AssertionError: Got unwanted exception (TypeError). Whoops
function equal
equal: (actual: any, expected: any, message?: string) => void;Tests shallow, coercive equality between the actual and expected parameters using the equal comparison operator (
==).const assert = require('assert');assert.equal(1, 1);// OK, 1 == 1assert.equal(1, '1');// OK, 1 == '1'assert.equal(1, 2);// AssertionError: 1 == 2assert.equal({a: {b: 1}}, {a: {b: 1}});//AssertionError: { a: { b: 1 } } == { a: { b: 1 } }If the values are not equal, an
AssertionErroris thrown with amessageproperty set equal to the value of themessageparameter. If themessageparameter is undefined, a default error message is assigned.
function fail
fail: (actual: any, expected: any, message: any, operator: any) => void;Throws an
AssertionError. Ifmessageis falsy, the error message is set as the values ofactualandexpectedseparated by the providedoperator. Otherwise, the error message is the value ofmessage.const assert = require('assert');assert.fail(1, 2, undefined, '>');// AssertionError: 1 > 2assert.fail(1, 2, 'whoops', '>');// AssertionError: whoops
function finite
finite: (finite: number, message?: string) => asserts finite is number;function func
func: (func: Func, message?: string) => asserts func is Func;function ifError
ifError: (value: any) => void;Throws
valueifvalueis truthy. This is useful when testing theerrorargument in callbacks.const assert = require('assert');assert.ifError(0);// OKassert.ifError(1);// Throws 1assert.ifError('error');// Throws 'error'assert.ifError(new Error());// Throws Error
function notDeepEqual
notDeepEqual: (actual: any, expected: any, message?: string) => void;Tests for any deep inequality. Opposite of
assert.deepEqual().const assert = require('assert');const obj1 = { a : { b : 1 } };const obj2 = { a : { b : 2 } };const obj3 = { a : { b : 1 } };const obj4 = Object.create(obj1);assert.notDeepEqual(obj1, obj1);// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }assert.notDeepEqual(obj1, obj2);// OK, obj1 and obj2 are not deeply equalassert.notDeepEqual(obj1, obj3);// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }assert.notDeepEqual(obj1, obj4);// OK, obj1 and obj2 are not deeply equalIf the values are deeply equal, an
AssertionErroris thrown with amessageproperty set equal to the value of themessageparameter. If themessageparameter is undefined, a default error message is assigned.
function notEqual
notEqual: (actual: any, expected: any, message?: string) => void;Tests shallow, coercive inequality with the not equal comparison operator (
!=).const assert = require('assert');assert.notEqual(1, 2);// OKassert.notEqual(1, 1);// AssertionError: 1 != 1assert.notEqual(1, '1');// AssertionError: 1 != '1'If the values are equal, an
AssertionErroris thrown with amessageproperty set equal to the value of themessageparameter. If themessageparameter is undefined, a default error message is assigned.
function notStrictEqual
notStrictEqual: (actual: any, expected: any, message?: string) => void;Tests strict inequality as determined by the strict not equal operator (
!==).const assert = require('assert');assert.notStrictEqual(1, 2);// OKassert.notStrictEqual(1, 1);// AssertionError: 1 !== 1assert.notStrictEqual(1, '1');// OKIf the values are strictly equal, an
AssertionErroris thrown with amessageproperty set equal to the value of themessageparameter. If themessageparameter is undefined, a default error message is assigned.
function number
number: (number: number, message?: string) => asserts number is number;function object
object: <T extends object = any>(obj: T, message?: string) => asserts obj is T;function ok
ok: (options: any, message?: string) => void;Tests if
valueis truthy. It is equivalent toassert.equal(!!value, true, message).If
valueis not truthy, anAssertionErroris thrown with amessageproperty set equal to the value of themessageparameter. If themessageparameter isundefined, a default error message is assigned.const assert = require('assert');assert.ok(true);// OKassert.ok(1);// OKassert.ok(false);// throws "AssertionError: false == true"assert.ok(0);// throws "AssertionError: 0 == true"assert.ok(false, 'it\'s false');// throws "AssertionError: it's false"
function optionalArray
optionalArray: ( arr: any[] | undefined, message?: string) => asserts arr is any[];function optionalArrayOfArray
optionalArrayOfArray: ( arr: any[][] | undefined, message?: string) => asserts arr is any[][];function optionalArrayOfBool
optionalArrayOfBool: ( arr: boolean[] | undefined, message?: string) => asserts arr is boolean[];function optionalArrayOfBuffer
optionalArrayOfBuffer: ( arr: Buffer[] | undefined, message?: string) => asserts arr is Buffer[];function optionalArrayOfDate
optionalArrayOfDate: ( arr: Date[] | undefined, message?: string) => asserts arr is Date[];function optionalArrayOfFinite
optionalArrayOfFinite: ( arr: number[] | undefined, message?: string) => asserts arr is number[];function optionalArrayOfFunc
optionalArrayOfFunc: ( arr: Func[] | undefined, message?: string) => asserts arr is Func[];function optionalArrayOfNumber
optionalArrayOfNumber: ( arr: number[] | undefined, message?: string) => asserts arr is number[];function optionalArrayOfObject
optionalArrayOfObject: <T extends object = any>( arr: T[] | undefined, message?: string) => asserts arr is T[];function optionalArrayOfRegexp
optionalArrayOfRegexp: ( arr: RegExp[] | undefined, message?: string) => asserts arr is RegExp[];function optionalArrayOfStream
optionalArrayOfStream: ( arr: Stream[] | undefined, message?: string) => asserts arr is Stream[];function optionalArrayOfString
optionalArrayOfString: ( arr: string[] | undefined, message?: string) => asserts arr is string[];function optionalArrayOfUuid
optionalArrayOfUuid: ( arr: string[] | undefined, message?: string) => asserts arr is string[];function optionalBool
optionalBool: ( bool: boolean | undefined, message?: string) => asserts bool is boolean;function optionalBuffer
optionalBuffer: ( buffer: Buffer | undefined, message?: string) => asserts buffer is any;function optionalDate
optionalDate: ( options: Date | undefined, message?: string) => asserts options is Date;function optionalFinite
optionalFinite: ( options: number | undefined, message?: string) => asserts options is number;function optionalFunc
optionalFunc: ( options: Func | undefined, message?: string) => asserts options is Func;function optionalNumber
optionalNumber: ( options: number | undefined, message?: string) => asserts options is number;function optionalObject
optionalObject: <T extends object = any>( options: T | undefined, message?: string) => asserts options is T;function optionalRegexp
optionalRegexp: ( options: RegExp | undefined, message?: string) => asserts options is RegExp;function optionalStream
optionalStream: ( options: Stream | undefined, message?: string) => asserts options is any;function optionalString
optionalString: ( options: string | undefined, message?: string) => asserts options is string;function optionalUuid
optionalUuid: ( options: string | undefined, message?: string) => asserts options is string;function regexp
regexp: (regexp: RegExp, message?: string) => asserts regexp is RegExp;function stream
stream: (stream: Stream, message?: string) => asserts stream is Stream;function strictEqual
strictEqual: <T>(actual: T, expected: T, message?: string) => void;Tests strict equality as determined by the strict equality operator (
===).const assert = require('assert');assert.strictEqual(1, 2);// AssertionError: 1 === 2assert.strictEqual(1, 1);// OKassert.strictEqual(1, '1');// AssertionError: 1 === '1'If the values are not strictly equal, an
AssertionErroris thrown with amessageproperty set equal to the value of themessageparameter. If themessageparameter is undefined, a default error message is assigned.
function string
string: (str: string, message?: string) => asserts str is string;function throws
throws: (block: any, error?: any, message?: string) => void;function uuid
uuid: (uuid: string, message?: string) => asserts uuid is string;Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/assert-plus.
- Markdown[](https://www.jsdocs.io/package/@types/assert-plus)
- HTML<a href="https://www.jsdocs.io/package/@types/assert-plus"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2986 ms. - Missing or incorrect documentation? Open an issue for this package.
