Skip to content

Conversation

@nev21
Copy link
Contributor

@nev21 nev21 commented Jan 27, 2026

Add a new createNotAdapter function that wraps scope functions with a "not" operation more efficiently than createExprAdapter("not", scopeFn). This avoids expression parsing overhead by directly applying the negation context via notOp.

Changes:

  • Add core/src/assert/adapters/notAdapter.ts
  • Replace all 47 usages of createExprAdapter("not", fn) with createNotAdapter(fn) in assertClass.ts
  • Export createNotAdapter from the package index

@nev21 nev21 added this to the 0.1.5 milestone Jan 27, 2026
Copilot AI review requested due to automatic review settings January 27, 2026 06:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an optimized createNotAdapter function to avoid expression parsing overhead when wrapping scope functions with negation operations. The change replaces 47 instances of createExprAdapter("not", fn) with the more efficient createNotAdapter(fn).

Changes:

  • Adds a new optimized adapter createNotAdapter that directly applies negation via notOp instead of parsing the "not" expression
  • Refactors all 47 "not" negation operations in assertClass.ts to use the new adapter
  • Exports the new adapter from the package index for public use

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
core/src/assert/adapters/notAdapter.ts New file implementing the optimized negation adapter that directly calls notOp
core/src/assert/assertClass.ts Replaced all 47 instances of createExprAdapter("not", fn) with createNotAdapter(fn)
core/src/index.ts Added import and export for the new createNotAdapter function

@nev21 nev21 force-pushed the nev21/notAdapter branch 2 times, most recently from 2c2cf69 to 7748f14 Compare January 27, 2026 06:54
Add a new `createNotAdapter` function that wraps scope functions with a
"not" operation more efficiently than `createExprAdapter("not", scopeFn)`.
This avoids expression parsing overhead by directly applying the negation
context via `notOp`.

Changes:
- Add core/src/assert/adapters/notAdapter.ts
- Replace all 47 usages of `createExprAdapter("not", fn)` with `createNotAdapter(fn)` in assertClass.ts
- Export `createNotAdapter` from the package index
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

// To verify negation is active, we check that an eval(true) fails
// and an eval(false) passes, which is the opposite of normal behavior
let evalTrueResult: boolean | undefined;
let evalFalseResult: boolean | undefined;
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable evalFalseResult.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

@nev21 nev21 merged commit 436d4b7 into main Jan 27, 2026
16 checks passed
@nev21 nev21 deleted the nev21/notAdapter branch January 27, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants