UNPKG

@18ys/god

Version:

prefer to a global Object that can set some data to it, because vue3 don't have the global Object Vue.

48 lines (32 loc) 961 B
## What is God? God is a global target, you can set some data to it, to resolve that vue3 don't have the global Vue. ## Installation ### Node.js $ npm install @18ys/god ## Module umd ## Usage ```js import { give, ask, clean } from '@18ys/god'; // for example: set axios instance to god // give one time at a file with js let instance = axios.createInstance(); give('axios', instance, { readonly: true }); // use Infinity times at any file with js let axiosInstance = ask('axios'); axiosInstance.get('http://example.com/getData').then(..) // when you couldn't use some keys, clean it. clean('axios'); ask('axios'); // null ``` ## Api ```js import god from '@18ys/god'; // 1. set god.give(key: string, value: any, options?: { readonly?: boolean }); // readonly default is false, when you set readonly as true, the key is can't be cleaned // 2. get god.ask(key: string) // return (value: any | null) // 3. remove god.clean(key: string) ```