🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@vueblocks/vue-use-vuex

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vueblocks/vue-use-vuex - npm Package Compare versions

Comparing version

to
0.1.6

55

lib/index.cjs.js

@@ -7,3 +7,2 @@ 'use strict';

// import { isObject, isNull } from 'lodash'
const isObject = (arg) => Object.prototype.toString.call(arg) === '[object Object]';

@@ -23,4 +22,18 @@ const isNull = (val) => val === null;

}
return vm.$store;
return vueDemi.isVue3 ? vm.ctx.$store : vm.$store;
};
const computedGetter = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return vueDemi.computed(() => store.getters[prop]);
};
const computedState = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return vueDemi.computed(() => store.state[namespace][prop]);
};
const computedMethods = (store = null, namespace, cb) => {
const { state, getters } = store;
return vueDemi.computed(() => cb(state[namespace], getters));
};
const mapFormArray = (namespace, map, cb) => {

@@ -44,4 +57,4 @@ // console.group('mapFromArray')

// console.groupEnd()
let result = {};
for (let key in map) {
const result = {};
for (const key in map) {
const prop = getProperty(map, key);

@@ -60,6 +73,6 @@ if (typeof prop === 'function' && !isNull(namespace)) {

const keysMap = {
'useState': state[namespace],
'useGetters': getters,
'useMutations': _mutations,
'useActions': _actions
useState: state[namespace],
useGetters: getters,
useMutations: _mutations,
useActions: _actions
};

@@ -79,22 +92,7 @@ return Object.keys(keysMap[type]);

};
const computedGetter = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return vueDemi.computed(() => store.getters[prop]);
};
const computedState = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return vueDemi.computed(() => store.state[namespace][prop]);
};
const computedMethods = (store = null, namespace, cb) => {
const { state, getters } = store;
return vueDemi.computed(() => cb(state[namespace], getters));
};
const getMutations = (store = null, namespace, type) => {
if (!store)
store = getStoreFromInstance();
return function mappedMutation() {
const args = arguments;
return store.commit.apply(store, [type, ...args]);
return function mappedMutation(...args) {
return store.commit(type, ...args);
};

@@ -105,5 +103,4 @@ };

store = getStoreFromInstance();
return function mappedAction() {
const args = arguments;
return store.dispatch.apply(store, [action, ...args]);
return function mappedAction(...args) {
return store.dispatch(action, args);
};

@@ -149,3 +146,3 @@ };

store = getStoreFromInstance();
console.log(store);
// console.log(store)
return {

@@ -152,0 +149,0 @@ useState: useState.bind(null, store),

@@ -1,4 +0,3 @@

import { getCurrentInstance, computed } from 'vue-demi';
import { isVue3, getCurrentInstance, computed } from 'vue-demi';
// import { isObject, isNull } from 'lodash'
const isObject = (arg) => Object.prototype.toString.call(arg) === '[object Object]';

@@ -18,4 +17,18 @@ const isNull = (val) => val === null;

}
return vm.$store;
return isVue3 ? vm.ctx.$store : vm.$store;
};
const computedGetter = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return computed(() => store.getters[prop]);
};
const computedState = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return computed(() => store.state[namespace][prop]);
};
const computedMethods = (store = null, namespace, cb) => {
const { state, getters } = store;
return computed(() => cb(state[namespace], getters));
};
const mapFormArray = (namespace, map, cb) => {

@@ -39,4 +52,4 @@ // console.group('mapFromArray')

// console.groupEnd()
let result = {};
for (let key in map) {
const result = {};
for (const key in map) {
const prop = getProperty(map, key);

@@ -55,6 +68,6 @@ if (typeof prop === 'function' && !isNull(namespace)) {

const keysMap = {
'useState': state[namespace],
'useGetters': getters,
'useMutations': _mutations,
'useActions': _actions
useState: state[namespace],
useGetters: getters,
useMutations: _mutations,
useActions: _actions
};

@@ -74,22 +87,7 @@ return Object.keys(keysMap[type]);

};
const computedGetter = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return computed(() => store.getters[prop]);
};
const computedState = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return computed(() => store.state[namespace][prop]);
};
const computedMethods = (store = null, namespace, cb) => {
const { state, getters } = store;
return computed(() => cb(state[namespace], getters));
};
const getMutations = (store = null, namespace, type) => {
if (!store)
store = getStoreFromInstance();
return function mappedMutation() {
const args = arguments;
return store.commit.apply(store, [type, ...args]);
return function mappedMutation(...args) {
return store.commit(type, ...args);
};

@@ -100,5 +98,4 @@ };

store = getStoreFromInstance();
return function mappedAction() {
const args = arguments;
return store.dispatch.apply(store, [action, ...args]);
return function mappedAction(...args) {
return store.dispatch(action, args);
};

@@ -144,3 +141,3 @@ };

store = getStoreFromInstance();
console.log(store);
// console.log(store)
return {

@@ -147,0 +144,0 @@ useState: useState.bind(null, store),

@@ -7,3 +7,2 @@ (function (global, factory) {

// import { isObject, isNull } from 'lodash'
const isObject = (arg) => Object.prototype.toString.call(arg) === '[object Object]';

@@ -23,4 +22,18 @@ const isNull = (val) => val === null;

}
return vm.$store;
return vueDemi.isVue3 ? vm.ctx.$store : vm.$store;
};
const computedGetter = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return vueDemi.computed(() => store.getters[prop]);
};
const computedState = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return vueDemi.computed(() => store.state[namespace][prop]);
};
const computedMethods = (store = null, namespace, cb) => {
const { state, getters } = store;
return vueDemi.computed(() => cb(state[namespace], getters));
};
const mapFormArray = (namespace, map, cb) => {

@@ -44,4 +57,4 @@ // console.group('mapFromArray')

// console.groupEnd()
let result = {};
for (let key in map) {
const result = {};
for (const key in map) {
const prop = getProperty(map, key);

@@ -60,6 +73,6 @@ if (typeof prop === 'function' && !isNull(namespace)) {

const keysMap = {
'useState': state[namespace],
'useGetters': getters,
'useMutations': _mutations,
'useActions': _actions
useState: state[namespace],
useGetters: getters,
useMutations: _mutations,
useActions: _actions
};

@@ -79,22 +92,7 @@ return Object.keys(keysMap[type]);

};
const computedGetter = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return vueDemi.computed(() => store.getters[prop]);
};
const computedState = (store = null, namespace, prop) => {
if (!store)
store = getStoreFromInstance();
return vueDemi.computed(() => store.state[namespace][prop]);
};
const computedMethods = (store = null, namespace, cb) => {
const { state, getters } = store;
return vueDemi.computed(() => cb(state[namespace], getters));
};
const getMutations = (store = null, namespace, type) => {
if (!store)
store = getStoreFromInstance();
return function mappedMutation() {
const args = arguments;
return store.commit.apply(store, [type, ...args]);
return function mappedMutation(...args) {
return store.commit(type, ...args);
};

@@ -105,5 +103,4 @@ };

store = getStoreFromInstance();
return function mappedAction() {
const args = arguments;
return store.dispatch.apply(store, [action, ...args]);
return function mappedAction(...args) {
return store.dispatch(action, args);
};

@@ -149,3 +146,3 @@ };

store = getStoreFromInstance();
console.log(store);
// console.log(store)
return {

@@ -152,0 +149,0 @@ useState: useState.bind(null, store),

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VueUseVuex={},e.VueDemi)}(this,(function(e,t){"use strict";const n=e=>"[object Object]"===Object.prototype.toString.call(e),r=(e,t)=>e[t],u=e=>Array.isArray(e)||n(e),s=()=>{const e=t.getCurrentInstance();return e||console.error('You must use this function within the "setup()" method, or insert the store as first argument.'),e.$store},o=(e,t,u,s,o)=>{if(!s)return{};if(Array.isArray(s))return((e,t,n)=>t.reduce(((t,r)=>(t[r]=n(null,e,r),t)),{}))(u,s,o);if(n(s)){return((e,t,n,u,s)=>{let o={};for(let a in u){const l=r(u,a);"function"==typeof l&&null!==n&&(o[a]=i(t,n,l)),e.includes(l)&&(o[a]=s(null,n,l))}return o})(((e,t,n)=>{const{state:r,getters:u,_mutations:s,_actions:o}=e,a={useState:r[t],useGetters:u,useMutations:s,useActions:o};return Object.keys(a[n])})(t,u,e),t,u,s,o)}},a=(e=null,n,r)=>(e||(e=s()),t.computed((()=>e.getters[r]))),l=(e=null,n,r)=>(e||(e=s()),t.computed((()=>e.state[n][r]))),i=(e=null,n,r)=>{const{state:u,getters:s}=e;return t.computed((()=>r(u[n],s)))},c=(e=null,t,n)=>(e||(e=s()),function(){const t=arguments;return e.commit.apply(e,[n,...t])}),p=(e=null,t,n)=>(e||(e=s()),function(){const t=arguments;return e.dispatch.apply(e,[n,...t])}),m=(e,t,n)=>(u(n)||console.error("[vuex] useGetters: mapper parameter must be either an Array or an Object"),o.bind(null,m.name)(e,t,n,a)),d=(e,t,n)=>(u(n)||console.error("[vuex] useState: mapper parameter must be either an Array or an Object"),o.bind(null,d.name)(e,t,n,l)),b=(e,t,n)=>(u(n)||console.error("[vuex] useMutations: mapper parameter must be either an Array or an Object"),o.bind(null,b.name)(e,t,n,c)),f=(e,t,n)=>(u(n)||console.error("[vuex] useActions: mapper parameter must be either an Array or an Object"),o.bind(null,f.name)(e,t,n,p)),y=e=>({mapState:d.bind(null,e),mapGetters:m.bind(null,e),mapMutations:b.bind(null,e),mapActions:f.bind(null,e)});e.useVuex=e=>(e||(e=s()),console.log(e),{useState:d.bind(null,e),useGetters:m.bind(null,e),useMutations:b.bind(null,e),useActions:f.bind(null,e),getStoreFromInstance:s,createNamespacedHelpers:y}),Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VueUseVuex={},e.VueDemi)}(this,(function(e,t){"use strict";const n=e=>"[object Object]"===Object.prototype.toString.call(e),u=(e,t)=>e[t],s=e=>Array.isArray(e)||n(e),l=()=>{const e=t.getCurrentInstance();return t.isVue3?e.ctx.$store:e.$store},r=(e=null,n,u)=>(e||(e=l()),t.computed((()=>e.getters[u]))),i=(e=null,n,u)=>(e||(e=l()),t.computed((()=>e.state[n][u]))),o=(e=null,n,u)=>{const{state:s,getters:l}=e;return t.computed((()=>u(s[n],l)))},c=(e,t,s,l,r)=>{if(!l)return{};if(Array.isArray(l))return((e,t,n)=>t.reduce(((t,u)=>(t[u]=n(null,e,u),t)),{}))(s,l,r);if(n(l)){return((e,t,n,s,l)=>{const r={};for(const i in s){const c=u(s,i);"function"==typeof c&&null!==n&&(r[i]=o(t,n,c)),e.includes(c)&&(r[i]=l(null,n,c))}return r})(((e,t,n)=>{const{state:u,getters:s,_mutations:l,_actions:r}=e,i={useState:u[t],useGetters:s,useMutations:l,useActions:r};return Object.keys(i[n])})(t,s,e),t,s,l,r)}},a=(e=null,t,n)=>(e||(e=l()),function(...t){return e.commit(n,...t)}),d=(e=null,t,n)=>(e||(e=l()),function(...t){return e.dispatch(n,t)}),f=(e,t,n)=>(s(n),c.bind(null,f.name)(e,t,n,r)),m=(e,t,n)=>(s(n),c.bind(null,m.name)(e,t,n,i)),p=(e,t,n)=>(s(n),c.bind(null,p.name)(e,t,n,a)),b=(e,t,n)=>(s(n),c.bind(null,b.name)(e,t,n,d)),y=e=>({mapState:m.bind(null,e),mapGetters:f.bind(null,e),mapMutations:p.bind(null,e),mapActions:b.bind(null,e)});e.useVuex=e=>(e||(e=l()),{useState:m.bind(null,e),useGetters:f.bind(null,e),useMutations:p.bind(null,e),useActions:b.bind(null,e),getStoreFromInstance:l,createNamespacedHelpers:y}),Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@vueblocks/vue-use-vuex",
"description": "Use Vuex With Composition API Easily.",
"version": "0.1.5",
"version": "0.1.6",
"main": "lib/index.cjs.js",

@@ -39,3 +39,3 @@ "types": "lib/index.d.ts",

},
"gitHead": "ddef409f3770d9484a5755574c5ef94279587214"
"gitHead": "a3b871c1cb59c735b7998f72801c68e44623c959"
}