Socket
Socket
Sign inDemoInstall

vue-deepset

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.3 to 0.5.4

126

index.js

@@ -35,3 +35,3 @@ 'use strict';

*/
function forEach(obj, fn) {
function forEach(obj, fn, throwErrors) {
try {

@@ -71,3 +71,3 @@ if (Array.isArray(obj)) {

} catch (err) {
return;
if (throwErrors) throw err;
}

@@ -217,3 +217,3 @@ }

var connector = path.match(/^\[/) ? '' : '.';
return '' + (base ? base : '') + (base ? connector : '') + path;
return '' + (base || '') + (base ? connector : '') + path;
} catch (error) {

@@ -227,5 +227,5 @@ return '';

* paths need to be constructed
* @param {*} obj
* @param {*} current
* @param {*} paths
* @param {*} obj
* @param {*} current
* @param {*} paths
*/

@@ -280,16 +280,19 @@ function pushPaths(obj, current, paths) {

* deep sets a Vue.js object creating reactive properties if they do not exist
* @param obj
* @param object
* @param path
* @param value
*/
function vueSet(obj, path, value) {
var fields = Array.isArray(path) ? path : toPath(path);
var prop = fields.shift();
function vueSet(object, path, value) {
var parts = toPath(path);
var obj = object;
if (!fields.length) return Vue.set(obj, prop, value);
if (!hasPath(obj, prop) || obj[prop] === null) {
Vue.set(obj, prop, fields.length >= 1 && typeof fields[0] === 'number' ? [] : {});
while (parts.length) {
var key = parts.shift();
if (!parts.length) {
Vue.set(obj, key, value);
} else if (!hasPath(obj, key) || obj[key] === null) {
Vue.set(obj, key, key === 'number' ? [] : {});
}
obj = obj[key];
}
vueSet(obj[prop], fields, value);
}

@@ -365,13 +368,15 @@

if (typeof vuexPath !== 'string' || !vuexPath) throw new Error('[vue-deepset]: invalid vuex path string');
if (!hasPath(this.$store.state, vuexPath)) throw new Error('[vue-deepset]: Cannot find path "' + vuexPath + '" in Vuex store');
options = isHash(options) ? options : {};
// non-proxy
if (options.useProxy === false || (typeof Proxy === 'undefined' ? 'undefined' : _typeof(Proxy)) === undefined) {
return buildVuexModel.call(this, vuexPath, options);
var opts = Object.assign({}, options);
if (typeof vuexPath !== 'string' || !vuexPath) {
throw new Error('[vue-deepset]: invalid vuex path string');
} else if (!hasPath(this.$store.state, vuexPath)) {
throw new Error('[vue-deepset]: Cannot find path "' + vuexPath + '" in Vuex store');
} else if (opts.useProxy === false || typeof Proxy === 'undefined') {
return buildVuexModel.call(this, vuexPath, opts);
}
var obj = get(this.$store.state, vuexPath);
var tgt = { model: buildVuexModel.call(this, vuexPath, options) };
var tgt = {
model: buildVuexModel.call(this, vuexPath, opts)
};

@@ -384,5 +389,5 @@ return new Proxy(obj, {

// add any missing paths to the source object and add the property
if (!hasPath(obj, property) && (typeof property === 'string' || typeof property === 'number')) {
if (opts.dynamicUpdates !== false && !hasPath(obj, property) && (typeof property === 'string' || typeof property === 'number')) {
vuexSet.call(_this2, pathJoin(vuexPath, property), undefined);
tgt.model = buildVuexModel.call(_this2, vuexPath, options);
tgt.model = buildVuexModel.call(_this2, vuexPath, opts);
}

@@ -400,5 +405,5 @@ return tgt.model[property];

if (property === '_isVue') return true;
if (!hasPath(obj, property) && (typeof property === 'string' || typeof property === 'number')) {
if (opts.dynamicUpdates !== false && !hasPath(obj, property) && (typeof property === 'string' || typeof property === 'number')) {
vuexSet.call(_this2, pathJoin(vuexPath, property), undefined);
tgt.model = buildVuexModel.call(_this2, vuexPath, options);
tgt.model = buildVuexModel.call(_this2, vuexPath, opts);
}

@@ -443,39 +448,38 @@ return true;

if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || !obj) throw new Error('[vue-deepset]: invalid object specified for vue model');
options = isHash(options) ? options : {};
var opts = Object.assign({}, options);
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || !obj) {
throw new Error('[vue-deepset]: invalid object specified for vue model');
} else if (opts.useProxy === false || typeof Proxy === 'undefined') {
return buildVueModel.call(this, obj, opts);
}
var tgt = { model: buildVueModel.call(this, obj, opts) };
return new Proxy(obj, {
get: function get$$1(target, property) {
if ((typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'symbol') return target[property];
if (property === 'toJSON') return target.toJSON;
if (property === '_isVue') return false; // _isVue is always false
if (options.useProxy === false || typeof Proxy === 'undefined') {
return buildVueModel.call(this, obj, options);
} else {
var tgt = { model: buildVueModel.call(this, obj, options) };
return new Proxy(obj, {
get: function get$$1(target, property) {
if ((typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'symbol') return target[property];
if (property === 'toJSON') return target.toJSON;
if (property === '_isVue') return false; // _isVue is always false
if (opts.dynamicUpdates !== false && !hasPath(tgt.model, property) && (typeof property === 'string' || typeof property === 'number')) {
vueSet.call(_this4, obj, property, undefined);
tgt.model = buildVueModel.call(_this4, obj, opts);
}
return tgt.model[property];
},
set: function set$$1(target, property, value) {
if (tgt.model[property] === value) return true;
tgt.model[property] = value;
return true;
},
has: function has(target, property) {
if (property === '_isVue') return true;
if ((typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'symbol') return target[property];
if (property === 'toJSON') return target.toJSON;
if (!hasPath(tgt.model, property) && (typeof property === 'string' || typeof property === 'number')) {
vueSet.call(_this4, obj, property, undefined);
tgt.model = buildVueModel.call(_this4, obj, options);
}
return tgt.model[property];
},
set: function set$$1(target, property, value) {
if (tgt.model[property] === value) return true;
tgt.model[property] = value;
return true;
},
has: function has(target, property) {
if (property === '_isVue') return true;
if ((typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'symbol') return target[property];
if (property === 'toJSON') return target.toJSON;
if (!hasPath(tgt.model, property) && (typeof property === 'string' || typeof property === 'number')) {
vueSet.call(_this4, obj, property, undefined);
tgt.model = buildVueModel.call(_this4, obj, options);
}
return true;
if (opts.dynamicUpdates !== false && !hasPath(tgt.model, property) && (typeof property === 'string' || typeof property === 'number')) {
vueSet.call(_this4, obj, property, undefined);
tgt.model = buildVueModel.call(_this4, obj, opts);
}
});
}
return true;
}
});
}

@@ -482,0 +486,0 @@

{
"name": "vue-deepset",
"version": "0.5.3",
"version": "0.5.4",
"description": "Deep set Vue.js objects",
"main": "index.js",
"scripts": {
"lint": "eslint src/",
"build:pre": "cp build/.build.babelrc src/.babelrc",

@@ -63,2 +64,7 @@ "build:post": "rm -f src/.babelrc",

"browserify-global-shim": "^1.0.3",
"eslint": "^4.15.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"rollup": "^0.41.4",

@@ -65,0 +71,0 @@ "rollup-plugin-babel": "^2.7.1",

@@ -10,2 +10,4 @@ # vue-deepset

Also note that models are flat and once built can set vue/vuex directly using `model[path] = value`
### Examples

@@ -124,6 +126,2 @@

##### sanitizePath ( path:String )
Converts a path string into the correct format for accessing deeply nested models
##### vueSet ( obj:Object, path:String, value:* )

@@ -151,2 +149,3 @@

* `useProxy=true` {`Boolean`} - disable use of Proxy when false
* `dynamicUpdates=true` {`Boolean`} - disable dynamic property update check (can improve performance on deeply nested objects)

@@ -159,2 +158,3 @@ ##### vuexModel ( path:String, [options:Object] )

* `useProxy=true` {`Boolean`} - disable use of Proxy when false
* `dynamicUpdates=true` {`Boolean`} - disable dynamic property update check (can improve performance on deeply nested objects)

@@ -167,2 +167,3 @@ ##### deepModel ( obj:Object, [options:Object] )

* `useProxy=true` {`Boolean`} - disable use of Proxy when false
* `dynamicUpdates=true` {`Boolean`} - disable dynamic property update check (can improve performance on deeply nested objects)

@@ -175,2 +176,3 @@ ##### deepModel ( path:String, [options:Object] )

* `useProxy=true` {`Boolean`} - disable use of Proxy when false
* `dynamicUpdates=true` {`Boolean`} - disable dynamic property update check (can improve performance on deeply nested objects)

@@ -177,0 +179,0 @@ ### Non-Plugin usage

@@ -36,3 +36,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.VueDeepSet = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

*/
function forEach(obj, fn) {
function forEach(obj, fn, throwErrors) {
try {

@@ -72,3 +72,3 @@ if (Array.isArray(obj)) {

} catch (err) {
return;
if (throwErrors) throw err;
}

@@ -218,3 +218,3 @@ }

var connector = path.match(/^\[/) ? '' : '.';
return '' + (base ? base : '') + (base ? connector : '') + path;
return '' + (base || '') + (base ? connector : '') + path;
} catch (error) {

@@ -228,5 +228,5 @@ return '';

* paths need to be constructed
* @param {*} obj
* @param {*} current
* @param {*} paths
* @param {*} obj
* @param {*} current
* @param {*} paths
*/

@@ -281,16 +281,19 @@ function pushPaths(obj, current, paths) {

* deep sets a Vue.js object creating reactive properties if they do not exist
* @param obj
* @param object
* @param path
* @param value
*/
function vueSet(obj, path, value) {
var fields = Array.isArray(path) ? path : toPath(path);
var prop = fields.shift();
function vueSet(object, path, value) {
var parts = toPath(path);
var obj = object;
if (!fields.length) return Vue.set(obj, prop, value);
if (!hasPath(obj, prop) || obj[prop] === null) {
Vue.set(obj, prop, fields.length >= 1 && typeof fields[0] === 'number' ? [] : {});
while (parts.length) {
var key = parts.shift();
if (!parts.length) {
Vue.set(obj, key, value);
} else if (!hasPath(obj, key) || obj[key] === null) {
Vue.set(obj, key, key === 'number' ? [] : {});
}
obj = obj[key];
}
vueSet(obj[prop], fields, value);
}

@@ -366,13 +369,15 @@

if (typeof vuexPath !== 'string' || !vuexPath) throw new Error('[vue-deepset]: invalid vuex path string');
if (!hasPath(this.$store.state, vuexPath)) throw new Error('[vue-deepset]: Cannot find path "' + vuexPath + '" in Vuex store');
options = isHash(options) ? options : {};
// non-proxy
if (options.useProxy === false || (typeof Proxy === 'undefined' ? 'undefined' : _typeof(Proxy)) === undefined) {
return buildVuexModel.call(this, vuexPath, options);
var opts = Object.assign({}, options);
if (typeof vuexPath !== 'string' || !vuexPath) {
throw new Error('[vue-deepset]: invalid vuex path string');
} else if (!hasPath(this.$store.state, vuexPath)) {
throw new Error('[vue-deepset]: Cannot find path "' + vuexPath + '" in Vuex store');
} else if (opts.useProxy === false || typeof Proxy === 'undefined') {
return buildVuexModel.call(this, vuexPath, opts);
}
var obj = get(this.$store.state, vuexPath);
var tgt = { model: buildVuexModel.call(this, vuexPath, options) };
var tgt = {
model: buildVuexModel.call(this, vuexPath, opts)
};

@@ -385,5 +390,5 @@ return new Proxy(obj, {

// add any missing paths to the source object and add the property
if (!hasPath(obj, property) && (typeof property === 'string' || typeof property === 'number')) {
if (opts.dynamicUpdates !== false && !hasPath(obj, property) && (typeof property === 'string' || typeof property === 'number')) {
vuexSet.call(_this2, pathJoin(vuexPath, property), undefined);
tgt.model = buildVuexModel.call(_this2, vuexPath, options);
tgt.model = buildVuexModel.call(_this2, vuexPath, opts);
}

@@ -401,5 +406,5 @@ return tgt.model[property];

if (property === '_isVue') return true;
if (!hasPath(obj, property) && (typeof property === 'string' || typeof property === 'number')) {
if (opts.dynamicUpdates !== false && !hasPath(obj, property) && (typeof property === 'string' || typeof property === 'number')) {
vuexSet.call(_this2, pathJoin(vuexPath, property), undefined);
tgt.model = buildVuexModel.call(_this2, vuexPath, options);
tgt.model = buildVuexModel.call(_this2, vuexPath, opts);
}

@@ -444,39 +449,38 @@ return true;

if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || !obj) throw new Error('[vue-deepset]: invalid object specified for vue model');
options = isHash(options) ? options : {};
var opts = Object.assign({}, options);
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || !obj) {
throw new Error('[vue-deepset]: invalid object specified for vue model');
} else if (opts.useProxy === false || typeof Proxy === 'undefined') {
return buildVueModel.call(this, obj, opts);
}
var tgt = { model: buildVueModel.call(this, obj, opts) };
return new Proxy(obj, {
get: function get$$1(target, property) {
if ((typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'symbol') return target[property];
if (property === 'toJSON') return target.toJSON;
if (property === '_isVue') return false; // _isVue is always false
if (options.useProxy === false || typeof Proxy === 'undefined') {
return buildVueModel.call(this, obj, options);
} else {
var tgt = { model: buildVueModel.call(this, obj, options) };
return new Proxy(obj, {
get: function get$$1(target, property) {
if ((typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'symbol') return target[property];
if (property === 'toJSON') return target.toJSON;
if (property === '_isVue') return false; // _isVue is always false
if (opts.dynamicUpdates !== false && !hasPath(tgt.model, property) && (typeof property === 'string' || typeof property === 'number')) {
vueSet.call(_this4, obj, property, undefined);
tgt.model = buildVueModel.call(_this4, obj, opts);
}
return tgt.model[property];
},
set: function set$$1(target, property, value) {
if (tgt.model[property] === value) return true;
tgt.model[property] = value;
return true;
},
has: function has(target, property) {
if (property === '_isVue') return true;
if ((typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'symbol') return target[property];
if (property === 'toJSON') return target.toJSON;
if (!hasPath(tgt.model, property) && (typeof property === 'string' || typeof property === 'number')) {
vueSet.call(_this4, obj, property, undefined);
tgt.model = buildVueModel.call(_this4, obj, options);
}
return tgt.model[property];
},
set: function set$$1(target, property, value) {
if (tgt.model[property] === value) return true;
tgt.model[property] = value;
return true;
},
has: function has(target, property) {
if (property === '_isVue') return true;
if ((typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'symbol') return target[property];
if (property === 'toJSON') return target.toJSON;
if (!hasPath(tgt.model, property) && (typeof property === 'string' || typeof property === 'number')) {
vueSet.call(_this4, obj, property, undefined);
tgt.model = buildVueModel.call(_this4, obj, options);
}
return true;
if (opts.dynamicUpdates !== false && !hasPath(tgt.model, property) && (typeof property === 'string' || typeof property === 'number')) {
vueSet.call(_this4, obj, property, undefined);
tgt.model = buildVueModel.call(_this4, obj, opts);
}
});
}
return true;
}
});
}

@@ -483,0 +487,0 @@

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.VueDeepSet=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _interopDefault$1(ex){return ex&&typeof ex==="object"&&"default"in ex?ex["default"]:ex}var Vue=_interopDefault$1(window.Vue);function toPath(pathString){if(Array.isArray(pathString))return pathString;if(typeof pathString==="number")return[pathString];pathString=String(pathString);var pathRx=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g;var pathArray=[];pathString.replace(pathRx,function(match,number,quote,string){pathArray.push(quote?string:number!==undefined?Number(number):match);return pathArray[pathArray.length-1]});return pathArray}function forEach(obj,fn){try{if(Array.isArray(obj)){var idx=0;var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=obj[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var val=_step.value;if(fn(val,idx)===false)break;idx++}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator.return){_iterator.return()}}finally{if(_didIteratorError){throw _iteratorError}}}}else{for(var key in obj){if(fn(obj[key],key)===false)break}}}catch(err){return}}function get(obj,path,defaultValue){try{var o=obj;var fields=Array.isArray(path)?path:toPath(path);while(fields.length){var prop=fields.shift();o=o[prop];if(!fields.length){return o}}}catch(err){return defaultValue}return defaultValue}function hasPath(object,path){path=toPath(path);var index=-1;var _path=path,length=_path.length;var result=false;var key=void 0;while(++index<length){key=path[index];if(!(result=object!=null&&Object.prototype.hasOwnProperty.call(object,key))){break}object=object[key]}return result}var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};var toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}else{return Array.from(arr)}};var INVALID_KEY_RX=/^\d|[^a-zA-Z0-9_]/gm;var INT_KEY_RX=/^\d+$/;function isHash(obj){return(typeof obj==="undefined"?"undefined":_typeof(obj))==="object"&&!Array.isArray(obj)&&!(obj instanceof Date)&&obj!==null}function pathJoin(base,path){try{var connector=path.match(/^\[/)?"":".";return""+(base?base:"")+(base?connector:"")+path}catch(error){return""}}function pushPaths(obj,current,paths){paths.push(current);if(isHash(obj)||Array.isArray(obj)){getPaths(obj,current,paths)}}function getPaths(obj){var current=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"";var paths=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];if(isHash(obj)){forEach(obj,function(val,key){if(key.match(INT_KEY_RX)!==null){pushPaths(val,(current+"."+key).replace(/^\./,""),paths);pushPaths(val,(current+"["+key+"]").replace(/^\./,""),paths);pushPaths(val,(current+'["'+key+'"]').replace(/^\./,""),paths)}else if(key.match(INVALID_KEY_RX)!==null){pushPaths(val,(current+'["'+key+'"]').replace(/^\./,""),paths)}else{pushPaths(val,(current+"."+key).replace(/^\./,""),paths)}})}else if(Array.isArray(obj)){forEach(obj,function(val,idx){pushPaths(val,(current+"."+idx).replace(/^\./,""),paths);pushPaths(val,(current+"["+idx+"]").replace(/^\./,""),paths);pushPaths(val,(current+'["'+idx+'"]').replace(/^\./,""),paths)})}return[].concat(toConsumableArray(new Set(paths)))}function vueSet(obj,path,value){var fields=Array.isArray(path)?path:toPath(path);var prop=fields.shift();if(!fields.length)return Vue.set(obj,prop,value);if(!hasPath(obj,prop)||obj[prop]===null){Vue.set(obj,prop,fields.length>=1&&typeof fields[0]==="number"?[]:{})}vueSet(obj[prop],fields,value)}function vuexSet(path,value){if(!this.$store)throw new Error("[vue-deepset]: could not find vuex store object on instance");this.$store[this.$store.commit?"commit":"dispatch"]("VUEX_DEEP_SET",{path:path,value:value})}function VUEX_DEEP_SET(state,args){vueSet(state,args.path,args.value)}function extendMutation(){var mutations=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return Object.assign(mutations,{VUEX_DEEP_SET:VUEX_DEEP_SET})}function buildVuexModel(vuexPath,options){var _this=this;var model={};var obj=get(this.$store.state,vuexPath);var paths=getPaths(obj);forEach(paths,function(path){var propPath=pathJoin(vuexPath,path);Object.defineProperty(model,path,{configurable:true,enumerable:true,get:function get$$1(){return get(_this.$store.state,propPath)},set:function set$$1(value){vuexSet.call(_this,propPath,value)}})});return model}function vuexModel(vuexPath,options){var _this2=this;if(typeof vuexPath!=="string"||!vuexPath)throw new Error("[vue-deepset]: invalid vuex path string");if(!hasPath(this.$store.state,vuexPath))throw new Error('[vue-deepset]: Cannot find path "'+vuexPath+'" in Vuex store');options=isHash(options)?options:{};if(options.useProxy===false||(typeof Proxy==="undefined"?"undefined":_typeof(Proxy))===undefined){return buildVuexModel.call(this,vuexPath,options)}var obj=get(this.$store.state,vuexPath);var tgt={model:buildVuexModel.call(this,vuexPath,options)};return new Proxy(obj,{get:function get$$1(target,property){if((typeof property==="undefined"?"undefined":_typeof(property))==="symbol")return target[property];if(property==="toJSON")return target.toJSON;if(property==="_isVue")return false;if(!hasPath(obj,property)&&(typeof property==="string"||typeof property==="number")){vuexSet.call(_this2,pathJoin(vuexPath,property),undefined);tgt.model=buildVuexModel.call(_this2,vuexPath,options)}return tgt.model[property]},set:function set$$1(target,property,value){if(tgt.model[property]===value)return true;tgt.model[property]=value;return true},has:function has(target,property){if((typeof property==="undefined"?"undefined":_typeof(property))==="symbol")return target[property];if(property==="toJSON")return target.toJSON;if(property==="_isVue")return true;if(!hasPath(obj,property)&&(typeof property==="string"||typeof property==="number")){vuexSet.call(_this2,pathJoin(vuexPath,property),undefined);tgt.model=buildVuexModel.call(_this2,vuexPath,options)}return true}})}function buildVueModel(obj,options){var _this3=this;var model={};forEach(getPaths(obj),function(path){Object.defineProperty(model,path,{configurable:true,enumerable:true,get:function get$$1(){return get(obj,path)},set:function set$$1(value){vueSet.call(_this3,obj,path,value)}})});return model}function vueModel(obj,options){var _this4=this;if((typeof obj==="undefined"?"undefined":_typeof(obj))!=="object"||!obj)throw new Error("[vue-deepset]: invalid object specified for vue model");options=isHash(options)?options:{};if(options.useProxy===false||typeof Proxy==="undefined"){return buildVueModel.call(this,obj,options)}else{var tgt={model:buildVueModel.call(this,obj,options)};return new Proxy(obj,{get:function get$$1(target,property){if((typeof property==="undefined"?"undefined":_typeof(property))==="symbol")return target[property];if(property==="toJSON")return target.toJSON;if(property==="_isVue")return false;if(!hasPath(tgt.model,property)&&(typeof property==="string"||typeof property==="number")){vueSet.call(_this4,obj,property,undefined);tgt.model=buildVueModel.call(_this4,obj,options)}return tgt.model[property]},set:function set$$1(target,property,value){if(tgt.model[property]===value)return true;tgt.model[property]=value;return true},has:function has(target,property){if(property==="_isVue")return true;if((typeof property==="undefined"?"undefined":_typeof(property))==="symbol")return target[property];if(property==="toJSON")return target.toJSON;if(!hasPath(tgt.model,property)&&(typeof property==="string"||typeof property==="number")){vueSet.call(_this4,obj,property,undefined);tgt.model=buildVueModel.call(_this4,obj,options)}return true}})}}function deepModel(arg,options){return typeof arg==="string"?vuexModel.call(this,arg,options):vueModel.call(this,arg,options)}function install(Vue$$1){Vue$$1.prototype.$deepModel=deepModel;Vue$$1.prototype.$vueSet=vueSet;Vue$$1.prototype.$vuexSet=vuexSet}exports.vueSet=vueSet;exports.vuexSet=vuexSet;exports.VUEX_DEEP_SET=VUEX_DEEP_SET;exports.extendMutation=extendMutation;exports.vuexModel=vuexModel;exports.vueModel=vueModel;exports.deepModel=deepModel;exports.install=install},{}]},{},[1])(1)});
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.VueDeepSet=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _interopDefault$1(ex){return ex&&typeof ex==="object"&&"default"in ex?ex["default"]:ex}var Vue=_interopDefault$1(window.Vue);function toPath(pathString){if(Array.isArray(pathString))return pathString;if(typeof pathString==="number")return[pathString];pathString=String(pathString);var pathRx=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g;var pathArray=[];pathString.replace(pathRx,function(match,number,quote,string){pathArray.push(quote?string:number!==undefined?Number(number):match);return pathArray[pathArray.length-1]});return pathArray}function forEach(obj,fn,throwErrors){try{if(Array.isArray(obj)){var idx=0;var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=obj[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var val=_step.value;if(fn(val,idx)===false)break;idx++}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator.return){_iterator.return()}}finally{if(_didIteratorError){throw _iteratorError}}}}else{for(var key in obj){if(fn(obj[key],key)===false)break}}}catch(err){if(throwErrors)throw err}}function get(obj,path,defaultValue){try{var o=obj;var fields=Array.isArray(path)?path:toPath(path);while(fields.length){var prop=fields.shift();o=o[prop];if(!fields.length){return o}}}catch(err){return defaultValue}return defaultValue}function hasPath(object,path){path=toPath(path);var index=-1;var _path=path,length=_path.length;var result=false;var key=void 0;while(++index<length){key=path[index];if(!(result=object!=null&&Object.prototype.hasOwnProperty.call(object,key))){break}object=object[key]}return result}var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};var toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}else{return Array.from(arr)}};var INVALID_KEY_RX=/^\d|[^a-zA-Z0-9_]/gm;var INT_KEY_RX=/^\d+$/;function isHash(obj){return(typeof obj==="undefined"?"undefined":_typeof(obj))==="object"&&!Array.isArray(obj)&&!(obj instanceof Date)&&obj!==null}function pathJoin(base,path){try{var connector=path.match(/^\[/)?"":".";return""+(base||"")+(base?connector:"")+path}catch(error){return""}}function pushPaths(obj,current,paths){paths.push(current);if(isHash(obj)||Array.isArray(obj)){getPaths(obj,current,paths)}}function getPaths(obj){var current=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"";var paths=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];if(isHash(obj)){forEach(obj,function(val,key){if(key.match(INT_KEY_RX)!==null){pushPaths(val,(current+"."+key).replace(/^\./,""),paths);pushPaths(val,(current+"["+key+"]").replace(/^\./,""),paths);pushPaths(val,(current+'["'+key+'"]').replace(/^\./,""),paths)}else if(key.match(INVALID_KEY_RX)!==null){pushPaths(val,(current+'["'+key+'"]').replace(/^\./,""),paths)}else{pushPaths(val,(current+"."+key).replace(/^\./,""),paths)}})}else if(Array.isArray(obj)){forEach(obj,function(val,idx){pushPaths(val,(current+"."+idx).replace(/^\./,""),paths);pushPaths(val,(current+"["+idx+"]").replace(/^\./,""),paths);pushPaths(val,(current+'["'+idx+'"]').replace(/^\./,""),paths)})}return[].concat(toConsumableArray(new Set(paths)))}function vueSet(object,path,value){var parts=toPath(path);var obj=object;while(parts.length){var key=parts.shift();if(!parts.length){Vue.set(obj,key,value)}else if(!hasPath(obj,key)||obj[key]===null){Vue.set(obj,key,key==="number"?[]:{})}obj=obj[key]}}function vuexSet(path,value){if(!this.$store)throw new Error("[vue-deepset]: could not find vuex store object on instance");this.$store[this.$store.commit?"commit":"dispatch"]("VUEX_DEEP_SET",{path:path,value:value})}function VUEX_DEEP_SET(state,args){vueSet(state,args.path,args.value)}function extendMutation(){var mutations=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return Object.assign(mutations,{VUEX_DEEP_SET:VUEX_DEEP_SET})}function buildVuexModel(vuexPath,options){var _this=this;var model={};var obj=get(this.$store.state,vuexPath);var paths=getPaths(obj);forEach(paths,function(path){var propPath=pathJoin(vuexPath,path);Object.defineProperty(model,path,{configurable:true,enumerable:true,get:function get$$1(){return get(_this.$store.state,propPath)},set:function set$$1(value){vuexSet.call(_this,propPath,value)}})});return model}function vuexModel(vuexPath,options){var _this2=this;var opts=Object.assign({},options);if(typeof vuexPath!=="string"||!vuexPath){throw new Error("[vue-deepset]: invalid vuex path string")}else if(!hasPath(this.$store.state,vuexPath)){throw new Error('[vue-deepset]: Cannot find path "'+vuexPath+'" in Vuex store')}else if(opts.useProxy===false||typeof Proxy==="undefined"){return buildVuexModel.call(this,vuexPath,opts)}var obj=get(this.$store.state,vuexPath);var tgt={model:buildVuexModel.call(this,vuexPath,opts)};return new Proxy(obj,{get:function get$$1(target,property){if((typeof property==="undefined"?"undefined":_typeof(property))==="symbol")return target[property];if(property==="toJSON")return target.toJSON;if(property==="_isVue")return false;if(opts.dynamicUpdates!==false&&!hasPath(obj,property)&&(typeof property==="string"||typeof property==="number")){vuexSet.call(_this2,pathJoin(vuexPath,property),undefined);tgt.model=buildVuexModel.call(_this2,vuexPath,opts)}return tgt.model[property]},set:function set$$1(target,property,value){if(tgt.model[property]===value)return true;tgt.model[property]=value;return true},has:function has(target,property){if((typeof property==="undefined"?"undefined":_typeof(property))==="symbol")return target[property];if(property==="toJSON")return target.toJSON;if(property==="_isVue")return true;if(opts.dynamicUpdates!==false&&!hasPath(obj,property)&&(typeof property==="string"||typeof property==="number")){vuexSet.call(_this2,pathJoin(vuexPath,property),undefined);tgt.model=buildVuexModel.call(_this2,vuexPath,opts)}return true}})}function buildVueModel(obj,options){var _this3=this;var model={};forEach(getPaths(obj),function(path){Object.defineProperty(model,path,{configurable:true,enumerable:true,get:function get$$1(){return get(obj,path)},set:function set$$1(value){vueSet.call(_this3,obj,path,value)}})});return model}function vueModel(obj,options){var _this4=this;var opts=Object.assign({},options);if((typeof obj==="undefined"?"undefined":_typeof(obj))!=="object"||!obj){throw new Error("[vue-deepset]: invalid object specified for vue model")}else if(opts.useProxy===false||typeof Proxy==="undefined"){return buildVueModel.call(this,obj,opts)}var tgt={model:buildVueModel.call(this,obj,opts)};return new Proxy(obj,{get:function get$$1(target,property){if((typeof property==="undefined"?"undefined":_typeof(property))==="symbol")return target[property];if(property==="toJSON")return target.toJSON;if(property==="_isVue")return false;if(opts.dynamicUpdates!==false&&!hasPath(tgt.model,property)&&(typeof property==="string"||typeof property==="number")){vueSet.call(_this4,obj,property,undefined);tgt.model=buildVueModel.call(_this4,obj,opts)}return tgt.model[property]},set:function set$$1(target,property,value){if(tgt.model[property]===value)return true;tgt.model[property]=value;return true},has:function has(target,property){if(property==="_isVue")return true;if((typeof property==="undefined"?"undefined":_typeof(property))==="symbol")return target[property];if(property==="toJSON")return target.toJSON;if(opts.dynamicUpdates!==false&&!hasPath(tgt.model,property)&&(typeof property==="string"||typeof property==="number")){vueSet.call(_this4,obj,property,undefined);tgt.model=buildVueModel.call(_this4,obj,opts)}return true}})}function deepModel(arg,options){return typeof arg==="string"?vuexModel.call(this,arg,options):vueModel.call(this,arg,options)}function install(Vue$$1){Vue$$1.prototype.$deepModel=deepModel;Vue$$1.prototype.$vueSet=vueSet;Vue$$1.prototype.$vuexSet=vuexSet}exports.vueSet=vueSet;exports.vuexSet=vuexSet;exports.VUEX_DEEP_SET=VUEX_DEEP_SET;exports.extendMutation=extendMutation;exports.vuexModel=vuexModel;exports.vueModel=vueModel;exports.deepModel=deepModel;exports.install=install},{}]},{},[1])(1)});

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