@types/assert-plus

  • Version 1.0.4
  • Published
  • 1 dependency
  • MIT license

Install

npm i @types/assert-plus
yarn add @types/assert-plus
pnpm add @types/assert-plus

Overview

TypeScript definitions for assert-plus

Index

Functions

function array

array: (arr: any[], message?: string) => void;

    function arrayOfArray

    arrayOfArray: (arr: any[][], message?: string) => void;

      function arrayOfBool

      arrayOfBool: (arr: boolean[], message?: string) => void;

        function arrayOfBuffer

        arrayOfBuffer: (arr: Buffer[], message?: string) => void;

          function arrayOfDate

          arrayOfDate: (arr: Date[], message?: string) => void;

            function arrayOfFinite

            arrayOfFinite: (arr: number[], message?: string) => void;

              function arrayOfFunc

              arrayOfFunc: (arr: any[], message?: string) => void;

                function arrayOfNumber

                arrayOfNumber: (arr: number[], message?: string) => void;

                  function arrayOfObject

                  arrayOfObject: (arr: any[], message?: string) => void;

                    function arrayOfRegexp

                    arrayOfRegexp: (arr: RegExp[], message?: string) => void;

                      function arrayOfStream

                      arrayOfStream: (arr: Stream[], message?: string) => void;

                        function arrayOfString

                        arrayOfString: (arr: string[], message?: string) => void;

                          function arrayOfUuid

                          arrayOfUuid: (arr: string[], message?: string) => void;

                            function AssertionError

                            AssertionError: (options: any, message?: string) => void;

                              function bool

                              bool: (bool: boolean, message?: string) => void;

                                function buffer

                                buffer: (buffer: any, message?: string) => void;

                                  function date

                                  date: (date: Date, message?: string) => void;

                                    function deepEqual

                                    deepEqual: <T>(actual: T, expected: T, message?: string) => void;
                                    • Tests for deep equality between the actual and expected parameters. 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 an AssertionError because 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 AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default error message is assigned.

                                    function doesNotThrow

                                    doesNotThrow: (block: any, error?: any, message?: string) => void;
                                    • Asserts that the function block does not throw an error. See assert.throws() for more details.

                                      When assert.doesNotThrow() is called, it will immediately call the block function.

                                      If an error is thrown and it is the same type as that specified by the error parameter, then an AssertionError is thrown. If the error is of a different type, or if the error parameter 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 AssertionError with the message 'Got unwanted exception (TypeError)..':

                                      assert.doesNotThrow(
                                      () => {
                                      throw new TypeError('Wrong value');
                                      },
                                      TypeError
                                      );

                                      If an AssertionError is thrown and a value is provided for the message parameter, the value of message will be appended to the AssertionError message:

                                      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 == 1
                                      assert.equal(1, '1');
                                      // OK, 1 == '1'
                                      assert.equal(1, 2);
                                      // AssertionError: 1 == 2
                                      assert.equal({a: {b: 1}}, {a: {b: 1}});
                                      //AssertionError: { a: { b: 1 } } == { a: { b: 1 } }

                                      If the values are not equal, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default error message is assigned.

                                    function fail

                                    fail: (actual: any, expected: any, message: any, operator: any) => void;
                                    • Throws an AssertionError. If message is falsy, the error message is set as the values of actual and expected separated by the provided operator. Otherwise, the error message is the value of message.

                                      const assert = require('assert');
                                      assert.fail(1, 2, undefined, '>');
                                      // AssertionError: 1 > 2
                                      assert.fail(1, 2, 'whoops', '>');
                                      // AssertionError: whoops

                                    function finite

                                    finite: (finite: number, message?: string) => void;

                                      function func

                                      func: (func: any, message?: string) => void;

                                        function ifError

                                        ifError: (value: any) => void;
                                        • Throws value if value is truthy. This is useful when testing the error argument in callbacks.

                                          const assert = require('assert');
                                          assert.ifError(0);
                                          // OK
                                          assert.ifError(1);
                                          // Throws 1
                                          assert.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 equal
                                          assert.notDeepEqual(obj1, obj3);
                                          // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
                                          assert.notDeepEqual(obj1, obj4);
                                          // OK, obj1 and obj2 are not deeply equal

                                          If the values are deeply equal, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter 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);
                                          // OK
                                          assert.notEqual(1, 1);
                                          // AssertionError: 1 != 1
                                          assert.notEqual(1, '1');
                                          // AssertionError: 1 != '1'

                                          If the values are equal, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter 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);
                                          // OK
                                          assert.notStrictEqual(1, 1);
                                          // AssertionError: 1 !== 1
                                          assert.notStrictEqual(1, '1');
                                          // OK

                                          If the values are strictly equal, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default error message is assigned.

                                        function number

                                        number: (number: number, message?: string) => void;

                                          function object

                                          object: (obj: any, message?: string) => void;

                                            function ok

                                            ok: (options: any, message?: string) => void;
                                            • Tests if value is truthy. It is equivalent to assert.equal(!!value, true, message).

                                              If value is not truthy, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default error message is assigned.

                                              const assert = require('assert');
                                              assert.ok(true);
                                              // OK
                                              assert.ok(1);
                                              // OK
                                              assert.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) => void;

                                              function optionalArrayOfArray

                                              optionalArrayOfArray: (arr: any[][] | undefined, message?: string) => void;

                                                function optionalArrayOfBool

                                                optionalArrayOfBool: (arr: boolean[] | undefined, message?: string) => void;

                                                  function optionalArrayOfBuffer

                                                  optionalArrayOfBuffer: (arr: Buffer[] | undefined, message?: string) => void;

                                                    function optionalArrayOfDate

                                                    optionalArrayOfDate: (arr: Date[] | undefined, message?: string) => void;

                                                      function optionalArrayOfFinite

                                                      optionalArrayOfFinite: (arr: number[] | undefined, message?: string) => void;

                                                        function optionalArrayOfFunc

                                                        optionalArrayOfFunc: (arr: any[] | undefined, message?: string) => void;

                                                          function optionalArrayOfNumber

                                                          optionalArrayOfNumber: (arr: number[] | undefined, message?: string) => void;

                                                            function optionalArrayOfObject

                                                            optionalArrayOfObject: (arr: any[] | undefined, message?: string) => void;

                                                              function optionalArrayOfRegexp

                                                              optionalArrayOfRegexp: (arr: RegExp[] | undefined, message?: string) => void;

                                                                function optionalArrayOfStream

                                                                optionalArrayOfStream: (arr: Stream[] | undefined, message?: string) => void;

                                                                  function optionalArrayOfString

                                                                  optionalArrayOfString: (arr: string[] | undefined, message?: string) => void;

                                                                    function optionalArrayOfUuid

                                                                    optionalArrayOfUuid: (arr: string[] | undefined, message?: string) => void;

                                                                      function optionalBool

                                                                      optionalBool: (bool: boolean | undefined, message?: string) => void;

                                                                        function optionalBuffer

                                                                        optionalBuffer: (buffer: Buffer | undefined, message?: string) => void;

                                                                          function optionalDate

                                                                          optionalDate: (options: Date | undefined, message?: string) => void;

                                                                            function optionalFinite

                                                                            optionalFinite: (options: number | undefined, message?: string) => void;

                                                                              function optionalFunc

                                                                              optionalFunc: (options: any, message?: string) => void;

                                                                                function optionalNumber

                                                                                optionalNumber: (options: number | undefined, message?: string) => void;

                                                                                  function optionalObject

                                                                                  optionalObject: (options: any, message?: string) => void;

                                                                                    function optionalRegexp

                                                                                    optionalRegexp: (options: RegExp | undefined, message?: string) => void;

                                                                                      function optionalStream

                                                                                      optionalStream: (options: Stream | undefined, message?: string) => void;

                                                                                        function optionalString

                                                                                        optionalString: (options: string | undefined, message?: string) => void;

                                                                                          function optionalUuid

                                                                                          optionalUuid: (options: string | undefined, message?: string) => void;

                                                                                            function regexp

                                                                                            regexp: (regexp: RegExp, message?: string) => void;

                                                                                              function stream

                                                                                              stream: (stream: any, message?: string) => void;

                                                                                                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 === 2
                                                                                                  assert.strictEqual(1, 1);
                                                                                                  // OK
                                                                                                  assert.strictEqual(1, '1');
                                                                                                  // AssertionError: 1 === '1'

                                                                                                  If the values are not strictly equal, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default error message is assigned.

                                                                                                function string

                                                                                                string: (str: string, message?: string) => void;

                                                                                                  function throws

                                                                                                  throws: (block: any, error?: any, message?: string) => void;

                                                                                                    function uuid

                                                                                                    uuid: (uuid: string, message?: string) => void;

                                                                                                      Package Files (1)

                                                                                                      Dependencies (1)

                                                                                                      Dev Dependencies (0)

                                                                                                      No dev dependencies.

                                                                                                      Peer Dependencies (0)

                                                                                                      No peer dependencies.

                                                                                                      Badge

                                                                                                      To add a badge like this onejsDocs.io badgeto 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
                                                                                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](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>