-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(core): add optimized createNotAdapter for negation operations #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
createNotAdapterthat directly applies negation vianotOpinstead of parsing the "not" expression - Refactors all 47 "not" negation operations in
assertClass.tsto 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 |
2c2cf69 to
7748f14
Compare
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
7748f14 to
5fca4ae
Compare
There was a problem hiding this 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; |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable evalFalseResult.
There was a problem hiding this comment.
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
Add a new
createNotAdapterfunction that wraps scope functions with a "not" operation more efficiently thancreateExprAdapter("not", scopeFn). This avoids expression parsing overhead by directly applying the negation context vianotOp.Changes:
createExprAdapter("not", fn)withcreateNotAdapter(fn)in assertClass.tscreateNotAdapterfrom the package index