{"library":"ngraph.merge","title":"ngraph.merge","description":"ngraph.merge is a minimalist JavaScript utility designed to extend target objects with properties from source objects without introducing external dependencies. It primarily operates as a shallow merge. Its key differentiator is a specific, somewhat unconventional, conflict resolution strategy: properties from the source will overwrite existing target properties only if their types differ. If the target already contains a property with the same name and type, it is *not* overwritten by the source property. The package is currently at version 1.0.0, with its last commit in 2017, indicating it is no longer actively maintained and has an abandoned release cadence. Its zero-dependency footprint makes it suitable for environments where bundle size and dependency chain control are critical, though its unique merge logic requires careful consideration.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install ngraph.merge"],"cli":null},"imports":["const merge = require('ngraph.merge');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const merge = require('ngraph.merge');\n\nconst defaults = {\n  name: 'Guest',\n  age: 30,\n  isActive: true,\n  settings: { theme: 'dark' }\n};\n\nconst userOptions = {\n  name: 'Alice',       // Same type as default, will not overwrite\n  age: 'thirty',      // Different type (string vs number), will overwrite\n  isAdmin: false,\n  settings: { debug: true } // New property for settings, will overwrite entire settings object if it's not a deep merge\n};\n\nconst finalOptions = {};\nmerge(finalOptions, defaults);\nconsole.log('1. After merging with defaults:', finalOptions);\n// Expected: { name: 'Guest', age: 30, isActive: true, settings: { theme: 'dark' } }\n\nmerge(finalOptions, userOptions);\nconsole.log('2. After merging with user options:', finalOptions);\n// Expected: { name: 'Guest', age: 'thirty', isActive: true, isAdmin: false, settings: { theme: 'dark' } }\n// Note: `name` remains 'Guest' because types match. `age` becomes 'thirty' due to type mismatch.\n// `settings` in `userOptions` will not overwrite because the `settings` property in `finalOptions` already exists and has the same object type.\n\nconsole.log('Final Name:', finalOptions.name);     // Expected: 'Guest'\nconsole.log('Final Age:', finalOptions.age);       // Expected: 'thirty'\nconsole.log('Final Is Admin:', finalOptions.isAdmin); // Expected: false\nconsole.log('Final Settings:', finalOptions.settings); // Expected: { theme: 'dark' } - not affected by userOptions.settings because it's a shallow merge and type match.","lang":"javascript","description":"This quickstart demonstrates basic usage and highlights the specific shallow merge logic and overwrite behavior based on type matching.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}