@nevware21/tripwire - v0.1.2
    Preparing search index...

    Function addAssertFuncs

    • Adds multiple new assertion functions to the assert instance, it does not add these functions to the IAssertInst "class" so they will be only available by directly referencing the assert instance.

      This method allows you to add multiple assertion functions at once. Each function is defined by a name and a definition. The definition can be a string, an array of strings, a function, or an object that implements the IAssertDef interface.

      Parameters

      • target: any

        The instance to add the functions to.

      • funcs: { [key: string]: AssertClassDef }

        An object where the keys are the names of the functions to add, and the values are their definitions.

      • OptionalresponseHandler: (result: any) => any

      Returns void

      AssertionError - If any of the definitions are invalid.

      addAssertFuncs({
      isPositive: (value) => this._context.eval(value > 0)
      isNegative: (value) => this._context.eval(value < 0),
      isArray: "is.array",
      isObject: ["is", "object"]
      });

      assert.isPositive(1); // Passes
      assert.isPositive(0); // Fails - throws an AssertionFailure
      assert.isNegative(-1); // Passes
      assert.isArray([]); // Passes
      assert.isObject({}); // Passes

      0.1.0