CodeVetter · Repo Unpack · Data flow
chaijs/chai
Assertion input becomes a target reference plus metadata stored in flags. Chain getters and methods propagate those flags, while selected operations replace the target for subsequent assertions. Comparison results pass through a common negation and error-construction boundary. Outputs are continuing assertion objects, explicit return values, or thrown errors; inspected callback operations can also modify consumer-owned state.
- expect forwards its value and optional message to Assertion; construction records object, message, ssfi, lockSsfi, and the current configured deep comparator.
- flag reads or writes __flags according to argument count; transferFlags copies flag values and can exclude object, ssfi, lockSsfi, and message.
- Property and method wrappers call the supplied implementation, preserve explicit results, and otherwise construct another Assertion populated with transferred flags.
- Chainable getters first run chainingBehavior, then create a callable wrapper that inherits assertion properties, copies flags, and is proxified; calling it runs the stored method.
- assertProperty resolves nested paths through getPathInfo or reads obj[name], checks existence and optional equality, then replaces the object flag with the resolved value.
- Assertion.assert sends the expression through util.test for negation, applies showDiff policy, derives message/actual/operator metadata, and throws AssertionError only on failure.
- getMessage selects positive or negative templates, evaluates function templates, replaces this/act/exp placeholders in one pass, and prefixes the custom message; display delegates to loupe and threshold-based summaries.
- change reads a subject before and after invoking the target function, stores delta metadata in flags, and leaves the consumer's resulting state in place; by reads those stored values without invoking the callback again.