Modelo.js is a JavaScript utility providing a robust and performant mechanism for object inheritance, specifically designed to extend Node.js's `util.inherits` with multiple inheritance capabilities. As of version 4.2.3, it allows developers to inherit from multiple base objects seamlessly, addressing a common limitation in standard JavaScript inheritance patterns. A key feature is the `isInstance` method, which is automatically added to instances and serves as a reliable replacement for the native `instanceof` operator when working with multiple inheritance, as `instanceof` is inherently limited to single-prototype chains. The library emphasizes performance, aiming for overhead comparable to `util.inherits` despite its added complexity. While the release cadence isn't explicitly detailed, the version number suggests ongoing maintenance. It differentiates itself by offering a familiar Node.js-style interface while introducing powerful multiple inheritance features, making it suitable for projects requiring flexible object composition.
npm install modeloVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic single and multiple inheritance using `modelo.inherits` and shows how to use the `isInstance` method for multi-inherited objects.
Use the `isInstance` method provided on the created instances (e.g., `instance.isInstance(MixinOne)`) instead of `instanceof` to accurately check for inheritance against all base objects in a multiple inheritance scenario.
When performing multiple inheritance, avoid the `super_` attribute. Instead, directly call the desired parent prototype's method using `<Constructor>.prototype.<method>.call(this, ...)` or `<Constructor>.prototype.<method>.apply(this, ...)`.
Use the `isInstance` method provided by Modelo.js on the instance itself: `instance.isInstance(MixinTwo)`.
For multiple inheritance, directly invoke the method on the specific parent prototype: `MixinTwo.prototype.method.call(this, ...)` instead of relying on `super_`.
No dependency data recorded yet.