Improved deep equality testing for Node.js and the browser with support for complex types and circular references.
Overall
score
96%
Build a function signature validator that compares actual function calls against expected signatures to verify correct function invocation patterns.
Create a utility that validates whether functions are being called with the correct argument patterns. The validator should compare the actual arguments passed to a function against expected argument patterns, handling the special nature of JavaScript's arguments object.
Create a validateSignature(actual, expected) function that:
actual: the arguments object from a real function callexpected: an array representing the expected argument patterntrue if the arguments match the pattern (element-by-element comparison)false otherwise(5, "hello", {x: 1}), it should match the expected pattern [5, "hello", {x: 1}] @test(1, 2), it should NOT match the expected pattern [1, 2, 3] (different lengths) @test(1, 2), those arguments should NOT be considered equal to the plain array [1, 2] (arguments vs array distinction) @test({a: {b: 2}}), it should match the expected pattern [{a: {b: 2}}] (deep comparison) @test@generates
/**
* Validates whether function arguments match an expected signature pattern
* @param {IArguments} actual - The arguments object from a function call
* @param {Array} expected - The expected argument pattern as an array
* @returns {boolean} True if arguments match the pattern, false otherwise
*/
function validateSignature(actual, expected) {
// Implementation here
}
module.exports = { validateSignature };Provides deep equality comparison with support for arguments objects.
Install with Tessl CLI
npx tessl i tessl/npm-deep-eqldocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10