@fatcherjs/middleware-aborter 1.0.0 → 1.2.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.
|
File without changes
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { warn } from 'fatcher';
|
|
2
|
-
|
|
3
1
|
function aborter(options = {}) {
|
|
4
2
|
const { timeout = 0, onAbort = null } = options;
|
|
5
3
|
let _timeout = timeout;
|
|
6
4
|
if (isNaN(timeout) || ~~timeout <= 0) {
|
|
7
|
-
warn("
|
|
5
|
+
console.warn("[fatcher-middleware-aborter] Timeout is not a valid number.");
|
|
8
6
|
_timeout = 0;
|
|
9
7
|
}
|
|
10
8
|
return {
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var fatcher = require('fatcher');
|
|
6
|
-
|
|
7
5
|
function aborter(options = {}) {
|
|
8
6
|
const { timeout = 0, onAbort = null } = options;
|
|
9
7
|
let _timeout = timeout;
|
|
10
8
|
if (isNaN(timeout) || ~~timeout <= 0) {
|
|
11
|
-
|
|
9
|
+
console.warn("[fatcher-middleware-aborter] Timeout is not a valid number.");
|
|
12
10
|
_timeout = 0;
|
|
13
11
|
}
|
|
14
12
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.FatcherMiddlewareAborter={}))})(this,function(e){"use strict";function t(a={}){const{timeout:o=0,onAbort:r=null}=a;let n=o;return(isNaN(o)||~~o<=0)&&(console.warn("[fatcher-middleware-aborter] Timeout is not a valid number."),n=0),{name:"fatcher-middleware-aborter",async use(c,u){const i=new AbortController,s=u({signal:i.signal});if(!n)return s;const l=setTimeout(()=>{i.abort(),r?.()},n),d=await s;return clearTimeout(l),d}}}e.aborter=t,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/package.json
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fatcherjs/middleware-aborter",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"main": "dist/
|
|
5
|
-
"module": "dist/
|
|
6
|
-
"browser": "dist/
|
|
7
|
-
"typings": "dist/
|
|
8
|
-
"repository": "https://github.com/fatcherjs/middlewares/tree/master/packages/aborter",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"main": "dist/aborter.js",
|
|
5
|
+
"module": "dist/aborter.esm.js",
|
|
6
|
+
"browser": "dist/aborter.min.js",
|
|
7
|
+
"typings": "dist/aborter.d.ts",
|
|
9
8
|
"license": "MIT",
|
|
10
9
|
"files": [
|
|
11
10
|
"dist"
|
|
12
11
|
],
|
|
12
|
+
"homepage": "https://github.com/fatcherjs/fatcher/tree/master/packages/aborter",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/fatcherjs/fatcher.git"
|
|
16
|
+
},
|
|
13
17
|
"peerDependencies": {
|
|
14
18
|
"fatcher": "^1.0.0"
|
|
15
19
|
},
|
|
16
20
|
"scripts": {
|
|
17
21
|
"dev": "rimraf dist && rollup -c rollup.config.ts -w",
|
|
18
|
-
"build": "rimraf dist && rollup -c rollup.config.ts"
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
"build": "rimraf dist && rollup -c rollup.config.ts",
|
|
23
|
+
"deploy": "pnpm run build && pnpm publish --no-git-check"
|
|
24
|
+
}
|
|
21
25
|
}
|
package/dist/index.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("fatcher")):typeof define=="function"&&define.amd?define(["exports","fatcher"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.FatcherMiddlewareAborter={},e.Fatcher))})(this,function(e,t){"use strict";function u(a={}){const{timeout:r=0,onAbort:o=null}=a;let n=r;return(isNaN(r)||~~r<=0)&&(t.warn("<Aborter> Timeout is not a valid number."),n=0),{name:"fatcher-middleware-aborter",async use(l,c){const i=new AbortController,s=c({signal:i.signal});if(!n)return s;const f=setTimeout(()=>{i.abort(),o?.()},n),d=await s;return clearTimeout(f),d}}}e.aborter=u,Object.defineProperty(e,"__esModule",{value:!0})});
|