vue-use-async 1.4.5 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ComputedRef, Ref } from 'vue';
2
- import cache, { cacheSize, clearCache, cacheIds } from './cache';
2
+ import cache, { cacheIds, cacheSize, clearCache } from './cache';
3
3
  import Deferred from './Deferred';
4
4
  import useAsync from './useAsync';
5
5
  import useMutation from './useMutation';
@@ -0,0 +1,90 @@
1
+ import Deferred from '../src/Deferred';
2
+ declare type Condition = Partial<{
3
+ method: string;
4
+ url: string;
5
+ params: {
6
+ [id: string]: any;
7
+ };
8
+ getAttribute: (arg0: string) => any;
9
+ }>;
10
+ declare class MockXhr {
11
+ header: Array<any>;
12
+ xhr: null | XMLHttpRequest;
13
+ method: null | string;
14
+ pending: Deferred<any>;
15
+ constructor();
16
+ get(condition: Condition): {
17
+ context: MockXhr;
18
+ abort: () => void;
19
+ resolve: (fakeResult: any, delay?: number) => void;
20
+ reject: (fakeResult: any, delay?: number) => void;
21
+ };
22
+ post(condition: Condition): {
23
+ context: MockXhr;
24
+ abort: () => void;
25
+ resolve: (fakeResult: any, delay?: number) => void;
26
+ reject: (fakeResult: any, delay?: number) => void;
27
+ };
28
+ delete(condition: Condition): {
29
+ context: MockXhr;
30
+ abort: () => void;
31
+ resolve: (fakeResult: any, delay?: number) => void;
32
+ reject: (fakeResult: any, delay?: number) => void;
33
+ };
34
+ put(condition: Condition): {
35
+ context: MockXhr;
36
+ abort: () => void;
37
+ resolve: (fakeResult: any, delay?: number) => void;
38
+ reject: (fakeResult: any, delay?: number) => void;
39
+ };
40
+ sendForm(form: Condition): {
41
+ context: MockXhr;
42
+ abort: () => void;
43
+ resolve: (fakeResult: any, delay?: number) => void;
44
+ reject: (fakeResult: any, delay?: number) => void;
45
+ };
46
+ abort(fakeResult: any): void;
47
+ resolve(fakeResult: any, delay?: number): void;
48
+ reject(fakeResult: any, delay?: number): void;
49
+ static restore(): void;
50
+ _mockXMLHttpRequest(this: MockXhr, condition: Condition): {
51
+ context: MockXhr;
52
+ abort: () => void;
53
+ resolve: (fakeResult: any, delay?: number) => void;
54
+ reject: (fakeResult: any, delay?: number) => void;
55
+ };
56
+ }
57
+ export default function mockXhr(): {
58
+ get(condition: Condition): {
59
+ context: MockXhr;
60
+ abort: () => void;
61
+ resolve: (fakeResult: any, delay?: number) => void;
62
+ reject: (fakeResult: any, delay?: number) => void;
63
+ };
64
+ post(condition: Condition): {
65
+ context: MockXhr;
66
+ abort: () => void;
67
+ resolve: (fakeResult: any, delay?: number) => void;
68
+ reject: (fakeResult: any, delay?: number) => void;
69
+ };
70
+ delete(condition: Condition): {
71
+ context: MockXhr;
72
+ abort: () => void;
73
+ resolve: (fakeResult: any, delay?: number) => void;
74
+ reject: (fakeResult: any, delay?: number) => void;
75
+ };
76
+ put(condition: Condition): {
77
+ context: MockXhr;
78
+ abort: () => void;
79
+ resolve: (fakeResult: any, delay?: number) => void;
80
+ reject: (fakeResult: any, delay?: number) => void;
81
+ };
82
+ sendForm(condition: Condition): {
83
+ context: MockXhr;
84
+ abort: () => void;
85
+ resolve: (fakeResult: any, delay?: number) => void;
86
+ reject: (fakeResult: any, delay?: number) => void;
87
+ };
88
+ restore(): void;
89
+ };
90
+ export {};
@@ -0,0 +1,2 @@
1
+ import mockXhr from './mockXhr';
2
+ export { mockXhr, };
package/dist/tests.js ADDED
@@ -0,0 +1 @@
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{mockXhr:()=>E});function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=n((function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"resolve",void 0),o(this,"reject",void 0),o(this,"promise",void 0),o(this,"done",!1),this.resolve=function(){throw Error("Can t resolve")},this.reject=function(){throw Error("Can t reject")},this.promise=new Promise((function(e,r){t.resolve=e,t.reject=r})),this.promise.finally((function(){t.done=!0}))}));function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}function h(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var p=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),d(this,"onError",(function(){})),d(this,"onStart",(function(){})),d(this,"onAbort",(function(){})),d(this,"onProgress",(function(){})),d(this,"onEnd",(function(){})),d(this,"token",null),d(this,"url",""),d(this,"params",{}),d(this,"sendAs","json"),d(this,"timeout",1e4),d(this,"port",80),d(this,"responseType","text"),d(this,"isPending",!1),d(this,"_eventsReady",void 0),d(this,"_oXHR",void 0),d(this,"_onEnd",(function(){})),d(this,"_onError",(function(){})),d(this,"_deferred",void 0),d(this,"_isXhrResolved",void 0),d(this,"_isXhrRejected",void 0),d(this,"_eventReady",void 0),this._eventsReady=!1,this._constructor(t||{},r)}var t,r,n;return t=e,r=[{key:"_getUrl",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.onBeforeSendList.reduce((function(e,t){return t(e||{})}),t);return e.stringifyUrl(this.url,r)}},{key:"removeEvents",value:function(){var e=this,t=function(){e._oXHR.removeEventListener("load",e._onEnd,!1),e._oXHR.removeEventListener("error",e._onError,!1),e._oXHR.removeEventListener("timeout",e._onError,!1),e._oXHR.removeEventListener("loadstart",e.onStart,!1),e._oXHR.removeEventListener("abort",e.onAbort,!1),e._oXHR.upload.removeEventListener("progress",e.onProgress,!1),e._oXHR.removeEventListener("progress",e.onProgress,!1)};this._deferred.promise.then(t,t)}},{key:"post",value:function(e){return this._constructor(e),this._oXHR.open("POST",this._getUrl(),!0),this._send(),this._deferred.promise}},{key:"put",value:function(e){return this._constructor(e),this._oXHR.open("PUT",this._getUrl(),!0),this._send(),this._deferred.promise}},{key:"get",value:function(e){this._constructor(e||{}),this._oXHR.open("GET",this._getUrl("multipart"===this.sendAs?{}:this.params),!0),this._send();var t=this._deferred.promise;return t.abortXhr=this.abort.bind(this),t}},{key:"delete",value:function(e){return this._constructor(e),this._oXHR.open("DELETE",this._getUrl(this.params),!0),this._send(),this._deferred.promise}},{key:"abort",value:function(){return this._isXhrResolved&&!this._isXhrRejected||(this._oXHR.abort(null,this),this._isXhrRejected=!0,this._deferred.reject({error:"Xhr aborted: ".concat(this.url),code:"HTTP-ABORTED"})),this._deferred.promise}},{key:"resolve",value:function(e){return this._deferred.resolve(e),this._deferred.promise}},{key:"reject",value:function(e){return this._deferred.reject(e),this._deferred.promise}},{key:"_setEvents",value:function(e){this._eventsReady||(this._eventReady=!0,e.addEventListener("load",this._onEnd,!1),e.addEventListener("error",this._onError,!1),e.addEventListener("timeout",this._onError,!1),e.addEventListener("loadstart",this.onStart,!1),e.addEventListener("abort",this.onAbort,!1),e.upload.addEventListener("progress",this.onProgress,!1),e.addEventListener("progress",this.onProgress,!1))}},{key:"_send",value:function(){var t;this.isPending=!0,"multipart"===this.sendAs?t=e.getFormData(this.params):"json"===this.sendAs&&(this._oXHR.setRequestHeader("content-type","application/json; charset=utf-8"),t=JSON.stringify(this.params)),this.token&&this._oXHR.setRequestHeader("Authorization","Bearer ".concat(this.token)),this._oXHR.send(t,this)}},{key:"_constructor",value:function(t,r){var n=this;t&&"object"===l(t)?(this.sendAs=t.sendAs||this.sendAs,this.url=t.url||this.url,this.port=t.port||this.port,this.params=t.params||this.params,this.timeout=t.timeout||this.timeout,this.responseType=t.responseType||this.responseType,this.onProgress=(t.onProgress||this.onProgress).bind(this),this.onStart=(t.onStart||this.onStart).bind(this),this.onAbort=(t.onAbort||this.onAbort).bind(this),this.onEnd=(t.onEnd||this.onEnd).bind(this),this.onError=(t.onError||this.onError).bind(this),this.token=t.token||this.token):t&&"string"==typeof t&&(this.url=t,this.params=r||this.params),80!==this.port&&(this.url="".concat(window.location.protocol,"//").concat(window.location.hostname,":").concat(this.port).concat(this.url)),this._deferred=new i,this._deferred.promise.finally((function(){n.isPending=!1})),this._oXHR=new XMLHttpRequest,this._oXHR.timeout=this.timeout,this._oXHR.responseType=this.responseType,this._isXhrResolved=!1,this._isXhrRejected=!1;var o=e._injectParamsInUrl(this.url,this.params),s=o.url,a=o.params;this.url=s,this.params=a,this._onError=function(e){n.onError(e),n.removeEvents(),n._deferred.reject(e)},this._onEnd=function(t){var r=e.parseResult(n._oXHR);return n._oXHR.status>=400?(n._isXhrRejected=!0,n._onError(r),n._deferred.reject(r)):(n.onEnd(r,t),n._isXhrResolved=!0,n.removeEvents(),n.resolve(r))},this._setEvents(this._oXHR)}}],n=[{key:"parseResult",value:function(e){var t=e.response;try{var r=e.getResponseHeader("Content-Type");r&&r.toLowerCase().indexOf("json")>-1&&(t=JSON.parse(e.response))}catch(r){t=e.response}return t}},{key:"onBeforeSend",value:function(t){e.onBeforeSendList.push(t)}},{key:"new",value:function(t){return new e(t)}},{key:"stringifyUrl",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e._injectParamsInUrl(t,r);t=n.url,r=n.params;var o=t.indexOf("?")>-1?"&":"?",i="";return Object.getOwnPropertyNames(r).filter((function(e){return void 0!==r[e]})).forEach((function(e){i+="".concat(o).concat(e,"=").concat(encodeURIComponent(JSON.stringify(r[e]))),o="&"})),(t=t.replace(/\/:[^/]*/gi,""))+i}},{key:"getFormData",value:function(e){var t,r=new FormData;return Object.keys(e).forEach((function(n){if(e[n]instanceof FileList)for(var o=0;o<e[n].length;o+=1)r.append(n,e[n][o]);else e[n]instanceof File?r.append(n,e[n]):("object"!==l(t=e[n])&&!Array.isArray(t)||null===t||(t=JSON.stringify(t)),r.append(n,t))})),r}},{key:"_injectParamsInUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Array.isArray(t))return{url:e,params:t};var r={},n=decodeURIComponent(e),o=n.indexOf("?"),i=(!0).toString(),s=(!1).toString();o>-1&&(n.split("?")[1].split("&").reduce((function(e,t){var r=u(t.split("="),2),n=r[0],o=u(r[1].match(/^(?:"?([^"]+)"?)$/)||[],2)[1];if(o===i||o===s)e[n]=o===i;else{var a=Number(o);e[n]=""===o||Number.isNaN(a)?o:a}return e}),r),n=n.substring(0,o));var c=Object.getOwnPropertyNames(t).reduce((function(e,r){return e[r]=t[r],e}),a({},r));((n=n.replace(/#/,"%23")).match(/:[a-z0-9]+/gi)||[]).forEach((function(e){e=e.substring(1),void 0!==c[e]&&(n=n.replace(":".concat(e),null===c[e]||""===c[e]?"null":c[e]),delete c[e])})),Object.keys(c).forEach((function(e){void 0!==r[e]&&(r[e]=c[e],delete c[e])}));var l=Object.keys(r);if(l.length){var h="?";l.forEach((function(e){if(!0===r[e]||!1===r[e])n+="".concat(h).concat(e,"=").concat(r[e]);else if(null===r[e])n+="".concat(h).concat(e,"=").concat(r[e]);else{var t=Number(r[e]),o=Number.isNaN(t)?encodeURIComponent('"'.concat(r[e],'"')):t;n+="".concat(h).concat(e,"=").concat(o)}h="&"}))}return{url:n,params:c}}}],r&&h(t.prototype,r),n&&h(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function v(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}d(p,"onBeforeSendList",[]);var y=XMLHttpRequest.prototype,m=y.send,b=y.abort,_=y.open,g=y.setRequestHeader,R=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),v(this,"header",void 0),v(this,"xhr",void 0),v(this,"method",void 0),v(this,"pending",void 0),this.header=[],this.xhr=null,this.method=null,this.pending=new i}var t,r,n;return t=e,r=[{key:"get",value:function(e){return e.method="GET",this._mockXMLHttpRequest(e)}},{key:"post",value:function(e){return e.method="POST",this._mockXMLHttpRequest(e)}},{key:"delete",value:function(e){return e.method="DELETE",this._mockXMLHttpRequest(e)}},{key:"put",value:function(e){return e.method="PUT",this._mockXMLHttpRequest(e)}},{key:"sendForm",value:function(e){var t,r,n={method:null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"method"),url:null==e||null===(r=e.getAttribute)||void 0===r?void 0:r.call(e,"action")};return this._mockXMLHttpRequest(n)}},{key:"abort",value:function(t){var r=this;XMLHttpRequest.prototype.abort=function(){r.pending.promise.catch((function(e){return e.resolve(t)})).then(e.restore)}}},{key:"resolve",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.pending.promise.then((function(r){setTimeout((function(){r.resolve(e)}),t)}))}},{key:"reject",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.pending.promise.then((function(r){setTimeout((function(){r.reject(e)}),t)}))}},{key:"_mockXMLHttpRequest",value:function(e){var t=arguments,r=this;return XMLHttpRequest.prototype.open=function(n,o){o===("GET"===e.method?p.stringifyUrl(e.url||"",e.params):e.url)&&e.method===n?r.method=n:_.apply(r,t)},XMLHttpRequest.prototype.send=function(n,o){p.stringifyUrl(e.url||"",e.params)&&r.method===e.method?(r.xhr=o,r.pending.resolve(o)):m.apply(r,t)},XMLHttpRequest.prototype.setRequestHeader=function(e,t){r.header.push([e,t])},{context:this,abort:this.abort.bind(this,e),resolve:this.resolve.bind(this),reject:this.reject.bind(this)}}}],n=[{key:"restore",value:function(){XMLHttpRequest.prototype.abort=b,XMLHttpRequest.prototype.send=m,XMLHttpRequest.prototype.open=_,XMLHttpRequest.prototype.setRequestHeader=g}}],r&&f(t.prototype,r),n&&f(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function E(){return{get:function(e){return(new R).get(e)},post:function(e){return(new R).post(e)},delete:function(e){return(new R).delete(e)},put:function(e){return(new R).put(e)},sendForm:function(e){return(new R).sendForm(e)},restore:function(){R.restore()}}}return t})()));
@@ -1,8 +1,8 @@
1
1
  import { ComputedRef, Ref } from 'vue';
2
2
  import type { Obj, UnwrappedPromiseType } from './index';
3
- declare type OnErrorCb = (e: null | Error, params: any) => any;
4
- declare type OnStartCb = (params: any) => any;
5
- declare type OnEndCb<T> = (res: T, params: any) => any;
3
+ declare type OnErrorCb<T> = (e: null | Error, params: T) => unknown;
4
+ declare type OnStartCb<T> = (params: T) => unknown;
5
+ declare type OnEndCb<T, Z> = (res: T, params: Z) => unknown;
6
6
  declare type Params<Z, A extends unknown[]> = (() => (Z | [...A])) | ComputedRef<Z | [...A]> | Ref<Z | [...A]> | Z | [
7
7
  ...A
8
8
  ];
@@ -11,10 +11,10 @@ export default function useAsync<T, Z extends TypeAllowed, A extends TypeAllowed
11
11
  isPending: Ref<undefined | boolean>;
12
12
  data: Ref<undefined | null | UnwrappedPromiseType<typeof func>>;
13
13
  error: Ref<null | Error>;
14
- reload: () => any;
15
- onError: (cb: OnErrorCb) => any;
16
- onStart: (cb: OnStartCb) => any;
17
- onEnd: (cb: OnEndCb<UnwrappedPromiseType<typeof func>>) => any;
14
+ reload: () => unknown;
15
+ onError: (cb: OnErrorCb<Params<Z, A>>) => unknown;
16
+ onStart: (cb: OnStartCb<Params<Z, A>>) => unknown;
17
+ onEnd: (cb: OnEndCb<UnwrappedPromiseType<typeof func>, Params<Z, A>>) => unknown;
18
18
  promise: ComputedRef<null | ReturnType<typeof func>>;
19
19
  };
20
20
  export {};
package/dist/useXhr.d.ts CHANGED
@@ -23,10 +23,10 @@ export default function (args?: UseXhr): {
23
23
  isPending: Ref<boolean | undefined>;
24
24
  data: Ref<T_1 | null | undefined>;
25
25
  error: Ref<Error | null>;
26
- reload: () => any;
27
- onError: (cb: (e: Error | null, params: any) => any) => any;
28
- onStart: (cb: (params: any) => any) => any;
29
- onEnd: (cb: (res: T_1, params: any) => any) => any;
26
+ reload: () => unknown;
27
+ onError: (cb: (e: Error | null, params: [] | Obj | ComputedRef<[] | Obj> | Ref<[] | Obj> | (() => [] | Obj)) => unknown) => unknown;
28
+ onStart: (cb: (params: [] | Obj | ComputedRef<[] | Obj> | Ref<[] | Obj> | (() => [] | Obj)) => unknown) => unknown;
29
+ onEnd: (cb: (res: T_1, params: [] | Obj | ComputedRef<[] | Obj> | Ref<[] | Obj> | (() => [] | Obj)) => unknown) => unknown;
30
30
  promise: ComputedRef<Promise<T_1> | null>;
31
31
  };
32
32
  put: <T_2 = any>(xhrConfig?: XhrConfig, params?: Obj | Ref<Obj>) => {
@@ -34,10 +34,10 @@ export default function (args?: UseXhr): {
34
34
  isPending: Ref<boolean | undefined>;
35
35
  data: Ref<T_2 | null | undefined>;
36
36
  error: Ref<Error | null>;
37
- reload: () => any;
38
- onError: (cb: (e: Error | null, params: any) => any) => any;
39
- onStart: (cb: (params: any) => any) => any;
40
- onEnd: (cb: (res: T_2, params: any) => any) => any;
37
+ reload: () => unknown;
38
+ onError: (cb: (e: Error | null, params: [] | Obj | ComputedRef<[] | Obj> | Ref<[] | Obj> | (() => [] | Obj)) => unknown) => unknown;
39
+ onStart: (cb: (params: [] | Obj | ComputedRef<[] | Obj> | Ref<[] | Obj> | (() => [] | Obj)) => unknown) => unknown;
40
+ onEnd: (cb: (res: T_2, params: [] | Obj | ComputedRef<[] | Obj> | Ref<[] | Obj> | (() => [] | Obj)) => unknown) => unknown;
41
41
  promise: ComputedRef<Promise<T_2> | null>;
42
42
  };
43
43
  delete: <T_3 = any>(xhrConfig?: XhrConfig, params?: Obj | Ref<Obj>) => {
@@ -45,10 +45,10 @@ export default function (args?: UseXhr): {
45
45
  isPending: Ref<boolean | undefined>;
46
46
  data: Ref<any>;
47
47
  error: Ref<Error | null>;
48
- reload: () => any;
49
- onError: (cb: (e: Error | null, params: any) => any) => any;
50
- onStart: (cb: (params: any) => any) => any;
51
- onEnd: (cb: (res: any, params: any) => any) => any;
48
+ reload: () => unknown;
49
+ onError: (cb: (e: Error | null, params: [] | Obj | ComputedRef<[] | Obj> | Ref<[] | Obj> | (() => [] | Obj)) => unknown) => unknown;
50
+ onStart: (cb: (params: [] | Obj | ComputedRef<[] | Obj> | Ref<[] | Obj> | (() => [] | Obj)) => unknown) => unknown;
51
+ onEnd: (cb: (res: any, params: [] | Obj | ComputedRef<[] | Obj> | Ref<[] | Obj> | (() => [] | Obj)) => unknown) => unknown;
52
52
  promise: ComputedRef<Promise<any> | null>;
53
53
  };
54
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-use-async",
3
- "version": "1.4.5",
3
+ "version": "1.5.0",
4
4
  "description": "Xhr and async helpers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,8 +12,8 @@
12
12
  "types": "./dist/index.d.ts",
13
13
  "scripts": {
14
14
  "prepare": "husky install",
15
- "beforebuild": "node ./scripts/beforeBuild.js && npm run tsc:export-types",
16
- "afterbuild": "node ./scripts/afterbuild.js",
15
+ "beforebuild": "node ./scripts/beforeBuild.cjs && npm run tsc:export-types",
16
+ "afterbuild": "node ./scripts/afterbuild.cjs",
17
17
  "build": "npm run beforebuild && npm run build:webpack && npm run afterbuild",
18
18
  "build:webpack": "webpack --mode=production",
19
19
  "lint": "npm run tsc:check-types && eslint --ext .js,.ts src tests",
@@ -32,22 +32,22 @@
32
32
  "@babel/plugin-proposal-class-properties": "^7.18.6",
33
33
  "@babel/preset-env": "^7.18.10",
34
34
  "@babel/preset-typescript": "^7.18.6",
35
- "@types/jest": "^28.1.7",
36
- "@typescript-eslint/eslint-plugin": "^5.33.1",
37
- "@typescript-eslint/parser": "^5.33.1",
35
+ "@types/jest": "^28.1.8",
36
+ "@typescript-eslint/eslint-plugin": "^5.35.1",
37
+ "@typescript-eslint/parser": "^5.35.1",
38
38
  "babel-eslint": "^10.1.0",
39
- "babel-jest": "^28.1.3",
39
+ "babel-jest": "^29.0.1",
40
40
  "babel-loader": "^8.2.5",
41
41
  "babel-plugin-module-resolver": "^4.1.0",
42
- "eslint": "^8.22.0",
42
+ "eslint": "~8.22.0",
43
43
  "eslint-config-airbnb-base": "^15.0.0",
44
- "eslint-import-resolver-typescript": "^3.4.1",
44
+ "eslint-import-resolver-typescript": "^3.5.0",
45
45
  "eslint-plugin-import": "^2.26.0",
46
46
  "husky": "^8.0.1",
47
- "jest": "^28.1.3",
48
- "jest-environment-jsdom": "^28.1.3",
47
+ "jest": "^29.0.1",
48
+ "jest-environment-jsdom": "^29.0.1",
49
49
  "lint-staged": "^13.0.3",
50
- "typescript": "^4.7.4",
50
+ "typescript": "~4.7.4",
51
51
  "vue": "^3.2.37",
52
52
  "webpack": "^5.74.0",
53
53
  "webpack-cli": "^4.10.0"