{"library":"object-lib","title":"Object Utility Library","description":"object-lib is a utility library for JavaScript that provides a collection of functions for robust object manipulation, particularly focusing on recursive operations, alignment, cloning, deep comparison, and merging. The current stable version is 5.2.4, with frequent patch and minor releases, indicating active maintenance and continuous development. Key differentiators include its integration with `object-scan` syntax for declarative pathing in functions like `clone` and `Merge`, enabling powerful and flexible data transformations. It also offers unique features like `jsonSmartParse` for gracefully handling malformed JSON, often encountered from LLM outputs, and `SafeProxy` for creating proxy objects that enforce strict property access, throwing errors for non-existent keys instead of returning `undefined`. The library is designed for modern Node.js environments, requiring Node.js version 20 or higher since v5.0.0, ensuring compatibility with contemporary JavaScript features.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install object-lib"],"cli":null},"imports":["import { align } from 'object-lib';","import { clone } from 'object-lib';","import { Merge } from 'object-lib';","import { SafeProxy } from 'object-lib';","import { jsonSmartParse } from 'object-lib';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { align, clone, Merge, SafeProxy, jsonSmartParse } from 'object-lib';\n\n// Align object keys to a reference object\nconst objToAlign = { k1: 1, k3: 3, k2: 2 };\nconst ref = { k2: null, k1: null, k4: 4 };\nconst aligned = align(objToAlign, ref);\nconsole.log('Aligned object:', aligned); \n// Expected: { k2: 2, k1: 1 }\n\n// Deep clone with selective referencing/exclusion using object-scan syntax\nconst originalData = { a: { nested: 1 }, b: { nested: 2 }, c: { nested: 3 } };\nconst clonedData = clone(originalData, ['b', '!c']);\nconsole.log('Cloned data:', clonedData);\nconsole.log('Is `a` deep cloned?', clonedData.a !== originalData.a); \n// Expected: true\nconsole.log('Is `b` referenced?', clonedData.b === originalData.b); \n// Expected: true\n\n// Smartly merge objects based on a unique identifier (e.g., 'id')\nconst merged = Merge({ '**[*]': 'id' })(\n  { items: [{ id: 1, val: 'a' }, { id: 2, val: 'b' }] },\n  { items: [{ id: 2, val: 'c' }, { id: 3, val: 'd' }] }\n);\nconsole.log('Merged items:', merged); \n// Expected: { items: [{ id: 1, val: 'a' }, { id: 2, val: 'c' }, { id: 3, val: 'd' }] }\n\n// Create a SafeProxy for strict property access, throwing errors for non-existent keys\nconst config = SafeProxy({ db: { host: 'localhost' } });\ntry {\n  console.log('DB Host:', config.db.host);\n  // Attempting to access a non-existent property will throw\n  // console.log('Non-existent property:', config.db.port);\n} catch (e) {\n  console.error('Caught error from SafeProxy:', e.message);\n}\n\n// Parse potentially invalid JSON strings (e.g., from LLMs)\nconst brokenJson = \"{ name: 'Alice', age: 30, city: 'New York' }\"; // Missing quotes on keys\nconst parsed = jsonSmartParse(brokenJson);\nconsole.log('Smart parsed JSON:', parsed); \n// Expected: { name: 'Alice', age: 30, city: 'New York' }","lang":"javascript","description":"This quickstart demonstrates key features including object alignment, deep cloning with selective referencing, smart merging based on identifiers, using `SafeProxy` for strict property access, and parsing malformed JSON with `jsonSmartParse`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}