autocreate is a JavaScript utility that allows classes to be called without the `new` keyword, and provides a hook method (`__class_call__`) to customize behavior when invoked as a plain function. Current stable version is 1.2.0, with a low release cadence. It supports ES7/Babel decorators, TypeScript, CoffeeScript, and plain JavaScript, targeting ES5/ES6+ environments. Unlike similar libraries (e.g., `newless`), autocreate handles inheritance, static properties, and non-enumerable descriptors without external dependencies. It provides both decorator and manual wrapping patterns for maximum flexibility.
npm install autocreateVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of @auto decorator to omit `new`, and custom __class_call__ hook for different behavior when called as function.
Use `const MyClass = auto(class { ... })` instead of `@auto` for class expressions.Access constructor via `this.constructor` or store needed state on the prototype.
Use a static async factory method instead.
Manually call parent's `__class_call__` from child's if needed.
If using ESM, use `createRequire` from 'module' or a bundler that handles CJS interop.
Export the class before applying `@auto`, or use a separate variable to hold the wrapped class.
Use the functional form: `const MyClass = auto(MyClass)` after the class definition, or transpile with Babel/TypeScript with decorator support.
Use `const auto = require('autocreate')` (CommonJS) or configure bundler to handle default exports from CJS.No dependency data recorded yet.