{"library":"lodash._topath","title":"Lodash toPath Internal Utility","description":"This package, `lodash._topath`, provides the internal `toPath` utility function from Lodash, specifically from its v3 branch. It is designed to convert various input values into a normalized array of path segments, which is crucial for higher-order Lodash functions like `_.get`, `_.set`, or `_.has` that operate on deeply nested object properties using string paths. While historically published as a standalone module for granular consumption, its direct use is generally discouraged in modern applications in favor of accessing equivalent path resolution functionality directly from the main `lodash` package or `lodash-es` (v4+), where `toPath` serves as an internal helper. The current stable version provided by this specific package is `3.8.1`. The parent Lodash project, from which this utility originates, follows semantic versioning and has an active, though somewhat infrequent for major versions, release cadence. Key differentiators of `toPath` include its robust handling of complex path syntax, such as dot notation, bracket notation for array indices or properties with special characters, and direct array inputs, providing a consistent and reliable way to abstract property access.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install lodash._topath"],"cli":null},"imports":["const toPath = require('lodash._topath');","import { get } from 'lodash';","type Path = string | Array<string | number | symbol>;"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const toPath = require('lodash._topath');\n\n// Example 1: Basic string path\nconst path1 = 'user.address.street';\nconsole.log(`Path \"${path1}\" parsed:`, toPath(path1));\n// Expected: [ 'user', 'address', 'street' ]\n\n// Example 2: Path with array index\nconst path2 = 'data.items[0].name';\nconsole.log(`Path \"${path2}\" parsed:`, toPath(path2));\n// Expected: [ 'data', 'items', '0', 'name' ]\n\n// Example 3: Path with mixed notation and special characters\nconst path3 = 'config[\"api-keys\"][1].secret';\nconsole.log(`Path \"${path3}\" parsed:`, toPath(path3));\n// Expected: [ 'config', 'api-keys', '1', 'secret' ]\n\n// Example 4: Already an array (should return itself)\nconst path4 = ['config', 'version'];\nconsole.log(`Path ${JSON.stringify(path4)} parsed:`, toPath(path4));\n// Expected: [ 'config', 'version' ]\n\n// Example 5: Non-string, non-array input (should convert to string then path)\nconst path5 = Symbol('id');\nconsole.log(`Path ${String(path5)} parsed:`, toPath(path5));\n// Expected: [ 'Symbol(id)' ]","lang":"javascript","description":"Demonstrates how to use `lodash._topath` to parse various string and array representations of object paths into an array of segments, showcasing its handling of dot and bracket notation for robust property access.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}