{"id":15439,"library":"gextend","title":"GExtend Object Utility","description":"GExtend is a concise utility module designed for robust object extension, supporting both Node.js and browser environments. The package, currently at version 0.8.0, provides a flexible `extend` function to merge properties from multiple source objects into a target object, analogous to `jQuery.extend` or `Object.assign`. It includes specialized methods like `extend.only` for selective property merging, `extend.shim` to safely wrap objects (e.g., `console`) without direct modification, and `extend.unshim` for reverting shims, making it suitable for creating configurable and insulated class instances. Despite its utility, the project appears to be largely unmaintained, with its last recorded release history updates dating back to 2019. Its primary distribution method and usage patterns predate modern JavaScript module conventions, relying heavily on CommonJS and mentioning Bower for frontend integration.","status":"abandoned","version":"0.8.0","language":"javascript","source_language":"en","source_url":"git://github.com/goliatone/gextend","tags":["javascript"],"install":[{"cmd":"npm install gextend","lang":"bash","label":"npm"},{"cmd":"yarn add gextend","lang":"bash","label":"yarn"},{"cmd":"pnpm add gextend","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primary usage pattern for this CommonJS-first library. The 'extend' symbol is an object/function.","wrong":"import extend from 'gextend';","symbol":"extend","correct":"const extend = require('gextend');"},{"note":"For modern ESM environments, `import * as` is the most reliable way to import a CommonJS module that exports a function/object directly. A direct default import (`import extend from 'gextend';`) might not work without specific transpiler/Node.js configurations for CJS interop.","wrong":"import { extend } from 'gextend';","symbol":"extend (ESM compatibility)","correct":"import * as extend from 'gextend';"},{"note":"These are methods on the `extend` object itself, not separate named exports. Access them via the main `extend` import.","wrong":"import { only, shim } from 'gextend';","symbol":"extend.only, extend.shim, extend.unshim","correct":"const extend = require('gextend');\n// ... later ...\nextend.only(attributes);"}],"quickstart":{"code":"const extend = require('gextend');\n\nconst DEFAULTS = {\n    port: 9090,\n    url: 'http://localhost'\n};\n\nfunction connect(options){\n    // Merges options into DEFAULTS, then into a new empty object.\n    // The empty object {} ensures DEFAULTS is not mutated.\n    let config = extend({}, DEFAULTS, options);\n    console.log('Connect to %s:%s', config.url, config.port);\n}\n\n// Example usage\nconnect({\n    url: 'http://127.0.0.1'\n});\n\nconnect({\n    port: 8080\n});\n\nconnect({});","lang":"javascript","description":"Demonstrates the core object extension functionality, showing how to merge default configuration with user-provided options to create a final, immutable configuration object for a `connect` function."},"warnings":[{"fix":"Review existing code that extends objects containing functions and adjust expectations or implementation if function merging was previously desired. Functions will now be replaced, not merged.","message":"Starting with v0.4.0, the `extend` function changed its behavior when handling functions during merging. Previously, functions might have been extended, but now they are overwritten directly, which can change object behavior if you were relying on function merging.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"For new projects, consider using actively maintained alternatives like `Object.assign()` (native ES6), Lodash's `_.merge()` or `_.defaults()`, or other modern utility libraries. For existing projects, be aware of the lack of updates.","message":"The `gextend` package appears to be an abandoned project. Its last activity in the release history dates back to 2019, and it references deprecated tools like Bower.js. This implies no active maintenance, security updates, or feature development, making it potentially unsuitable for new projects or critical applications.","severity":"gotcha","affected_versions":">=0.6.0"},{"fix":"In CJS environments, use `const extend = require('gextend');`. In ESM, use `import * as extend from 'gextend';` or rely on a bundler to handle CJS module resolution.","message":"GExtend is primarily a CommonJS (CJS) module. While it can be used in modern Node.js ESM environments via interoperability layers, direct `import extend from 'gextend';` might not work as expected without specific `type: 'module'` in `package.json` and/or bundler configurations.","severity":"gotcha","affected_versions":"all"},{"fix":"Do not attempt to install or manage `gextend` via Bower. Use npm (`npm install gextend`) or Yarn (`yarn add gextend`) instead.","message":"The README extensively mentions and provides instructions for Bower, a package manager for the web that has largely been superseded by npm and Yarn for frontend dependency management. This further highlights the package's age and lack of modern tooling adoption.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"First, ensure the package is installed: `npm install gextend`. If using ESM, try `import * as extend from 'gextend';` or verify your build configuration supports CJS module interoperability.","cause":"The package 'gextend' has not been installed, or the CommonJS `require()` path is incorrect, or you are trying to use an ESM `import` in a context where it's not resolved properly.","error":"Error: Cannot find module 'gextend'"},{"fix":"Verify that you are using `const extend = require('gextend');` in CommonJS. If in ESM, ensure you are importing it as an object (e.g., `import * as extend from 'gextend';`) and then calling `extend.default()` or `extend({}, ...)` if it exposes itself as the default.","cause":"This usually occurs when attempting to call `extend()` directly after an incorrect `import` statement in an ESM context, or if the `require('gextend')` result is not assigned to a variable named `extend`.","error":"TypeError: extend is not a function"},{"fix":"Avoid using `sudo npm install -g` as it can lead to permission issues. Instead, fix permissions by running `sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}` or, preferably, use a Node Version Manager (like nvm) to manage Node.js versions and packages without requiring `sudo`.","cause":"This error, often seen on older Node.js setups, indicates insufficient permissions for npm to write to global installation directories, typically `/usr/local/lib/node_modules`.","error":"EACCES: permission denied, mkdir '/usr/local/lib/node_modules/gextend'"}],"ecosystem":"npm"}