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

    Function createNotAdapter

    Export the functions (and global assert)

    • Creates an adapter function that wraps the provided scope function with a "not" operation. When the returned scope function is executed, it first performs a negation (updating the context to negate evaluations) and then calls the provided scope function.

      This is an optimized alternative to using createExprAdapter("not", scopeFn) that avoids expression parsing overhead by directly applying the negation context.

      Parameters

      • scopeFn: IScopeFn

        The scope function to wrap with the "not" operation.

      Returns IScopeFn

      An IScopeFn function that will negate and then execute the provided scope function.

      import { createNotAdapter, createEvalAdapter } from "@nevware21/tripwire";

      const isTrueFunc = createEvalAdapter((actual: any) => actual === true, "Expected value to be true");
      const isNotTrueFunc = createNotAdapter(isTrueFunc);

      // Using with addAssertFunc
      addAssertFunc("isNotTrue", isNotTrueFunc);
      assert.isNotTrue(false); // Passes - false is not true
      assert.isNotTrue(true); // Fails - true is true

      0.1.5