{"id":16554319,"url":"https://github.com/jusx/object-dot","last_synced_at":"2025-06-12T12:08:40.020Z","repository":{"id":54853910,"uuid":"172863579","full_name":"jusx/object-dot","owner":"jusx","description":"Easily use dot notation to safely get, or set a property of a nested object. A Node module.","archived":false,"fork":false,"pushed_at":"2021-01-25T08:21:33.000Z","size":284,"stargazers_count":1,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-28T18:46:48.677Z","etag":null,"topics":["dot-notation","node-module","node-object","node-utility","object"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jusx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-27T07:13:56.000Z","updated_at":"2020-10-21T03:41:07.000Z","dependencies_parsed_at":"2022-08-14T04:50:31.037Z","dependency_job_id":null,"html_url":"https://github.com/jusx/object-dot","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/jusx/object-dot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jusx%2Fobject-dot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jusx%2Fobject-dot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jusx%2Fobject-dot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jusx%2Fobject-dot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jusx","download_url":"https://codeload.github.com/jusx/object-dot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jusx%2Fobject-dot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259462558,"owners_count":22861512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dot-notation","node-module","node-object","node-utility","object"],"created_at":"2024-10-11T19:51:12.513Z","updated_at":"2025-06-12T12:08:39.997Z","avatar_url":"https://github.com/jusx.png","language":"JavaScript","readme":"# 📦 object-dot\n\n[![CircleCI](https://circleci.com/gh/jusx/object-dot.svg?style=svg)](https://circleci.com/gh/jusx/object-dot) [![codecov](https://codecov.io/gh/jusx/object-dot/branch/master/graph/badge.svg)](https://codecov.io/gh/jusx/object-dot) [![npm](https://img.shields.io/npm/v/object-dot.svg?style=flat-square)](https://www.npmjs.com/package/object-dot)\n\nEasily use dot notation to `get`, or `set` a property of a nested object. A node module.\n\n\u003e 💥 100% code coverage, zero dependencies and flexible APIs.\n\n# Usage\n\n## `set`\n\nCreate the nested chain of objects with `set` and dot notation with one simple statement.\n\n```js\nconst objectd = require('object-dot')\n\nconsole.log(\n  objectd.set({ object: {}, path: 'a.b.c', value: 'foo' })\n)\n// =\u003e { a: { b: { c: 'foo' } } }\n\n// Array of the property chain will work too!\nconsole.log(\n  objectd.set({ object: {}, path: ['a', 'b', 'c'], value: 'foo' })\n)\n\n// Alternatively you may use arguments as parameters instead of an object.\nconsole.log(\n  objectd.set({}, 'a.b.c', 'foo')\n)\n```\n\nBy default any property with values that exists in the path of the chained property is overwritten. The API can be instructed to not overwrite but instead do nothing when this scenario is found. Consider the following:\n\n```js\nrequire('object-dot').extend()\nlet obj = { a: { b: { c: 'foo' } } }\n\n// By default, the value for `c` is overwritten\nconsole.log(\n  Object.set(obj, 'a.b.c.d', 'foo')\n)\n//=\u003e { a: { b: { c: { d: 'foo' } } } }\n\n// Tell the API not to overwrite\nconsole.log(\n  Object.set(obj, 'a.b.c.d', 'foo', false)\n)\n//=\u003e { a: { b: { c: 'foo' } } }\n\n// Alternatively, you may call it with an object as a parameter\nObject.set({ object: obj, path: 'a.b.c.d', value: 'foo', overwrite: false })\n```\n\n## `get`\n\nGet the value of a nested chain of objects without checking each object in the chain for its existence.\n\n```js\nconst objectd = require('object-dot')\n\n// when one of the properties in the chain is undefined. Safely return undefined.\nlet object = { foo: { bar: 'you!' }}\nconsole.log(\n  objectd.get({ object, path: 'foo.bar.c.d'})\n)\n//=\u003e undefined\n\n// return a default value if property is undefined\nobject = { foo: { bar: 'you!' }}\nconsole.log(\n  objectd.get({ object, path: 'foo.bar.c.d', value: 'my default value'})\n)\n//=\u003e 'my default value'\n\n// When the property exist.\nobject = { a: { foo: { bar: 'you!' } }}\nconsole.log(\n  objectd.get({ object, path: 'a.foo'})\n)\n//=\u003e { bar: 'you!' }\n\n// Plain arguments as parameters will work too!\nconsole.log(\n  objectd.get(object, 'a.foo.bar')\n)\n// =\u003e 'you!'\n\n// Using arrays instead of dot notation is also supported.\nconsole.log(\n  objectd.get(object, ['a', 'foo', 'bar'])\n)\n// =\u003e 'you!'\n\n```\n\n## `exists`\n\nThe `exists` method determines if a chained object exist.\n\n```js\nconst objectd = require('object-dot')\n\n// when one of the properties in the chain is undefined. Safely return undefined.\nlet object = { foo: { bar: 'you!' }}\nconsole.log(\n  objectd.exists({ object, path: 'foo.bar'})\n)\n//=\u003e true\n\n// alternatively using plain old arguments work too.\nconsole.log(\n  objectd.exists(object, 'foo.bar')\n)\n\n```\n\n## `extend`\n\nUse the `extend` method to add the methods, `get`, `set` and `exists` to the Object prototype chain:\n\n```js\nrequire('object-dot').extend()\n\nlet object = { foo: { bar: 'you!' }}\nconsole.log(\n  Object.exists(object, 'foo.bar')\n)\n//=\u003e true\n```\n# Install\n\n```bash\n$ npm install object-dot --save\n```\n\n# License\n\nISC\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjusx%2Fobject-dot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjusx%2Fobject-dot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjusx%2Fobject-dot/lists"}