{"id":17857210,"url":"https://github.com/kouts/vue-set-path","last_synced_at":"2025-03-20T14:31:05.803Z","repository":{"id":40453576,"uuid":"365689913","full_name":"kouts/vue-set-path","owner":"kouts","description":"A set of utility methods to update Vue reactive objects, using the dot notation path syntax.","archived":false,"fork":false,"pushed_at":"2022-11-07T08:44:02.000Z","size":799,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T17:11:26.447Z","etag":null,"topics":["dot","keypath","notation","reactive","set","vue"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kouts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-09T07:08:00.000Z","updated_at":"2022-06-01T07:59:23.000Z","dependencies_parsed_at":"2022-08-31T12:22:50.208Z","dependency_job_id":null,"html_url":"https://github.com/kouts/vue-set-path","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kouts%2Fvue-set-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kouts%2Fvue-set-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kouts%2Fvue-set-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kouts%2Fvue-set-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kouts","download_url":"https://codeload.github.com/kouts/vue-set-path/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244630094,"owners_count":20484311,"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","keypath","notation","reactive","set","vue"],"created_at":"2024-10-28T03:11:52.784Z","updated_at":"2025-03-20T14:31:05.132Z","avatar_url":"https://github.com/kouts.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue-set-path \u003ca href=\"https://npm.im/vue-set-path\"\u003e\u003cimg src=\"https://badgen.net/npm/v/vue-set-path\"\u003e\u003c/a\u003e ![](https://img.badgesize.io/kouts/vue-set-path/main/dist/umd/vueSetPath.min.js.svg) ![](https://img.badgesize.io/kouts/vue-set-path/main/dist/umd/vueSetPath.min.js.svg?compression=gzip) ![](coverage/badge.svg)\n\n\u003e A set of utility methods to update Vue reactive objects, using the dot notation path syntax.\n\n`vue-set-path` methods can be used to `set` and `delete`\n\n- properties of the `data` object in a Vue instance\n- Vuex `state` properties\n- `Vue.observable` properties\n\nAll the methods use their `Vue` equivalents ([Vue.set](https://vuejs.org/v2/api/#Vue-set) and\n[Vue.delete](https://vuejs.org/v2/api/#Vue-delete)) under the hood, in order to retain reactivity.\n\n## Install\n\n```sh\nnpm install vue-set-path\n```\n\n## Example\n\n```js\nimport Vue from 'vue'\nimport { setOne, setMany, deleteOne, deleteMany } from 'vue-set-path'\n\nconst obj = Vue.observable({})\n\nsetOne(obj, 'foo.bar.baz', 'New value')\n// This will set obj.foo.bar.baz to 'New value'\n// If intermediate objects don't exist they will get automatically created\n\nsetMany(obj, {\n  'foo.bar.baz', 'New value',\n  'qux': 'Another value'\n})\n// The same as setOne, but uses a map of path/values to set multiple properties\n\ndeleteOne(obj, 'foo.bar.baz')\n// Deletes the foo.bar.baz property\n\ndeleteMany(obj, ['foo.bar.baz', 'qux'])\n// The same as deleteOne, but uses an array of paths to delete many properties at once\n\n```\n\n## API\n\n### setOne\n\nSets a reactive value on an object property or an array element.  \nNon-existent paths will be be initialized automatically.\n\n#### Syntax\n\n- `setOne(object, path, value)`\n\n#### Parameters\n\n- `object (Object | Array)`: The data object/array that we're changing.\n- `path (string)`: The path of the data we're changing, e.g.\n  - user\n  - user.name\n  - user.friends[1] or user.friends.1\n- `value (any)`: The value we're changing it to. Can be a primitive or an object (or array).\n\n### setMany\n\nSets one or many a reactive properties by using either `path, value` or a map of `path: value` pairs.\n\n#### Syntax\n\n- `setMany(object, path, value)`\n- `setMany(object, map)`\n\n#### Parameters\n\n- `object (Object | Array)`: The data object/array that we're changing.\n- `path (string)`: The path of the data we're changing, e.g.\n  - user\n  - user.name\n  - user.friends[1] or user.friends.1\n- `value (any)`: The value we're changing it to. Can be a primitive or an object (or array).\n- `map (Object)`: A map of `path: value` pairs.\n\n### deleteOne\n\nDeletes a property of an object or the element of an array.\n\n#### Syntax\n\n- `deleteOne(object, path)`\n\n#### Parameters\n\n- `object (Object | Array)`: The data object/array that we're deleting a property from.\n- `path (string)`: The path of the property that we're deleting, e.g.\n  - user\n  - user.name\n  - user.friends[1] or user.friends.1\n\n### deleteMany\n\nDeletes one or many properties and/or array elements by using an array of paths.\n\n#### Syntax\n\n- `deleteMany(object, path)`\n- `deleteMany(object, array)`\n\n#### Parameters\n\n- `object (Object | Array)`: The data object/array that we're deleting properties from.\n- `path (string)`: The path of the property that we're deleting, e.g.\n  - user\n  - user.name\n  - user.friends[1] or user.friends.1\n- `array (Array)`: An array of paths to delete.\n\n## Browsers support\n\n| [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png\" alt=\"IE / Edge\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003cbr/\u003eIE / Edge | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png\" alt=\"Firefox\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003cbr/\u003eFirefox | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png\" alt=\"Chrome\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003cbr/\u003eChrome | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png\" alt=\"Safari\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003cbr/\u003eSafari | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png\" alt=\"Opera\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003cbr/\u003eOpera |\n| --------- | --------- | --------- | --------- | --------- |\n| IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkouts%2Fvue-set-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkouts%2Fvue-set-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkouts%2Fvue-set-path/lists"}