{"id":13536147,"url":"https://github.com/RobinCK/vue-ls","last_synced_at":"2025-04-02T02:32:29.145Z","repository":{"id":37692868,"uuid":"81789440","full_name":"RobinCK/vue-ls","owner":"RobinCK","description":":boom: Vue plugin for work with local storage, session storage and memory storage from Vue context 🇺🇦","archived":false,"fork":false,"pushed_at":"2022-12-08T22:26:19.000Z","size":2911,"stargazers_count":536,"open_issues_count":14,"forks_count":42,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-31T10:37:41.290Z","etag":null,"topics":["docker","docker-compose","es6-modules","json","local-storage","localstorage","sessionstorage","storage","vue","vue-local-storage","vue-ls","vue-plugin","vuejs"],"latest_commit_sha":null,"homepage":"https://robinck.gitbooks.io/vue-storage/","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/RobinCK.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"open_collective":"vue-ls"}},"created_at":"2017-02-13T05:46:58.000Z","updated_at":"2024-09-16T10:54:28.000Z","dependencies_parsed_at":"2022-08-30T22:30:26.385Z","dependency_job_id":null,"html_url":"https://github.com/RobinCK/vue-ls","commit_stats":null,"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinCK%2Fvue-ls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinCK%2Fvue-ls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinCK%2Fvue-ls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinCK%2Fvue-ls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobinCK","download_url":"https://codeload.github.com/RobinCK/vue-ls/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222494666,"owners_count":16993284,"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":["docker","docker-compose","es6-modules","json","local-storage","localstorage","sessionstorage","storage","vue","vue-local-storage","vue-ls","vue-plugin","vuejs"],"created_at":"2024-08-01T09:00:35.239Z","updated_at":"2024-11-03T01:30:29.119Z","avatar_url":"https://github.com/RobinCK.png","language":"JavaScript","funding_links":["https://opencollective.com/vue-ls","https://opencollective.com/vue-ls/contribute","https://opencollective.com/vue-ls/organization/0/website","https://opencollective.com/vue-ls/organization/1/website","https://opencollective.com/vue-ls/organization/2/website","https://opencollective.com/vue-ls/organization/3/website","https://opencollective.com/vue-ls/organization/4/website","https://opencollective.com/vue-ls/organization/5/website","https://opencollective.com/vue-ls/organization/6/website","https://opencollective.com/vue-ls/organization/7/website","https://opencollective.com/vue-ls/organization/8/website","https://opencollective.com/vue-ls/organization/9/website"],"categories":["JavaScript","实用库","Awesome Vue.js [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)","公用事业","Components \u0026 Libraries","Utilities","Utilities [🔝](#readme)"],"sub_categories":["Libraries \u0026 Plugins","坚持","Utilities","Persistence"],"readme":"\u003cp align=\"center\"\u003e\n\n  \u003cimg width=\"130\" alt=\"vue-ls logo\" src=\"https://cdn.rawgit.com/RobinCK/0ef39abfff9a44061cee5b2c072e892e/raw/e2b95a57825ac9b8e845609ff9fc5fdaae37b55a/logo.svg\"\u003e\n  \n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://opencollective.com/vue-ls\" alt=\"Financial Contributors on Open Collective\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/all/badge.svg?label=financial+contributors\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/RobinCK/vue-ls\"\u003e\u003cimg src=\"https://img.shields.io/badge/vuejs-1.x-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/RobinCK/vue-ls\"\u003e\u003cimg src=\"https://img.shields.io/badge/vuejs-2.x-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/RobinCK/vue-ls\"\u003e\u003cimg src=\"https://img.shields.io/badge/vuejs-3.x-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://coveralls.io/github/RobinCK/vue-ls?branch=master\"\u003e\u003cimg src=\"https://img.shields.io/coveralls/RobinCK/vue-ls.svg?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"http://inch-ci.org/github/RobinCK/vue-ls\"\u003e\u003cimg src=\"https://inch-ci.org/github/RobinCK/vue-ls.svg?branch=master\u0026style=flat-squar\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://houndci.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg\"\u003e\u003c/a\u003e\n  \n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vue-ls\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/vue-ls.svg?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vue-ls\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/vue-ls.svg?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://cdnjs.com/libraries/vue-ls\"\u003e\u003cimg src=\"https://img.shields.io/cdnjs/v/vue-ls.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/RobinCK/vue-ls/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/vue-ls.svg?style=flat-square\"\u003e\u003c/a\u003e\n \n\u003c/p\u003e\n\n\n# vue-ls\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/RobinCK/vue-ls.svg)](https://greenkeeper.io/)\n\nVue plugin for work with local storage, session storage and memory storage from Vue context\n\n[![NPM](https://nodei.co/npm/vue-ls.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/vue-ls/)\n\n## jsFiddle Example\n\n[Vue 1.x](https://jsfiddle.net/Robin_ck/Lvb2ah5p/)\n\n[Vue 2.x](https://jsfiddle.net/Robin_ck/6x1akv1L/) \n\n## Install\n#### CDN\n\nRecommended: https://unpkg.com/vue-ls, which will reflect the latest version as soon as it is published to npm. You can also browse the source of the npm package at https://unpkg.com/vue-ls/\n\nAlso available on \u003ca href=\"https://cdn.jsdelivr.net/npm/vue-ls@latest\"\u003ejsDelivr\u003c/a\u003e or \u003ca href=\"https://cdnjs.com/libraries/vue-ls\"\u003ecdnjs\u003ca/\u003e, but these two services take some time to sync so the latest release may not be available yet.\n\n#### NPM\n\n``` bash\nnpm install vue-ls --save\n```\n\n#### Yarn\n\n``` bash\nyarn add vue-ls\n```\n\n#### Bower\n\n``` bash\nbower install vue-ls --save\n```\n\n## Development Setup\n\n``` bash\n# install dependencies\nnpm install\n\n# build dist files\nnpm run build\n```\n\n## Usage\n\nVue storage API.\n\n``` js\nimport Storage from 'vue-ls';\n\nconst options = {\n  namespace: 'vuejs__', // key prefix\n  name: 'ls', // name variable Vue.[ls] or this.[$ls],\n  storage: 'local', // storage name session, local, memory\n};\n\nVue.use(Storage, options);\n\n//or\n//Vue.use(Storage);\n\nnew Vue({\n    el: '#app',\n    mounted: function() {\n        Vue.ls.set('foo', 'boo');\n        //Set expire for item\n        Vue.ls.set('foo', 'boo', 60 * 60 * 1000); //expiry 1 hour\n        Vue.ls.get('foo');\n        Vue.ls.get('boo', 10); //if not set boo returned default 10\n        \n        let callback = (val, oldVal, uri) =\u003e {\n          console.log('localStorage change', val);\n        } \n        \n        Vue.ls.on('foo', callback) //watch change foo key and triggered callback\n        Vue.ls.off('foo', callback) //unwatch\n        \n        Vue.ls.remove('foo');\n    }\n});\n```\nUse in js file\n``` js\n// localStore.js\nimport Storage from 'vue-ls';\nconst options = {\n  namespace: 'vuejs__', // key prefix\n  name: 'ls', // name variable Vue.[ls] or this.[$ls],\n  storage: 'local', // storage name session, local, memory\n};\n\nconst { ls } = Storage.useStorage(options)\n\nexport default ls\n\n// somefile.js\nimport ls from 'localStore.js';\n\nls.set('foo', 'boo');\nls.get('foo');\n```\n\n#### Global\n\n- `Vue.ls`\n \n#### Context\n- `this.$ls`\n\n## API\n\n#### `Vue.ls.get(name, def)`\n\nReturns value under `name` in storage. Internally parses the value from JSON before returning it.\n\n- `def`: default null, returned if not set `name`.\n\n#### `Vue.ls.set(name, value, expire)`\n\nPersists `value` under `name` in storage. Internally converts the `value` to JSON.\n\n- `expire`: default null, life time in milliseconds `name`\n\n#### `Vue.ls.remove(name)`\n\nRemoves `name` from storage. Returns `true` if the property was successfully deleted, and `false` otherwise.\n\n#### `Vue.ls.clear()`\n\nClears storage.\n\n#### `Vue.ls.on(name, callback)`\n\nListen for changes persisted against `name` on other tabs. Triggers `callback` when a change occurs, passing the following arguments.\n\n- `newValue`: the current value for `name` in storage, parsed from the persisted JSON\n- `oldValue`: the old value for `name` in storage, parsed from the persisted JSON\n- `url`: the url for the tab where the modification came from\n\n#### `Vue.ls.off(name, callback)`\n\nRemoves a listener previously attached with `Vue.ls.on(name, callback)`.\n\n## Testing\n\n- `npm run test` - run unit test\n- `npm run test:browserstack` - run browser test\n  - `npm run test:browserstack:chrome`\n  - `npm run test:browserstack:ie`\n  - `npm run test:browserstack:edge`\n  - `npm run test:browserstack:firefox`\n  - `npm run test:browserstack:safari`\n- `npm run test:chrome` - run browser test in chrome\n\nTesting Supported By\u003cbr\u003e\n\u003cimg width=\"200\" src=\"https://cdn.rawgit.com/RobinCK/b1435c9cae05437ad9e4c2023aec08e4/raw/4b89e95cd89827935e6e3949d28a4f6ea3e48ee4/browser-stack.svg\"\u003e\n\n## Note\nSome browsers don't support the storage event, and most of the browsers that do support it will only call it when the storage is changed by a different window. So, open your page up in two windows. Click the links in one window and you will probably see the event in the other.\n\nThe assumption is that your page will already know all interactions with localStorage in its own window and only needs notification when a different window changes things. This, of course, is a foolish assumption. But.\n\n## Other my Vue JS plugins\n\n| Project | Status | Description |\n|---------|--------|-------------|\n| [vue-gallery](https://github.com/RobinCK/vue-gallery)    | ![npm](https://img.shields.io/npm/v/vue-gallery.svg)  | VueJS responsive and customizable image and video gallery |\n| [vue-popper](https://github.com/RobinCK/vue-popper)      | ![npm](https://img.shields.io/npm/v/vue-popperjs.svg) | VueJS popover component based on \u003ca href=\"https://popper.js.org/\"\u003epopper.js\u003c/a\u003e |\n\n## Contributors\n\n### Code Contributors\n\nThis project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].\n\u003ca href=\"https://github.com/RobinCK/vue-ls/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n### Financial Contributors\n\nBecome a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/vue-ls/contribute)]\n\n#### Individuals\n\n\u003ca href=\"https://opencollective.com/vue-ls\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/individuals.svg?width=890\"\u003e\u003c/a\u003e\n\n#### Organizations\n\nSupport this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/vue-ls/contribute)]\n\n\u003ca href=\"https://opencollective.com/vue-ls/organization/0/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/vue-ls/organization/1/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/vue-ls/organization/2/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/vue-ls/organization/3/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/vue-ls/organization/4/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/vue-ls/organization/5/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/vue-ls/organization/6/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/vue-ls/organization/7/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/vue-ls/organization/8/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/vue-ls/organization/9/website\"\u003e\u003cimg src=\"https://opencollective.com/vue-ls/organization/9/avatar.svg\"\u003e\u003c/a\u003e\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FRobinCK%2Fvue-ls.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FRobinCK%2Fvue-ls?ref=badge_large)\n\nMIT © [Igor Ognichenko](https://github.com/RobinCK)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobinCK%2Fvue-ls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRobinCK%2Fvue-ls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobinCK%2Fvue-ls/lists"}