🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
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.9

16

lib/index.cjs.js
/*!
* @vueblocks/vue-use-vuex v0.1.8
* @vueblocks/vue-use-vuex v0.1.9
* (c) 2020 xiaoluoboding

@@ -13,2 +13,3 @@ * @license MIT

const isObject = (val) => toString.call(val) === '[object Object]';
const isString = (str) => typeof str === 'string';
const partial = (fn, ...partials) => (...args) => fn(...partials, ...args);

@@ -46,3 +47,3 @@

return (namespace, map) => {
if (typeof namespace !== 'string') {
if (!isString(namespace)) {
map = namespace;

@@ -206,5 +207,5 @@ namespace = '';

* Get $store from current instance
* @return {Store} ### vm.$store
* @return {Store} vm.$store
*/
const getStoreFromInstance = () => {
const useStore = () => {
const vm = vueDemi.getCurrentInstance();

@@ -219,7 +220,7 @@ if (!vm) {

* @param {String} namespace
* @param {Store} store ### vm.$store
* @param {Store} store vm.$store
*/
function useVuex(namespace, store) {
if (!store)
store = getStoreFromInstance();
store = useStore();
// pre-specify initial arguments with store instance

@@ -232,3 +233,3 @@ let helpers = {

};
if (arguments.length === 1 && namespace) {
if (arguments.length >= 1 && isString(namespace)) {
helpers = partial(createNamespacedHelpers, store)(namespace);

@@ -244,2 +245,3 @@ }

exports.useState = useState;
exports.useStore = useStore;
exports.useVuex = useVuex;

@@ -9,3 +9,3 @@ import { Store } from 'vuex';

*/
declare const useState: (store: any, namespace: string, states: Array<string> | object) => any;
declare const useState: (store: Store<any>, namespace: string, states: Array<string> | object) => object;
/**

@@ -17,3 +17,3 @@ * Reduce the code which written in Vue.js for committing the mutation

*/
declare const useMutations: (store: any, namespace: string, mutations: Array<string> | object) => any;
declare const useMutations: (store: any, namespace: string, mutations: Array<string> | object) => object;
/**

@@ -25,3 +25,3 @@ * Reduce the code which written in Vue.js for getting the getters

*/
declare const useGetters: (store: any, namespace: string, getters: Array<string> | object) => any;
declare const useGetters: (store: Store<any>, namespace: string, getters: Array<string> | object) => object;
/**

@@ -33,3 +33,3 @@ * Reduce the code which written in Vue.js for dispatch the action

*/
declare const useActions: (store: any, namespace: string, actions: Array<string> | object) => any;
declare const useActions: (store: any, namespace: string, actions: Array<string> | object) => object;
/**

@@ -40,3 +40,3 @@ * Rebinding namespace param for mapXXX function in special scoped, and return them by simple object

*/
declare const createNamespacedHelpers: (store: any, namespace: string) => {
declare const createNamespacedHelpers: (store: Store<any>, namespace: string) => {
useState: (...args: any[]) => any;

@@ -48,13 +48,18 @@ useGetters: (...args: any[]) => any;

/**
* Get $store from current instance
* @return {Store} vm.$store
*/
declare const useStore: () => Store<any>;
/**
* Use Vuex with composition api easily. Both support Vue2.x / Vue3.x
* @param {String} namespace
* @param {Store} store ### vm.$store
* @param {Store} store vm.$store
*/
declare function useVuex(namespace?: string, store?: Store<any>): {
useState: (namespace: string, map: object | string[]) => any;
useGetters: (namespace: string, map: object | string[]) => any;
useMutations: (namespace: string, map: object | string[]) => any;
useActions: (namespace: string, map: object | string[]) => any;
useState: (namespace?: any, map?: object | string[] | undefined) => object;
useGetters: (namespace?: any, map?: object | string[] | undefined) => object;
useMutations: (namespace?: any, map?: object | string[] | undefined) => object;
useActions: (namespace?: any, map?: object | string[] | undefined) => object;
};
export { createNamespacedHelpers, useActions, useGetters, useMutations, useState, useVuex };
export { createNamespacedHelpers, useActions, useGetters, useMutations, useState, useStore, useVuex };
/*!
* @vueblocks/vue-use-vuex v0.1.8
* @vueblocks/vue-use-vuex v0.1.9
* (c) 2020 xiaoluoboding
* @license MIT
*/
import { computed, isVue3, getCurrentInstance } from 'vue-demi';
import { computed, getCurrentInstance, isVue3 } from 'vue-demi';
const isObject = (val) => toString.call(val) === '[object Object]';
const isString = (str) => typeof str === 'string';
const partial = (fn, ...partials) => (...args) => fn(...partials, ...args);

@@ -41,3 +42,3 @@

return (namespace, map) => {
if (typeof namespace !== 'string') {
if (!isString(namespace)) {
map = namespace;

@@ -201,5 +202,5 @@ namespace = '';

* Get $store from current instance
* @return {Store} ### vm.$store
* @return {Store} vm.$store
*/
const getStoreFromInstance = () => {
const useStore = () => {
const vm = getCurrentInstance();

@@ -214,7 +215,7 @@ if (!vm) {

* @param {String} namespace
* @param {Store} store ### vm.$store
* @param {Store} store vm.$store
*/
function useVuex(namespace, store) {
if (!store)
store = getStoreFromInstance();
store = useStore();
// pre-specify initial arguments with store instance

@@ -227,3 +228,3 @@ let helpers = {

};
if (arguments.length === 1 && namespace) {
if (arguments.length >= 1 && isString(namespace)) {
helpers = partial(createNamespacedHelpers, store)(namespace);

@@ -234,2 +235,2 @@ }

export { createNamespacedHelpers, useActions, useGetters, useMutations, useState, useVuex };
export { createNamespacedHelpers, useActions, useGetters, useMutations, useState, useStore, useVuex };
/*!
* @vueblocks/vue-use-vuex v0.1.8
* @vueblocks/vue-use-vuex v0.1.9
* (c) 2020 xiaoluoboding

@@ -13,2 +13,3 @@ * @license MIT

const isObject = (val) => toString.call(val) === '[object Object]';
const isString = (str) => typeof str === 'string';
const partial = (fn, ...partials) => (...args) => fn(...partials, ...args);

@@ -46,3 +47,3 @@

return (namespace, map) => {
if (typeof namespace !== 'string') {
if (!isString(namespace)) {
map = namespace;

@@ -206,5 +207,5 @@ namespace = '';

* Get $store from current instance
* @return {Store} ### vm.$store
* @return {Store} vm.$store
*/
const getStoreFromInstance = () => {
const useStore = () => {
const vm = vueDemi.getCurrentInstance();

@@ -219,7 +220,7 @@ if (!vm) {

* @param {String} namespace
* @param {Store} store ### vm.$store
* @param {Store} store vm.$store
*/
function useVuex(namespace, store) {
if (!store)
store = getStoreFromInstance();
store = useStore();
// pre-specify initial arguments with store instance

@@ -232,3 +233,3 @@ let helpers = {

};
if (arguments.length === 1 && namespace) {
if (arguments.length >= 1 && isString(namespace)) {
helpers = partial(createNamespacedHelpers, store)(namespace);

@@ -244,2 +245,3 @@ }

exports.useState = useState;
exports.useStore = useStore;
exports.useVuex = useVuex;

@@ -246,0 +248,0 @@

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VueUseVuex={},t.VueDemi)}(this,(function(t,e){"use strict";const n=(t,...e)=>(...n)=>t(...e,...n);function r(t){return Array.isArray(t)||(e=t,"[object Object]"===toString.call(e));var e}function o(t){return r(t)?Array.isArray(t)?t.map((t=>({key:t,val:t}))):Object.keys(t).map((e=>({key:e,val:t[e]}))):[]}function u(t){return(e,n)=>("string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n))}function s(t,e,n){return t._modulesNamespaceMap[n]}const c=(t,n,r)=>{const u={};return o(r).forEach((({key:r,val:o})=>{u[r]=e.computed((function(){let e=t.state,r=t.getters;if(n){const o=s(t,0,n);if(!o)return;e=o.context.state,r=o.context.getters}return"function"==typeof o?o(e,r):e[o]}))})),u},i=(t,e,n)=>{const r={};return o(n).forEach((({key:n,val:o})=>{r[n]=function(...n){let r=t.commit;if(e){const n=s(t,0,e);if(!n)return;r=n.context.commit}return"function"==typeof o?o.apply(this,[r].concat(n)):r.apply(t,[o].concat(n))}})),r},a=(t,n,r)=>{const u={};return o(r).forEach((({key:r,val:o})=>{o=n+o,u[r]=e.computed((function(){if(!n||s(t,0,n))return t.getters[o]}))})),u},f=(t,e,n)=>{const r={};return o(n).forEach((({key:n,val:o})=>{r[n]=function(...n){let r=t.dispatch;if(e){const n=s(t,0,e);if(!n)return;r=n.context.dispatch}return"function"==typeof o?o.apply(this,[r].concat(n)):r.apply(t,[o].concat(n))}})),r},p=(t,e)=>({useState:n(u(n(c,t)),e),useGetters:n(u(n(a,t)),e),useMutations:n(u(n(i,t)),e),useActions:n(u(n(f,t)),e)}),l=()=>{const t=e.getCurrentInstance();return e.isVue3?t.ctx.$store:t.$store};t.createNamespacedHelpers=p,t.useActions=f,t.useGetters=a,t.useMutations=i,t.useState=c,t.useVuex=function(t,e){e||(e=l());let r={useState:u(n(c,e)),useGetters:u(n(a,e)),useMutations:u(n(i,e)),useActions:u(n(f,e))};return 1===arguments.length&&t&&(r=n(p,e)(t)),r},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VueUseVuex={},t.VueDemi)}(this,(function(t,e){"use strict";const n=t=>"string"==typeof t,r=(t,...e)=>(...n)=>t(...e,...n);function o(t){return Array.isArray(t)||(e=t,"[object Object]"===toString.call(e));var e}function u(t){return o(t)?Array.isArray(t)?t.map((t=>({key:t,val:t}))):Object.keys(t).map((e=>({key:e,val:t[e]}))):[]}function s(t){return(e,r)=>(n(e)?"/"!==e.charAt(e.length-1)&&(e+="/"):(r=e,e=""),t(e,r))}function c(t,e,n){return t._modulesNamespaceMap[n]}const i=(t,n,r)=>{const o={};return u(r).forEach((({key:r,val:u})=>{o[r]=e.computed((function(){let e=t.state,r=t.getters;if(n){const o=c(t,0,n);if(!o)return;e=o.context.state,r=o.context.getters}return"function"==typeof u?u(e,r):e[u]}))})),o},a=(t,e,n)=>{const r={};return u(n).forEach((({key:n,val:o})=>{r[n]=function(...n){let r=t.commit;if(e){const n=c(t,0,e);if(!n)return;r=n.context.commit}return"function"==typeof o?o.apply(this,[r].concat(n)):r.apply(t,[o].concat(n))}})),r},f=(t,n,r)=>{const o={};return u(r).forEach((({key:r,val:u})=>{u=n+u,o[r]=e.computed((function(){if(!n||c(t,0,n))return t.getters[u]}))})),o},p=(t,e,n)=>{const r={};return u(n).forEach((({key:n,val:o})=>{r[n]=function(...n){let r=t.dispatch;if(e){const n=c(t,0,e);if(!n)return;r=n.context.dispatch}return"function"==typeof o?o.apply(this,[r].concat(n)):r.apply(t,[o].concat(n))}})),r},l=(t,e)=>({useState:r(s(r(i,t)),e),useGetters:r(s(r(f,t)),e),useMutations:r(s(r(a,t)),e),useActions:r(s(r(p,t)),e)}),y=()=>{const t=e.getCurrentInstance();return e.isVue3?t.ctx.$store:t.$store};t.createNamespacedHelpers=l,t.useActions=p,t.useGetters=f,t.useMutations=a,t.useState=i,t.useStore=y,t.useVuex=function(t,e){e||(e=y());let o={useState:s(r(i,e)),useGetters:s(r(f,e)),useMutations:s(r(a,e)),useActions:s(r(p,e))};return arguments.length>=1&&n(t)&&(o=r(l,e)(t)),o},Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@vueblocks/vue-use-vuex",
"description": "Use Vuex With Composition API Easily.",
"version": "0.1.8",
"version": "0.1.9",
"main": "lib/index.cjs.js",

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

},
"gitHead": "cc5e359b72aeb8372b6c5b76d091549b30a8ce1e"
"gitHead": "612d1ef72a37afdc32d513d5b622db07fde2ca29"
}

@@ -21,2 +21,4 @@ # @vueblocks/vue-use-vuex

### useVuex
`useVuex` utilities just similar with [Vuex Component Binding Helpers](https://vuex.vuejs.org/api/#component-binding-helpers)

@@ -36,2 +38,6 @@

### useStore
`useStore` utilities just do the same thing with Vuex 4.x composition api [useStore](https://next.vuex.vuejs.org/guide/composition-api.html)
It seems familiar right?

@@ -43,2 +49,7 @@

/**
* Get $store from current instance
* @return {Store} vm.$store
*/
declare const useStore: () => Store<any>;
/**
* Use Vuex with composition api easily. Both support Vue2.x / Vue3.x

@@ -45,0 +56,0 @@ * @param {String} namespace