diff --git a/CHANGELOG.md b/CHANGELOG.md index 23049cc..f6dc46e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [2.1.5](https://github.com/kouts/vue-path-store/compare/v2.1.4...v2.1.5) (2022-07-23) + + +### Bug Fixes + +* updated node and npm packages ([4cc9a46](https://github.com/kouts/vue-path-store/commit/4cc9a46865988b1e7232f051bb4f512320725229)) + ## [2.1.4](https://github.com/kouts/vue-path-store/compare/v2.1.3...v2.1.4) (2022-05-07) diff --git a/dist/cjs/pathStore.js b/dist/cjs/pathStore.js index c1e52c1..51e05fe 100644 --- a/dist/cjs/pathStore.js +++ b/dist/cjs/pathStore.js @@ -8,48 +8,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - - return keys; -} - -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -var ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; +const ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; function _typeof(obj) { "@babel/helpers - typeof"; @@ -177,41 +136,42 @@ var deleteMany = function deleteMany(obj, path) { }; function createPathStoreMethods() { - return _objectSpread2({ - set: function set(path, value) { + return { + set(path, value) { setMany(this, path, value); }, - toggle: function toggle(path) { + + toggle(path) { setOne(this, path, !getByPath(this, path)); }, - get: function get(path) { + + get(path) { return path ? getByPath(this, path) : this; }, - del: function del(path) { + + del(path) { deleteMany(this, path); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + }, - var path = args.shift(); - var arr = getByPath(this, path); + ...ARRAY_METHODS.reduce(function (acc, method) { + const fn = function (...args) { + const path = args.shift(); + const arr = getByPath(this, path); - if (!isArray(arr)) { - throw Error('Argument must be an array.'); - } + if (!isArray(arr)) { + throw Error('Argument must be an array.'); + } - return arr[method].apply(arr, args); - }; + return arr[method](...args); + }; - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); + return Object.assign(acc, { + [method]: fn + }); + }, {}) + }; } -var createPathStore = function createPathStore(state) { - return Object.assign(Vue__default["default"].observable(state), createPathStoreMethods()); -}; +const createPathStore = state => Object.assign(Vue__default["default"].observable(state), createPathStoreMethods()); exports.createPathStore = createPathStore; diff --git a/dist/cjs/pathStorePiniaPlugin.js b/dist/cjs/pathStorePiniaPlugin.js index 0598b08..f91830c 100644 --- a/dist/cjs/pathStorePiniaPlugin.js +++ b/dist/cjs/pathStorePiniaPlugin.js @@ -8,48 +8,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - - return keys; -} - -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -var ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; +const ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; function _typeof(obj) { "@babel/helpers - typeof"; @@ -177,41 +136,42 @@ var deleteMany = function deleteMany(obj, path) { }; function createPathStoreMethods() { - return _objectSpread2({ - set: function set(path, value) { + return { + set(path, value) { setMany(this, path, value); }, - toggle: function toggle(path) { + + toggle(path) { setOne(this, path, !getByPath(this, path)); }, - get: function get(path) { + + get(path) { return path ? getByPath(this, path) : this; }, - del: function del(path) { + + del(path) { deleteMany(this, path); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + }, - var path = args.shift(); - var arr = getByPath(this, path); + ...ARRAY_METHODS.reduce(function (acc, method) { + const fn = function (...args) { + const path = args.shift(); + const arr = getByPath(this, path); - if (!isArray(arr)) { - throw Error('Argument must be an array.'); - } + if (!isArray(arr)) { + throw Error('Argument must be an array.'); + } - return arr[method].apply(arr, args); - }; + return arr[method](...args); + }; - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); + return Object.assign(acc, { + [method]: fn + }); + }, {}) + }; } -var pathStorePiniaPlugin = function pathStorePiniaPlugin(ctx) { - return Object.assign(ctx.store.actions = ctx.store.actions || {}, createPathStoreMethods()); -}; +const pathStorePiniaPlugin = ctx => Object.assign(ctx.store.actions = ctx.store.actions || {}, createPathStoreMethods()); exports.pathStorePiniaPlugin = pathStorePiniaPlugin; diff --git a/dist/cjs/pathStoreVuexPlugin.js b/dist/cjs/pathStoreVuexPlugin.js index 9daec81..de5002b 100644 --- a/dist/cjs/pathStoreVuexPlugin.js +++ b/dist/cjs/pathStoreVuexPlugin.js @@ -8,81 +8,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - - return keys; -} - -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); -} - -function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) return _arrayLikeToArray(arr); -} - -function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); -} - -function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); -} - -function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - - return arr2; -} - -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} - -var ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; +const ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; function _typeof(obj) { "@babel/helpers - typeof"; @@ -209,82 +135,94 @@ var deleteMany = function deleteMany(obj, path) { } }; -var pathStoreVuexPlugin = function pathStoreVuexPlugin(store) { - var methods = _objectSpread2({ - set: function set(path, value) { +const pathStoreVuexPlugin = store => { + const methods = { + set(path, value) { store.commit('set', { - path: path, - value: value + path, + value }); }, - toggle: function toggle(path) { + + toggle(path) { store.commit('toggle', { - path: path + path }); }, - get: function get(path) { + + get(path) { return path ? getByPath(store.state, path) : store.state; }, - del: function del(path) { + + del(path) { store.commit('del', { - path: path + path }); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + }, - var path = args.shift(); - return store.commit(method, { - path: path, - args: args + ...ARRAY_METHODS.reduce((acc, method) => { + const fn = (...args) => { + const path = args.shift(); + return store.commit(method, { + path, + args + }); + }; + + return Object.assign(acc, { + [method]: fn }); - }; - - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); - - var mutations = _objectSpread2({ - set: function set(state, info) { - var path = info.path, - value = info.value; + }, {}) + }; + const mutations = { + set(state, info) { + const { + path, + value + } = info; setMany(state, path, value); }, - toggle: function toggle(state, info) { - var path = info.path; + + toggle(state, info) { + const { + path + } = info; setOne(state, path, !getByPath(state, path)); }, - del: function del(state, info) { - var path = info.path; + + del(state, info) { + const { + path + } = info; deleteMany(state, path); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn(state, info) { - var path = info.path, - args = info.args; - var arr = getByPath(state, path); - - if (!isArray(arr)) { - throw Error('Argument must be an array.'); - } + }, + + ...ARRAY_METHODS.reduce((acc, method) => { + const fn = (state, info) => { + const { + path, + args + } = info; + const arr = getByPath(state, path); - return arr[method].apply(arr, _toConsumableArray(args)); - }; + if (!isArray(arr)) { + throw Error('Argument must be an array.'); + } + + return arr[method](...args); + }; - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); + return Object.assign(acc, { + [method]: fn + }); + }, {}) + }; - var _loop = function _loop(type) { - var entry = store._mutations[type] || (store._mutations[type] = []); + for (const type in mutations) { + const entry = store._mutations[type] || (store._mutations[type] = []); entry.push(function wrappedMutationHandler(payload) { mutations[type].call(store, store.state, payload); }); - }; - - for (var type in mutations) { - _loop(type); } return Object.assign(store, methods); diff --git a/dist/es/pathStore.js b/dist/es/pathStore.js index 3086dab..6602857 100644 --- a/dist/es/pathStore.js +++ b/dist/es/pathStore.js @@ -1,47 +1,6 @@ import Vue from 'vue'; -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - - return keys; -} - -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -var ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; +const ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; function _typeof(obj) { "@babel/helpers - typeof"; @@ -169,41 +128,42 @@ var deleteMany = function deleteMany(obj, path) { }; function createPathStoreMethods() { - return _objectSpread2({ - set: function set(path, value) { + return { + set(path, value) { setMany(this, path, value); }, - toggle: function toggle(path) { + + toggle(path) { setOne(this, path, !getByPath(this, path)); }, - get: function get(path) { + + get(path) { return path ? getByPath(this, path) : this; }, - del: function del(path) { + + del(path) { deleteMany(this, path); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + }, - var path = args.shift(); - var arr = getByPath(this, path); + ...ARRAY_METHODS.reduce(function (acc, method) { + const fn = function (...args) { + const path = args.shift(); + const arr = getByPath(this, path); - if (!isArray(arr)) { - throw Error('Argument must be an array.'); - } + if (!isArray(arr)) { + throw Error('Argument must be an array.'); + } - return arr[method].apply(arr, args); - }; + return arr[method](...args); + }; - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); + return Object.assign(acc, { + [method]: fn + }); + }, {}) + }; } -var createPathStore = function createPathStore(state) { - return Object.assign(Vue.observable(state), createPathStoreMethods()); -}; +const createPathStore = state => Object.assign(Vue.observable(state), createPathStoreMethods()); export { createPathStore }; diff --git a/dist/es/pathStorePiniaPlugin.js b/dist/es/pathStorePiniaPlugin.js index be1d54b..c2af605 100644 --- a/dist/es/pathStorePiniaPlugin.js +++ b/dist/es/pathStorePiniaPlugin.js @@ -1,47 +1,6 @@ import Vue from 'vue'; -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - - return keys; -} - -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -var ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; +const ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; function _typeof(obj) { "@babel/helpers - typeof"; @@ -169,41 +128,42 @@ var deleteMany = function deleteMany(obj, path) { }; function createPathStoreMethods() { - return _objectSpread2({ - set: function set(path, value) { + return { + set(path, value) { setMany(this, path, value); }, - toggle: function toggle(path) { + + toggle(path) { setOne(this, path, !getByPath(this, path)); }, - get: function get(path) { + + get(path) { return path ? getByPath(this, path) : this; }, - del: function del(path) { + + del(path) { deleteMany(this, path); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + }, - var path = args.shift(); - var arr = getByPath(this, path); + ...ARRAY_METHODS.reduce(function (acc, method) { + const fn = function (...args) { + const path = args.shift(); + const arr = getByPath(this, path); - if (!isArray(arr)) { - throw Error('Argument must be an array.'); - } + if (!isArray(arr)) { + throw Error('Argument must be an array.'); + } - return arr[method].apply(arr, args); - }; + return arr[method](...args); + }; - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); + return Object.assign(acc, { + [method]: fn + }); + }, {}) + }; } -var pathStorePiniaPlugin = function pathStorePiniaPlugin(ctx) { - return Object.assign(ctx.store.actions = ctx.store.actions || {}, createPathStoreMethods()); -}; +const pathStorePiniaPlugin = ctx => Object.assign(ctx.store.actions = ctx.store.actions || {}, createPathStoreMethods()); export { pathStorePiniaPlugin }; diff --git a/dist/es/pathStoreVuexPlugin.js b/dist/es/pathStoreVuexPlugin.js index 25b142c..3b7fcb1 100644 --- a/dist/es/pathStoreVuexPlugin.js +++ b/dist/es/pathStoreVuexPlugin.js @@ -1,80 +1,6 @@ import Vue from 'vue'; -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - - return keys; -} - -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); -} - -function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) return _arrayLikeToArray(arr); -} - -function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); -} - -function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); -} - -function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - - return arr2; -} - -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} - -var ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; +const ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; function _typeof(obj) { "@babel/helpers - typeof"; @@ -201,82 +127,94 @@ var deleteMany = function deleteMany(obj, path) { } }; -var pathStoreVuexPlugin = function pathStoreVuexPlugin(store) { - var methods = _objectSpread2({ - set: function set(path, value) { +const pathStoreVuexPlugin = store => { + const methods = { + set(path, value) { store.commit('set', { - path: path, - value: value + path, + value }); }, - toggle: function toggle(path) { + + toggle(path) { store.commit('toggle', { - path: path + path }); }, - get: function get(path) { + + get(path) { return path ? getByPath(store.state, path) : store.state; }, - del: function del(path) { + + del(path) { store.commit('del', { - path: path + path }); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + }, - var path = args.shift(); - return store.commit(method, { - path: path, - args: args + ...ARRAY_METHODS.reduce((acc, method) => { + const fn = (...args) => { + const path = args.shift(); + return store.commit(method, { + path, + args + }); + }; + + return Object.assign(acc, { + [method]: fn }); - }; - - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); - - var mutations = _objectSpread2({ - set: function set(state, info) { - var path = info.path, - value = info.value; + }, {}) + }; + const mutations = { + set(state, info) { + const { + path, + value + } = info; setMany(state, path, value); }, - toggle: function toggle(state, info) { - var path = info.path; + + toggle(state, info) { + const { + path + } = info; setOne(state, path, !getByPath(state, path)); }, - del: function del(state, info) { - var path = info.path; + + del(state, info) { + const { + path + } = info; deleteMany(state, path); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn(state, info) { - var path = info.path, - args = info.args; - var arr = getByPath(state, path); - - if (!isArray(arr)) { - throw Error('Argument must be an array.'); - } + }, + + ...ARRAY_METHODS.reduce((acc, method) => { + const fn = (state, info) => { + const { + path, + args + } = info; + const arr = getByPath(state, path); - return arr[method].apply(arr, _toConsumableArray(args)); - }; + if (!isArray(arr)) { + throw Error('Argument must be an array.'); + } + + return arr[method](...args); + }; - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); + return Object.assign(acc, { + [method]: fn + }); + }, {}) + }; - var _loop = function _loop(type) { - var entry = store._mutations[type] || (store._mutations[type] = []); + for (const type in mutations) { + const entry = store._mutations[type] || (store._mutations[type] = []); entry.push(function wrappedMutationHandler(payload) { mutations[type].call(store, store.state, payload); }); - }; - - for (var type in mutations) { - _loop(type); } return Object.assign(store, methods); diff --git a/dist/umd/pathStore.js b/dist/umd/pathStore.js index d37b181..d19fd3b 100644 --- a/dist/umd/pathStore.js +++ b/dist/umd/pathStore.js @@ -8,48 +8,7 @@ var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); - function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - - return keys; - } - - function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - - return target; - } - - function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; - } - - var ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; + const ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; function _typeof(obj) { "@babel/helpers - typeof"; @@ -177,42 +136,43 @@ }; function createPathStoreMethods() { - return _objectSpread2({ - set: function set(path, value) { + return { + set(path, value) { setMany(this, path, value); }, - toggle: function toggle(path) { + + toggle(path) { setOne(this, path, !getByPath(this, path)); }, - get: function get(path) { + + get(path) { return path ? getByPath(this, path) : this; }, - del: function del(path) { + + del(path) { deleteMany(this, path); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + }, - var path = args.shift(); - var arr = getByPath(this, path); + ...ARRAY_METHODS.reduce(function (acc, method) { + const fn = function (...args) { + const path = args.shift(); + const arr = getByPath(this, path); - if (!isArray(arr)) { - throw Error('Argument must be an array.'); - } + if (!isArray(arr)) { + throw Error('Argument must be an array.'); + } - return arr[method].apply(arr, args); - }; + return arr[method](...args); + }; - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); + return Object.assign(acc, { + [method]: fn + }); + }, {}) + }; } - var createPathStore = function createPathStore(state) { - return Object.assign(Vue__default["default"].observable(state), createPathStoreMethods()); - }; + const createPathStore = state => Object.assign(Vue__default["default"].observable(state), createPathStoreMethods()); exports.createPathStore = createPathStore; diff --git a/dist/umd/pathStore.min.js b/dist/umd/pathStore.min.js index 24d0925..cc4127f 100644 --- a/dist/umd/pathStore.min.js +++ b/dist/umd/pathStore.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).pathStore={},e.Vue)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t);function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var u=["pop","push","reverse","shift","sort","splice","unshift"];function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function s(e){return!isNaN(e)&&!isNaN(parseFloat(e))}function c(e){return Array.isArray(e)}function a(e){for(var t,r=/([\w\s-]+)|\[([^\]]+)\]/g,n=[];t=r.exec(e||"");)"["===e[t.index]?n.push(t[2]):n.push(t[1]);return n}function l(e,t){for(var r=c(t)?t:a(t),n=r.length,o=0;oObject.assign(n.default.observable(t),y()),Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/dist/umd/pathStorePiniaPlugin.js b/dist/umd/pathStorePiniaPlugin.js index fc76a5f..2783b33 100644 --- a/dist/umd/pathStorePiniaPlugin.js +++ b/dist/umd/pathStorePiniaPlugin.js @@ -8,48 +8,7 @@ var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); - function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - - return keys; - } - - function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - - return target; - } - - function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; - } - - var ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; + const ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; function _typeof(obj) { "@babel/helpers - typeof"; @@ -177,42 +136,43 @@ }; function createPathStoreMethods() { - return _objectSpread2({ - set: function set(path, value) { + return { + set(path, value) { setMany(this, path, value); }, - toggle: function toggle(path) { + + toggle(path) { setOne(this, path, !getByPath(this, path)); }, - get: function get(path) { + + get(path) { return path ? getByPath(this, path) : this; }, - del: function del(path) { + + del(path) { deleteMany(this, path); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + }, - var path = args.shift(); - var arr = getByPath(this, path); + ...ARRAY_METHODS.reduce(function (acc, method) { + const fn = function (...args) { + const path = args.shift(); + const arr = getByPath(this, path); - if (!isArray(arr)) { - throw Error('Argument must be an array.'); - } + if (!isArray(arr)) { + throw Error('Argument must be an array.'); + } - return arr[method].apply(arr, args); - }; + return arr[method](...args); + }; - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); + return Object.assign(acc, { + [method]: fn + }); + }, {}) + }; } - var pathStorePiniaPlugin = function pathStorePiniaPlugin(ctx) { - return Object.assign(ctx.store.actions = ctx.store.actions || {}, createPathStoreMethods()); - }; + const pathStorePiniaPlugin = ctx => Object.assign(ctx.store.actions = ctx.store.actions || {}, createPathStoreMethods()); exports.pathStorePiniaPlugin = pathStorePiniaPlugin; diff --git a/dist/umd/pathStorePiniaPlugin.min.js b/dist/umd/pathStorePiniaPlugin.min.js index 14c31c4..0c5fe57 100644 --- a/dist/umd/pathStorePiniaPlugin.min.js +++ b/dist/umd/pathStorePiniaPlugin.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pathStorePiniaPlugin={},t.Vue)}(this,(function(t,e){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=r(e);function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var u=["pop","push","reverse","shift","sort","splice","unshift"];function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function s(t){return!isNaN(t)&&!isNaN(parseFloat(t))}function c(t){return Array.isArray(t)}function a(t){for(var e,r=/([\w\s-]+)|\[([^\]]+)\]/g,n=[];e=r.exec(t||"");)"["===t[e.index]?n.push(e[2]):n.push(e[1]);return n}function l(t,e){for(var r=c(e)?e:a(e),n=r.length,o=0;oObject.assign(t.store.actions=t.store.actions||{},y()),Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/dist/umd/pathStoreVuexPlugin.js b/dist/umd/pathStoreVuexPlugin.js index 3c37d0d..ce44d0d 100644 --- a/dist/umd/pathStoreVuexPlugin.js +++ b/dist/umd/pathStoreVuexPlugin.js @@ -8,81 +8,7 @@ var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); - function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - - return keys; - } - - function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - - return target; - } - - function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; - } - - function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); - } - - function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) return _arrayLikeToArray(arr); - } - - function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); - } - - function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); - } - - function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - - return arr2; - } - - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - var ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; + const ARRAY_METHODS = ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']; function _typeof(obj) { "@babel/helpers - typeof"; @@ -209,82 +135,94 @@ } }; - var pathStoreVuexPlugin = function pathStoreVuexPlugin(store) { - var methods = _objectSpread2({ - set: function set(path, value) { + const pathStoreVuexPlugin = store => { + const methods = { + set(path, value) { store.commit('set', { - path: path, - value: value + path, + value }); }, - toggle: function toggle(path) { + + toggle(path) { store.commit('toggle', { - path: path + path }); }, - get: function get(path) { + + get(path) { return path ? getByPath(store.state, path) : store.state; }, - del: function del(path) { + + del(path) { store.commit('del', { - path: path + path }); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + }, - var path = args.shift(); - return store.commit(method, { - path: path, - args: args + ...ARRAY_METHODS.reduce((acc, method) => { + const fn = (...args) => { + const path = args.shift(); + return store.commit(method, { + path, + args + }); + }; + + return Object.assign(acc, { + [method]: fn }); - }; - - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); - - var mutations = _objectSpread2({ - set: function set(state, info) { - var path = info.path, - value = info.value; + }, {}) + }; + const mutations = { + set(state, info) { + const { + path, + value + } = info; setMany(state, path, value); }, - toggle: function toggle(state, info) { - var path = info.path; + + toggle(state, info) { + const { + path + } = info; setOne(state, path, !getByPath(state, path)); }, - del: function del(state, info) { - var path = info.path; + + del(state, info) { + const { + path + } = info; deleteMany(state, path); - } - }, ARRAY_METHODS.reduce(function (acc, method) { - var fn = function fn(state, info) { - var path = info.path, - args = info.args; - var arr = getByPath(state, path); - - if (!isArray(arr)) { - throw Error('Argument must be an array.'); - } + }, + + ...ARRAY_METHODS.reduce((acc, method) => { + const fn = (state, info) => { + const { + path, + args + } = info; + const arr = getByPath(state, path); - return arr[method].apply(arr, _toConsumableArray(args)); - }; + if (!isArray(arr)) { + throw Error('Argument must be an array.'); + } + + return arr[method](...args); + }; - return Object.assign(acc, _defineProperty({}, method, fn)); - }, {})); + return Object.assign(acc, { + [method]: fn + }); + }, {}) + }; - var _loop = function _loop(type) { - var entry = store._mutations[type] || (store._mutations[type] = []); + for (const type in mutations) { + const entry = store._mutations[type] || (store._mutations[type] = []); entry.push(function wrappedMutationHandler(payload) { mutations[type].call(store, store.state, payload); }); - }; - - for (var type in mutations) { - _loop(type); } return Object.assign(store, methods); diff --git a/dist/umd/pathStoreVuexPlugin.min.js b/dist/umd/pathStoreVuexPlugin.min.js index 20e9dde..c96e54c 100644 --- a/dist/umd/pathStoreVuexPlugin.min.js +++ b/dist/umd/pathStoreVuexPlugin.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pathStoreVuexPlugin={},t.Vue)}(this,(function(t,e){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=r(e);function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function u(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r{const e={set(e,r){t.commit("set",{path:e,value:r})},toggle(e){t.commit("toggle",{path:e})},get:e=>e?a(t.state,e):t.state,del(e){t.commit("del",{path:e})},...n.reduce(((e,r)=>Object.assign(e,{[r]:(...e)=>{const o=e.shift();return t.commit(r,{path:o,args:e})}})),{})},r={set(t,e){const{path:r,value:o}=e;l(t,r,o)},toggle(t,e){const{path:r}=e;c(t,r,!a(t,r))},del(t,e){const{path:r}=e;!function(t,e){if("string"==typeof e)p(t,e);else{if(!i(e))throw Error("Arguments must be either string or array.");e.forEach((function(e){p(t,e)}))}}(t,r)},...n.reduce(((t,e)=>Object.assign(t,{[e]:(t,r)=>{const{path:o,args:n}=r,u=a(t,o);if(!i(u))throw Error("Argument must be an array.");return u[e](...n)}})),{})};for(const e in r){(t._mutations[e]||(t._mutations[e]=[])).push((function(o){r[e].call(t,t.state,o)}))}return Object.assign(t,e)},Object.defineProperty(t,"__esModule",{value:!0})}));