{"id":10674,"library":"core-object","title":"CoreObject","description":"CoreObject is a JavaScript library providing a lightweight, robust implementation of an OOP Class model. It was primarily developed for and used within the Ember-CLI ecosystem to define and extend classes, facilitating a structured approach to object-oriented programming in JavaScript. The package supports Node.js environments from version 4 onwards. While the latest public version is 3.1.5, its last major update was published approximately nine years ago, indicating that the project is currently abandoned. Consequently, there is no active release cadence, and it is not recommended for new projects seeking ongoing maintenance, security updates, or modern JavaScript features. Its primary value now lies in its historical context within legacy Ember-CLI applications, where it continues to function as a core utility.","status":"abandoned","version":"3.1.5","language":"javascript","source_language":"en","source_url":"https://github.com/ember-cli/core-object","tags":["javascript"],"install":[{"cmd":"npm install core-object","lang":"bash","label":"npm"},{"cmd":"yarn add core-object","lang":"bash","label":"yarn"},{"cmd":"pnpm add core-object","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"While a CJS module, Node.js ESM loaders will resolve the `module.exports` as the default import. There are no named exports.","wrong":"import { CoreObject } from 'core-object';","symbol":"CoreObject","correct":"import CoreObject from 'core-object';"},{"note":"CoreObject exports a single class as its default CommonJS export, not an object with named properties.","wrong":"const { CoreObject } = require('core-object');","symbol":"CoreObject","correct":"const CoreObject = require('core-object');"},{"note":"Best practice is to import/require CoreObject first, then extend it, for clarity and consistency.","wrong":"class BasicClass extends require('core-object') {}","symbol":"BasicClass","correct":"class BasicClass extends CoreObject {}"}],"quickstart":{"code":"import CoreObject from 'core-object';\n\n// Define a base class\nconst Animal = CoreObject.extend({\n  init() {\n    this._super(...arguments);\n    this.name = 'Unnamed';\n  },\n  sayHello() {\n    console.log(`Hello, I am ${this.name}.`);\n  }\n});\n\n// Extend the base class\nconst Dog = Animal.extend({\n  init(name) {\n    this._super(...arguments);\n    this.name = name || 'Fido';\n  },\n  bark() {\n    console.log(`${this.name} says Woof!`);\n  },\n  sayHello() {\n    this._super(...arguments);\n    this.bark();\n  }\n});\n\n// Create instances\nconst genericAnimal = Animal.create();\ngenericAnimal.sayHello(); // Output: Hello, I am Unnamed.\n\nconst myDog = Dog.create('Buddy');\nmyDog.sayHello(); // Output: Hello, I am Buddy.\\nBuddy says Woof!\nmyDog.bark(); // Output: Buddy says Woof!\n\n// Demonstrating `reopen` for adding methods dynamically\nDog.reopen({\n  fetch() {\n    console.log(`${this.name} is fetching!`);\n  }\n});\n\nmyDog.fetch(); // Output: Buddy is fetching!","lang":"javascript","description":"This quickstart demonstrates defining a base class, extending it, creating instances, and dynamically adding methods using `reopen`."},"warnings":[{"fix":"Migrate to a modern, actively maintained class implementation or inheritance pattern (e.g., native ES6 classes, utilities like `classnames`, or framework-specific solutions). For legacy Ember-CLI projects, consider deeply analyzing the risk of using unmaintained dependencies.","message":"The package is effectively abandoned, with its last public release (v3.1.5) over nine years ago. It receives no active maintenance, bug fixes, or security updates.","severity":"breaking","affected_versions":">=3.1.5"},{"fix":"Ensure your build tooling (e.g., Webpack, Rollup) is configured to handle CommonJS modules within an ESM project. For Node.js, confirm the `type: \"module\"` in `package.json` allows interoperability or use dynamic `import()` for problematic cases.","message":"Being an older CommonJS package, direct usage in pure ESM environments might require specific Node.js configuration or bundler setups to correctly interpret `require()` and `module.exports`. While Node.js often handles CJS imports in ESM, unexpected behaviors can arise, especially with tooling.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always include `this._super(...arguments)` as the first line in any overridden `init` method to ensure the inheritance chain's constructors are properly invoked.","message":"The `init` method in `CoreObject` classes requires calling `this._super(...arguments)` to ensure proper initialization of parent classes, similar to `super()` in native ES6 classes. Forgetting this call can lead to uninitialized properties or unexpected behavior from inherited constructors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"For ESM, use `import CoreObject from 'core-object';`. For CJS, use `const CoreObject = require('core-object');`. Ensure your build/runtime environment correctly resolves CJS modules.","cause":"Incorrect import statement or module resolution failure in ESM context for a CJS package.","error":"TypeError: CoreObject is not a constructor or undefined"},{"fix":"Only call `this._super()` when truly overriding a parent method. In `init` methods, always include `this._super(...arguments)` as the first line. If a method is new, remove the `this._super()` call.","cause":"Attempting to call `this._super()` in a method that does not override a parent method, or `init` method did not properly call `this._super()` in the constructor chain.","error":"TypeError: this._super is not a function"}],"ecosystem":"npm"}