Comparing version 0.3.0 to 0.3.1
import { watch as w, inject as inj, reactive, computed, } from 'vue'; | ||
import { deepCopy } from './util'; | ||
import { copy } from './util'; | ||
/** | ||
@@ -25,7 +25,7 @@ * Define store | ||
let _unsubscribes = []; | ||
const _getters = (getters ? computed(() => deepCopy(getters(modules))) : undefined); | ||
const _getters = (getters ? computed(() => copy(getters(modules))) : undefined); | ||
function on(mapper) { | ||
let _predicate = null; | ||
function trigger(action, options) { | ||
const target = () => deepCopy(mapper({ modules: _store, getters: _getters })); | ||
const target = () => copy(mapper({ modules: _store, getters: _getters })); | ||
const unwatch = w(target, async (newer, older, cleanUp) => { | ||
@@ -62,3 +62,3 @@ if (_predicate && !_predicate(newer, older)) | ||
function watch(effect, options) { | ||
const target = () => deepCopy(mapper({ modules: _store, getters: _getters })); | ||
const target = () => copy(mapper({ modules: _store, getters: _getters })); | ||
const unwatch = w(target, effect, options); | ||
@@ -144,2 +144,3 @@ _unsubscribes.push(unwatch); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function inject(key, type, name) { | ||
@@ -146,0 +147,0 @@ if (type === 'module' && name) { |
@@ -5,6 +5,6 @@ import { Ref, ComputedRef } from 'vue'; | ||
}[keyof T]; | ||
export declare type Action<T> = Pick<T, PickKeysByType<T, Function>>; | ||
export declare type State<T> = Omit<T, PickKeysByType<T, Function>>; | ||
export declare type Action<T> = Pick<T, PickKeysByType<T, (...args: any[]) => any>>; | ||
export declare type State<T> = Omit<T, PickKeysByType<T, (...args: any[]) => any>>; | ||
export declare type Module = Record<string, unknown>; | ||
export declare type Unref<T> = T extends Ref<infer V> ? V : T extends ComputedRef<infer R> ? R : T; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
export declare function deepCopy<T>(target: T): T; | ||
export declare function copy<T>(target: T): T; |
@@ -1,2 +0,2 @@ | ||
export function deepCopy(target) { | ||
export function copy(target) { | ||
if (typeof target === 'undefined' || typeof target === 'symbol') { | ||
@@ -15,7 +15,6 @@ return target; | ||
if (target instanceof Array) { | ||
return target.map((it) => deepCopy(it)); | ||
return target.map((it) => copy(it)); | ||
} | ||
const newObject = { ...target }; | ||
return newObject; | ||
return { ...target }; | ||
} | ||
//# sourceMappingURL=util.js.map |
{ | ||
"name": "svore", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "stare management by composition-api", | ||
@@ -9,2 +9,4 @@ "main": "lib/index.js", | ||
"build": "tsc", | ||
"lint": "eslint --ext ./src/*.ts", | ||
"format": "prettier -w ./src", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -24,6 +26,7 @@ }, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.26.1", | ||
"@typescript-eslint/parser": "^4.26.1", | ||
"@typescript-eslint/eslint-plugin": "^4.28.1", | ||
"@typescript-eslint/parser": "^4.28.1", | ||
"eslint": "^7.28.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-jest": "^24.3.6", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
@@ -30,0 +33,0 @@ "eslint-plugin-vue": "^7.11.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19985
11