Gathering detailed insights and metrics for @alicloud/fetcher-jsonp
Gathering detailed insights and metrics for @alicloud/fetcher-jsonp
npm install @alicloud/fetcher-jsonp
Typescript
Module System
Node Version
NPM Version
71.6
Supply Chain
86
Quality
81.7
Maintenance
100
Vulnerability
100
License
TypeScript (90.14%)
Less (9.02%)
JavaScript (0.83%)
Total Downloads
38,694
Last Day
14
Last Week
63
Last Month
162
Last Year
3,500
51 Stars
1,989 Commits
13 Forks
9 Watching
14 Branches
8 Contributors
Minified
Minified + Gzipped
Latest Version
1.5.9
Package Id
@alicloud/fetcher-jsonp@1.5.9
Unpacked Size
16.23 kB
Size
5.64 kB
File Count
25
NPM Version
lerna/6.6.0/node@v18.11.0+arm64 (darwin)
Node Version
18.11.0
Publised On
24 Mar 2023
Cumulative downloads
Total Downloads
Last day
133.3%
14
Compared to previous day
Last week
80%
63
Compared to previous week
Last month
-21%
162
Compared to previous month
Last year
-64.6%
3,500
Compared to previous year
@alicloud/fetcher
的底层 Promise 比较「纯」的 jsonp 实现,可以单独使用,返回为封装过的JsonResponse
而非直接的数据。
何以「纯」?
url
需要使用者来拼接参数(跟原生的 fetch 类似)。
1tnpm i @alicloud/fetcher-jsonp -S
1import jsonp, { 2 EJsonpError, 3 JsonpOptions 4} from '@alicloud/fetcher-jsonp'; 5 6jsonp(url, { 7 timeout, // 超时毫秒数,默认 5 秒(一般来说 JSONP 请求要求必须有超时时间) 8 charset, 9 jsonpCallback, 10 jsonpCallbackFunction, 11 signal // 和 fetch 一致 12});
参考 https://javascript.info/fetch-abort https://developer.mozilla.org/en-US/docs/Web/API/AbortController
1import jsonp from '@alicloud/fetcher-jsonp'; 2 3function getAbortSignal(): AbortSignal | undefined { 4 if (!window.AbortController) { // IE 下都不支持,请 if 保护 5 return; 6 } 7 8 const abortController = new AbortController(); 9 10 setTimeout(() => { // 这里是模拟的,实际场景中不会用 setTimeout 11 abortController.abort(); // 只有第一次调用有效 12 }, 200); 13 14 return abortController.signal; 15} 16 17return jsonp(jsonpUrl, { 18 signal: getAbortSignal(), 19 timeout 20}).then(response => response.json());
请求被 Abort 只是形式上的 Abort,就像 timeout
一样,请求最终还是会继续(即使 DOM script 已经被移除)。
Abort 后得到的错误和原生的 AbortError 类似,其 name 属性为 AbortError
。
No vulnerabilities found.
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
no binaries found in the repo
Reason
Found 6/16 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More