diff --git a/index.js b/index.js index 3805fa5..cb833fd 100644 --- a/index.js +++ b/index.js @@ -1,22 +1,30 @@ import { reactive } from "vue"; class Wait { - list = reactive({}); - is = (name) => !!this.list[name]; - start = (name) => !this.list[name] && (this.list[name] = Date.now()); - end = (name) => { + constructor() { + this.list = reactive({}); + } + is(name) { + return !!this.list[name]; + } + start(name) { + return !this.list[name] && (this.list[name] = Date.now()); + } + end(name) { const start = this.list[name]; delete this.list[name]; return Date.now() - start; - }; - any = () => Object.keys(this.list).length; - clear = () => { + } + any() { + return Object.keys(this.list).length; + } + clear() { let clearList = {}; Object.keys(this.list).forEach((item) => { clearList[item] = this.end(item); }); return clearList; - }; + } } export const $wait = new Wait(); diff --git a/package.json b/package.json index 156bfa3..04f6dc1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@meforma/vue-wait-for", - "version": "0.0.1", + "version": "0.0.2", "description": "A loader manager for vuejs 3 with reactive method", "main": "index.js", "scripts": {