{"library":"over","title":"over - Function Overloading","description":"over is a JavaScript library designed to facilitate function overloading, allowing developers to define multiple implementations for a single function based on the arguments provided during invocation. It operates by accepting an array of 'test functions' (such as `over.string`, `over.numberOptionalWithDefault`, `over.callbackOptional`), which are used to match the types and presence of input arguments against predefined patterns. This enables complex argument signature management, default values for optional parameters, and callback handling in a structured way. The package is currently at version `0.0.5`, with its last significant activity in 2013, and the copyright dates back to 2012. This strongly suggests the project is abandoned, with no active development or maintenance. Its core differentiator was providing a declarative approach to function dispatch in a pre-ESM and pre-TypeScript era, often mitigating verbose `if`/`else` or switch statements for argument validation. It primarily targets Node.js environments.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install over"],"cli":null},"imports":["const over = require('over');","const over = require('over');\nconst myFn = over([over.string, function (str) { /* ... */ }]);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const over = require('over');\n\nconst myfn = over([\n  [over.string, function (str) { console.log('Called with a single string:', str); }],\n  [over.string, over.numberOptionalWithDefault(5), over.callbackOptional, function (str, number, callback) {\n    console.log('Called with string, optional number (default 5), and optional callback.');\n    console.log('String:', str, 'Number:', number);\n    if (callback) {\n      console.log('Executing callback...');\n      callback(str, number);\n    }\n  }],\n  function() {\n    console.log('No specific overload matched. Falling back to default.');\n  }\n]);\n\n// Test cases\nmyfn(\"hello\");\nmyfn(\"world\", 10, (s, n) => console.log(`Callback invoked: ${s}, ${n}`));\nmyfn(\"test\", null, (s, n) => console.log(`Callback invoked with null number: ${s}, ${n}`)); // numberOptionalWithDefault should handle null/undefined\nmyfn(\"another test\", undefined, (s, n) => console.log(`Callback invoked with undefined number: ${s}, ${n}`));\nmyfn(); // Should hit default","lang":"javascript","description":"Demonstrates defining multiple function overloads using `over` with various argument matchers, including optional parameters with defaults and callbacks, then calling the overloaded function with different argument sets to show matching behavior.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}