class-utils is a JavaScript utility library designed to assist developers in working with and manipulating JavaScript classes and their prototype methods. As of its current stable version, 0.3.6, it provides functions for tasks such as checking for property existence (`has`, `hasAll`), type coercion (`arrayify`), inspecting constructors (`hasConstructor`), retrieving property descriptors (`getDescriptor`), and managing inheritance and property copying between objects (`copyDescriptor`, `copy`, `inherit`). The library's focus is on lower-level prototype manipulation, which was more common in pre-ES6 JavaScript class patterns, though its utilities remain functional for modern class syntax when deeper introspection or direct prototype modification is required. It typically follows a stable, low-cadence release cycle given its foundational utility nature. A key differentiator is its explicit focus on descriptors and direct prototype manipulation, offering fine-grained control over object properties and inheritance chains beyond typical `Object.assign` or spread operator usage. It is primarily a CommonJS module built for Node.js environments from version 0.10.0 and up.
npm install class-utilsVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing the class-utils library and using `copyDescriptor` to transfer a property descriptor from one object's prototype to another.
Use `const cu = require('class-utils');` for Node.js projects or ensure your build setup correctly transpiles CommonJS for browser or ESM environments.Be aware that the library's design reflects older JavaScript paradigms. Integrate carefully with modern class syntax if deep prototype manipulation is not your primary goal.
Familiarize yourself with JavaScript's object prototypes and property descriptors (e.g., `Object.defineProperty`, `Object.getOwnPropertyDescriptor`) to fully understand the library's capabilities and implications.
Change your import statement to `const cu = require('class-utils');`Verify the method name is correct according to the API (`cu.has`, `cu.copyDescriptor`, etc.) and ensure `const cu = require('class-utils');` executed without error.No dependency data recorded yet.