Socket
Socket
Sign inDemoInstall

vue-preferences

Package Overview
Dependencies
0
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 2.0.0

2

dist/index.js

@@ -1,2 +0,2 @@

var e="vp";function r(r,t){void 0===t&&(t={});var n=function(r,t){return void 0===t&&(t=e),t+":"+r}(r);return{get:function(){var e=function(e,r,n){var o=t;return"object"==typeof r&&(o=Object.assign({},r[e],t)),o}(r,this.$preferences);return function(e,r){var t=window.localStorage.getItem(e);if(null===t)return r.defaultValue;try{return JSON.parse(t)}catch(e){return""===t?t:t||r.defaultValue}}(n,e)},set:function(e){return function(e,r){return window.localStorage.setItem(e,JSON.stringify(r)),r}(n,e)}}}exports.DEFAULT_STORAGE_PREFIX=e,exports.preference=r,exports.mapPreferences=function(e){var t,n={};return(t=e,Array.isArray(t)?t.map(function(e){return{name:e,options:{}}}):Object.keys(t).map(function(e){return{name:e,options:t[e]}})).forEach(function(e){var t=e.name;n[t]=r(t,e.options)}),n},exports.default={install:function(e){e.prototype.$preferences={}}};
var t="vp",e=t+":tracked",r={reactive:!0};function n(t,e,r){var n=r;return"object"==typeof e&&(n=Object.assign({},e[t],r)),n}function i(t,r,i,a){return function(){var o=this||{},u=n(t,o.$preferences,i),c=function(t,e){var r=window.localStorage.getItem(t);if(null===r)return e.defaultValue;try{return JSON.parse(r)}catch(t){return""===r?r:r||e.defaultValue}}(r,u),f=function(t,r){var n=t[e];return n?n[r]:void 0}(o,r);return i.reactive&&a.isReactivitySetup?f:c}}function a(t,r,i,a){return function(o){var u=this||{},c=n(t,u.$preferences,i);!function(t,e){window.localStorage.setItem(t,JSON.stringify(e))}(r,o),c.reactive&&(function(t,r,n){t.$set(t[e],r,n)}(u,r,o),a.isReactivitySetup=!0)}}function o(e,n){void 0===n&&(n={});var o=Object.assign({},r,n),u=function(e,r){return void 0===r&&(r=t),r+":"+e}(e),c={isReactivitySetup:!1};return{get:i(e,u,o,c),set:a(e,u,o,c)}}exports.DEFAULT_STORAGE_PREFIX=t,exports.DEFAULT_REACTIVE_PROPERTIES_PREFIX=e,exports.preference=o,exports.mapPreferences=function(t){var e,r={};return(e=t,Array.isArray(e)?e.map(function(t){return{name:t,options:{}}}):Object.keys(e).map(function(t){return{name:t,options:e[t]}})).forEach(function(t){var e=t.name;r[e]=o(e,t.options)}),r},exports.default={install:function(t){t.prototype.$preferences={},t.mixin({data:function(){return{"vp:tracked":{}}}})}};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.vuePreferences={})}(this,function(e){var n="vp";function t(e,t){void 0===t&&(t={});var r=function(e,t){return void 0===t&&(t=n),t+":"+e}(e);return{get:function(){var n=function(e,n,r){var o=t;return"object"==typeof n&&(o=Object.assign({},n[e],t)),o}(e,this.$preferences);return function(e,n){var t=window.localStorage.getItem(e);if(null===t)return n.defaultValue;try{return JSON.parse(t)}catch(e){return""===t?t:t||n.defaultValue}}(r,n)},set:function(e){return function(e,n){return window.localStorage.setItem(e,JSON.stringify(n)),n}(r,e)}}}e.DEFAULT_STORAGE_PREFIX=n,e.preference=t,e.mapPreferences=function(e){var n,r={};return(n=e,Array.isArray(n)?n.map(function(e){return{name:e,options:{}}}):Object.keys(n).map(function(e){return{name:e,options:n[e]}})).forEach(function(e){var n=e.name;r[n]=t(n,e.options)}),r},e.default={install:function(e){e.prototype.$preferences={}}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.vuePreferences={})}(this,function(e){var t="vp",n=t+":tracked",r={reactive:!0};function i(e,t,n){var r=n;return"object"==typeof t&&(r=Object.assign({},t[e],n)),r}function o(e,t,r,o){return function(){var u=this||{},c=i(e,u.$preferences,r),a=function(e,t){var n=window.localStorage.getItem(e);if(null===n)return t.defaultValue;try{return JSON.parse(n)}catch(e){return""===n?n:n||t.defaultValue}}(t,c),f=function(e,t){var r=e[n];return r?r[t]:void 0}(u,t);return r.reactive&&o.isReactivitySetup?f:a}}function u(e,t,r,o){return function(u){var c=this||{},a=i(e,c.$preferences,r);!function(e,t){window.localStorage.setItem(e,JSON.stringify(t))}(t,u),a.reactive&&(function(e,t,r){e.$set(e[n],t,r)}(c,t,u),o.isReactivitySetup=!0)}}function c(e,n){void 0===n&&(n={});var i=Object.assign({},r,n),c=function(e,n){return void 0===n&&(n=t),n+":"+e}(e),a={isReactivitySetup:!1};return{get:o(e,c,i,a),set:u(e,c,i,a)}}e.DEFAULT_STORAGE_PREFIX=t,e.DEFAULT_REACTIVE_PROPERTIES_PREFIX=n,e.preference=c,e.mapPreferences=function(e){var t,n={};return(t=e,Array.isArray(t)?t.map(function(e){return{name:e,options:{}}}):Object.keys(t).map(function(e){return{name:e,options:t[e]}})).forEach(function(e){var t=e.name;n[t]=c(t,e.options)}),n},e.default={install:function(e){e.prototype.$preferences={},e.mixin({data:function(){return{"vp:tracked":{}}}})}}});
//# sourceMappingURL=index.umd.js.map
{
"name": "vue-preferences",
"version": "1.1.2",
"version": "2.0.0",
"description": "The coolest and easiest way to manage your user's preferences through localStorage and no back-end calls at all.",

@@ -30,11 +30,14 @@ "main": "dist/index.js",

"@babel/preset-env": "^7.4.3",
"@vue/test-utils": "^1.0.0-beta.29",
"babel-jest": "^24.7.1",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint": "^5.16.0",
"jest": "^24.7.1",
"microbundle": "^0.11.0",
"prettier": "1.17.0"
"prettier": "1.17.0",
"vue": "^2.6.10",
"vue-template-compiler": "^2.6.10"
}
}

@@ -15,6 +15,6 @@ # Vue Preferences

<a href="https://codeclimate.com/github/streaver/vue-preferences/maintainability">
<img src="https://api.codeclimate.com/v1/badges/3e69b841f5089cb9b11c/maintainability" />
<img src="https://api.codeclimate.com/v1/badges/e6725f51619a0c309f80/maintainability" />
</a>
<a href="https://codeclimate.com/github/streaver/vue-preferences/test_coverage">
<img src="https://api.codeclimate.com/v1/badges/3e69b841f5089cb9b11c/test_coverage" />
<img src="https://api.codeclimate.com/v1/badges/e6725f51619a0c309f80/test_coverage" />
</a>

@@ -58,2 +58,16 @@ <a href="https://github.com/streaver/vue-preferences/blob/master/LICENSE">

But first, remember to install the plugin before using it with:
```javascript
import VuePreferences from 'vue-preferences';
Vue.use(VuePreferences);
new Vue({
render: h => h(App),
}).$mount('#app');
```
This only needs to be done once, in the `main.js` or `index.js` file of your app, where you mount the Vue app for the first time.
### Declaring vue-preferences

@@ -68,8 +82,10 @@

```js
import { preference } from 'vue-preferences'
computed: {
isDarkMode: preference('isDarkModeEnabled', { defaultValue: false })
isDarkMode: preference('isDarkModeEnabled', { defaultValue: false, reactive: false })
}
```
or without `defaultValue`, no need to pass an `options` object in this case
keep in mind that there is no need to pass an `options` object if you don't need it

@@ -93,2 +109,4 @@ ```js

```js
import { mapPreferences } from 'vue-preferences'
computed: {

@@ -183,2 +201,13 @@ ...mapPreferences(["translatedTo", "isZoomed"])

### Options
🚀 In the near future, we will be supporting other custom options that will add even more power to the preferences you set. Stay tuned and support!
For now, this is the list of available options:
| Option | Default Value | Description |
| ------------- | ------------- | ------------- |
| `defaultValue` | `undefined` | Allows you to set up the preference with a custom default value. This allows you to ensures that even the first time the preference is read you will get something. |
| `reactive` | `true` | By default preferences are reactive. This means that if you use the property in your template/code you can expect it to be observed and trigger re-renders, just like normal computed properties while at the same time the values get persisted to `localStorage`. If you disable this behavior the property will not trigger re-renders/re-computation of dependant code |
### Notes

@@ -188,4 +217,2 @@

🚀 In the near future, we will be supporting other custom options that will add even more power to the preferences you set. Stay tuned and support!
## Contributing

@@ -192,0 +219,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc