{"_id":"@cjser/dot-prop__v9_0_0","name":"@cjser/dot-prop__v9_0_0","dist-tags":{"latest":"9.0.0-cjser.2"},"versions":{"9.0.0-cjser.2":{"name":"@cjser/dot-prop__v9_0_0","version":"9.0.0-cjser.2","description":"Get, set, or delete a property from a nested object using a dot path","license":"MIT","repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","require":"./dist-cjser/index.cjs","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsc","bench":"node benchmark.js"},"keywords":["object","prop","property","dot","path","get","set","delete","access","notation","dotty"],"dependencies":{"type-fest":"^4.18.2"},"devDependencies":{"ava":"^6.1.3","benchmark":"^2.1.4","expect-type":"^0.19.0","typescript":"^5.4.5","xo":"^0.58.0"},"types":"./index.d.ts","main":"./dist-cjser/index.cjs","cjser":{"sourceVersion":"9.0.0","cjserVersion":2,"original":{"name":"dot-prop","version":"9.0.0","exports":{"types":"./index.d.ts","default":"./index.js"},"repository":"sindresorhus/dot-prop","dependencies":{"type-fest":"^4.18.2"},"files":["index.js","index.d.ts"],"scripts":{"test":"xo && ava && tsc","bench":"node benchmark.js"}}},"_id":"@cjser/dot-prop__v9_0_0@9.0.0-cjser.2","gitHead":"a4bef54d7d22d3d9a6b84528457938d84cd65fe7","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-YcgqGLTON6cbNzfRHgJWVCWW0A1Sk0Sl3C5kYEJOQHEa6/6fa+CGt6h2rWVBJLsKfvbgjrK4JawofQ2tA6KJUA==","shasum":"9538316d2a59c795c881dde9d384939f9fa78c43","tarball":"https://registry.npmjs.org/@cjser/dot-prop__v9_0_0/-/dot-prop__v9_0_0-9.0.0-cjser.2.tgz","fileCount":6,"unpackedSize":26278,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICZHl4lf5KGeH/2YNU1yrDLP5G24Cb22beawzIBjv6ECAiA8moMHMzfdJ6M+dk9+UoRx3Kz4UqeVVm4dprBQD7X0XQ=="}]},"_npmUser":{"name":"nanahira","email":"nanahira@momobako.com"},"directories":{},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dot-prop__v9_0_0_9.0.0-cjser.2_1778157886880_0.510492478590852"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T12:44:46.782Z","9.0.0-cjser.2":"2026-05-07T12:44:47.049Z","modified":"2026-05-07T12:44:47.358Z"},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"description":"Get, set, or delete a property from a nested object using a dot path","keywords":["object","prop","property","dot","path","get","set","delete","access","notation","dotty"],"repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","readme":"# dot-prop\n\n> Get, set, or delete a property from a nested object using a dot path\n\n## Install\n\n```sh\nnpm install dot-prop\n```\n\n## Usage\n\n```js\nimport {getProperty, setProperty, hasProperty, deleteProperty} from 'dot-prop';\n\n// Getter\ngetProperty({foo: {bar: 'unicorn'}}, 'foo.bar');\n//=> 'unicorn'\n\ngetProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep');\n//=> undefined\n\ngetProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value');\n//=> 'default value'\n\ngetProperty({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\\\.dot');\n//=> 'unicorn'\n\ngetProperty({foo: [{bar: 'unicorn'}]}, 'foo[0].bar');\n//=> 'unicorn'\n\n// Setter\nconst object = {foo: {bar: 'a'}};\nsetProperty(object, 'foo.bar', 'b');\nconsole.log(object);\n//=> {foo: {bar: 'b'}}\n\nconst foo = setProperty({}, 'foo.bar', 'c');\nconsole.log(foo);\n//=> {foo: {bar: 'c'}}\n\nsetProperty(object, 'foo.baz', 'x');\nconsole.log(object);\n//=> {foo: {bar: 'b', baz: 'x'}}\n\nsetProperty(object, 'foo.biz[0]', 'a');\nconsole.log(object);\n//=> {foo: {bar: 'b', baz: 'x', biz: ['a']}}\n\n// Has\nhasProperty({foo: {bar: 'unicorn'}}, 'foo.bar');\n//=> true\n\n// Deleter\nconst object = {foo: {bar: 'a'}};\ndeleteProperty(object, 'foo.bar');\nconsole.log(object);\n//=> {foo: {}}\n\nobject.foo.bar = {x: 'y', y: 'x'};\ndeleteProperty(object, 'foo.bar.x');\nconsole.log(object);\n//=> {foo: {bar: {y: 'x'}}}\n```\n\n## API\n\n### getProperty(object, path, defaultValue?)\n\nGet the value of the property at the given path.\n\nReturns the value if any.\n\n### setProperty(object, path, value)\n\nSet the property at the given path to the given value.\n\nReturns the object.\n\n### hasProperty(object, path)\n\nCheck whether the property at the given path exists.\n\nReturns a boolean.\n\n### deleteProperty(object, path)\n\nDelete the property at the given path.\n\nReturns a boolean of whether the property existed before being deleted.\n\n### escapePath(path)\n\nEscape special characters in a path. Useful for sanitizing user input.\n\n```js\nimport {getProperty, escapePath} from 'dot-prop';\n\nconst object = {\n\tfoo: {\n\t\tbar: '👸🏻 You found me Mario!',\n\t},\n\t'foo.bar' : '🍄 The princess is in another castle!',\n};\nconst escapedPath = escapePath('foo.bar');\n\nconsole.log(getProperty(object, escapedPath));\n//=> '🍄 The princess is in another castle!'\n```\n\n### deepKeys(object)\n\nReturns an array of every path. Non-empty plain objects and arrays are deeply recursed and are not themselves included.\n\nThis can be useful to help flatten an object for an API that only accepts key-value pairs or for a tagged template literal.\n\n```js\nimport {getProperty, deepKeys} from 'dot-prop';\n\nconst user = {\n\tname: {\n\t\tfirst: 'Richie',\n\t\tlast: 'Bendall',\n\t},\n\tactiveTasks: [],\n\tcurrentProject: null\n};\n\nfor (const property of deepKeys(user)) {\n\tconsole.log(`${property}: ${getProperty(user, property)}`);\n\t//=> name.first: Richie\n\t//=> name.last: Bendall\n\t//=> activeTasks: []\n\t//=> currentProject: null\n}\n```\n\nSparse arrays are supported. In general, [avoid using sparse arrays](https://github.com/sindresorhus/dot-prop/issues/109#issuecomment-1614819869).\n\n#### object\n\nType: `object | array`\n\nObject or array to get, set, or delete the `path` value.\n\nYou are allowed to pass in `undefined` as the object to the `get` and `has` functions.\n\n#### path\n\nType: `string`\n\nPath of the property in the object, using `.` to separate each nested key.\n\nUse `\\\\.` if you have a `.` in the key.\n\nThe following path components are invalid and results in `undefined` being returned: `__proto__`, `prototype`, `constructor`.\n\n#### value\n\nType: `unknown`\n\nValue to set at `path`.\n\n#### defaultValue\n\nType: `unknown`\n\nDefault value.\n\n## cjser\n\nThis package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.\nOriginal repository: https://github.com/sindresorhus/dot-prop\n","readmeFilename":"readme.md","_rev":"1-13338a644de4d984741cb19f37348e2a"}