tools_dj 1.0.71 → 1.0.73

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/lib/request.d.ts CHANGED
@@ -2,6 +2,7 @@ interface conf {
2
2
  baseUrl?: string;
3
3
  timeout?: number;
4
4
  callback?: any;
5
+ errBack?: any;
5
6
  abController?: any;
6
7
  }
7
8
  /** 2025/3/31 15:54 User: DJ
package/lib/request.js CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0});const t=require("./index");exports.default=class{constructor(t={},e={}){this.options={},this.conf={baseUrl:"",timeout:6e3},this.options=t,Object.assign(this.conf,e)}serve(e="",o={},c={}){const s=(0,t.mergeObj)([this.conf,c]);const n=(0,t.mergeObj)([this.options,o],{callback:function(t){if(t)return t()},callType:"Function"}),{timeout:l=6e3,baseUrl:r}=s;e=r+e;const a=new AbortController,i=a.signal;s.abController&&s.abController(a);const b=setTimeout((()=>{a.abort()}),l);return fetch(e,Object.assign(Object.assign({},n),{signal:i})).then((t=>(clearTimeout(b),s.callback?s.callback(t):t))).catch((t=>{throw s.callback&&s.callback(t),clearTimeout(b),t}))}};
1
+ Object.defineProperty(exports,"__esModule",{value:!0});const e=require("./index");exports.default=class{constructor(e={},t={}){this.options={},this.conf={baseUrl:"",timeout:6e3},this.options=e,Object.assign(this.conf,t)}serve(t="",o={},r={}){const s=(0,e.mergeObj)([this.conf,r]);const c=(0,e.mergeObj)([this.options,o],{callback:function(e){if(e)return e()},callType:"Function"}),{timeout:n=6e3,baseUrl:a}=s;t=a+t;const i=new AbortController,l=i.signal;s.abController&&s.abController(i);const b=setTimeout((()=>{i.abort()}),n);return fetch(t,Object.assign(Object.assign({},c),{signal:l})).then((e=>(clearTimeout(b),s.callback?s.callback(e):e))).catch((e=>{throw s.errBack&&s.errBack(e),clearTimeout(b),e}))}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tools_dj",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "dj tools 工具库",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",