[backend] fix: 修复异常处理和类型转换问题

This commit is contained in:
xsl
2026-01-26 11:53:40 +08:00
parent 7ccc2a6ac6
commit 83e05bf85f
28639 changed files with 2506458 additions and 93 deletions
+12
View File
@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/is-weakref
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+82
View File
@@ -0,0 +1,82 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.1.1](https://github.com/inspect-js/is-weakref/compare/v1.1.0...v1.1.1) - 2025-02-03
### Commits
- [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/tsconfig`, `@types/tape`, `for-each` [`e0bccbc`](https://github.com/inspect-js/is-weakref/commit/e0bccbcfc4fa0176ef6e07876fcf67b2d7a99884)
- [types] use WeakKey instead of object [`9ec7583`](https://github.com/inspect-js/is-weakref/commit/9ec75834bfceb6b153bf6a55f9e410fe5ecdb90a)
- [Deps] update `call-bound` [`7655eb0`](https://github.com/inspect-js/is-weakref/commit/7655eb01853dda6ac7ad85c067e290ff18ce1879)
## [v1.1.0](https://github.com/inspect-js/is-weakref/compare/v1.0.2...v1.1.0) - 2024-12-13
### Commits
- [meta] use `npmignore` to autogenerate an npmignore file [`34494a3`](https://github.com/inspect-js/is-weakref/commit/34494a3a7df0b144fbb55b578ee383d676a5b3df)
- [actions] split out node 10-20, and 20+ [`78cb11d`](https://github.com/inspect-js/is-weakref/commit/78cb11d8a02f028c9566f8a75cfc516d4f789c15)
- [New] add types [`f4ceaf5`](https://github.com/inspect-js/is-weakref/commit/f4ceaf53638c97c65ebe2342080acd931443833d)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `tape` [`24fccf5`](https://github.com/inspect-js/is-weakref/commit/24fccf5ac81aa562a87fa5354fb9bb26e43fb95f)
- [actions] update rebase action to use reusable workflow [`b27c6e9`](https://github.com/inspect-js/is-weakref/commit/b27c6e90004d71627bebbac846213e980ea988ce)
- [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `npmignore`, `object-inspect`, `tape` [`30fe836`](https://github.com/inspect-js/is-weakref/commit/30fe836a57043092f400739c0e5190d5651bf8db)
- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`0185ba7`](https://github.com/inspect-js/is-weakref/commit/0185ba74824e9122bdcc42b929a4d3017779041f)
- [Refactor] use `call-bound` directly [`641d87c`](https://github.com/inspect-js/is-weakref/commit/641d87c36f6a7a19fafee6840be5fe06e216b355)
- [meta] add missing `engines.node` [`8543506`](https://github.com/inspect-js/is-weakref/commit/8543506b1a11dca0c7d041d5e822acae4a027f0b)
- [Tests] replace `aud` with `npm audit` [`883c75c`](https://github.com/inspect-js/is-weakref/commit/883c75cfa404dbbf1aba2547c023ee48745baad0)
- [Deps] update `call-bind` [`805de0e`](https://github.com/inspect-js/is-weakref/commit/805de0e6b9649bceb144cb323bcadc499ff42d66)
- [Deps] update `call-bind` [`6a7ee43`](https://github.com/inspect-js/is-weakref/commit/6a7ee43f7bd6a9197daa7f9fcd0378c22d7066ca)
- [Dev Deps] update `object-inspect` [`d3d6a99`](https://github.com/inspect-js/is-weakref/commit/d3d6a992e4ac41e93743b25556c4adeee3f0ab05)
- [meta] add `sideEffects` flag [`2b13054`](https://github.com/inspect-js/is-weakref/commit/2b13054ee66de02d38fdf3d18d61552c871ac5a3)
- [Dev Deps] add missing peer dep [`54cb0bc`](https://github.com/inspect-js/is-weakref/commit/54cb0bc2d4bd1aa11714d15feb671e3dc085eaf0)
## [v1.0.2](https://github.com/inspect-js/is-weakref/compare/v1.0.1...v1.0.2) - 2021-12-10
### Commits
- [actions] reuse common workflows [`2375b1f`](https://github.com/inspect-js/is-weakref/commit/2375b1f9798b08c7af98481bbb38b4105835dacf)
- [meta] do not publish workflow files [`4c1be42`](https://github.com/inspect-js/is-weakref/commit/4c1be423afacabf2f3aa9e8bf02f668bdeaf3a20)
- [actions] use `node/install` instead of `node/run`; use `codecov` action [`7ec78ce`](https://github.com/inspect-js/is-weakref/commit/7ec78ce58c7553469eee97ae82fe147dfccde611)
- [readme] update URLs [`6306f09`](https://github.com/inspect-js/is-weakref/commit/6306f09a7df388150fb1d0b855b6f9e60165a457)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `safe-publish-latest`, `tape` [`7a1601e`](https://github.com/inspect-js/is-weakref/commit/7a1601e93ae50a791751a96d33073f5e65f3d3c9)
- [readme] add actions and codecov badges [`67ecd14`](https://github.com/inspect-js/is-weakref/commit/67ecd14b8b0192456932d1d54838accbf90ff5c0)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `object-inspect`, `safe-publish-latest`, `tape` [`1a5013b`](https://github.com/inspect-js/is-weakref/commit/1a5013bddcb9edc23025571810f9a2eebda53683)
- [actions] update codecov uploader [`b57b037`](https://github.com/inspect-js/is-weakref/commit/b57b037a547f3ecfa3d3f079a8015ec005c7181b)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`da49017`](https://github.com/inspect-js/is-weakref/commit/da49017800d628c9bcd2f094d49783d6ee649c50)
- [meta] simplify "exports" [`9b88835`](https://github.com/inspect-js/is-weakref/commit/9b8883585506c135a3fcb9f55d0944a13b4eb3e6)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`c7e77f4`](https://github.com/inspect-js/is-weakref/commit/c7e77f495308f3385adfaa1f4ac78a2632e0bcde)
- [Dev Deps] update `eslint` [`417b29e`](https://github.com/inspect-js/is-weakref/commit/417b29e7ceacebe24aef15422544443f4b59e181)
- [meta] add `safe-publish-latest`; use `prepublishOnly` script for npm 7+ [`b1b99f4`](https://github.com/inspect-js/is-weakref/commit/b1b99f45e0977d10f8472e9272e48a696145c2b1)
- [Deps] update `call-bind` [`aea342e`](https://github.com/inspect-js/is-weakref/commit/aea342e9e301deeb938e62b92a37cf991c5f7dbc)
- [actions] update workflows [`786c2d3`](https://github.com/inspect-js/is-weakref/commit/786c2d3dd4486acec09786220d3dd9fd48e70e93)
## [v1.0.1](https://github.com/inspect-js/is-weakref/compare/v1.0.0...v1.0.1) - 2020-12-04
### Commits
- [Tests] migrate tests to Github Actions [`05b4faa`](https://github.com/inspect-js/is-weakref/commit/05b4faa167c67f42c792e35c07adcb6b87e7dea0)
- [Tests] run `nyc` on all tests [`8df2e4b`](https://github.com/inspect-js/is-weakref/commit/8df2e4bd66bb6b7d55f389f28e6bb167fe1deb5a)
- [actions] add "Allow Edits" workflow [`4a716b8`](https://github.com/inspect-js/is-weakref/commit/4a716b8fcc025fe889a0f09ccaee7a9f748b1c66)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect` [`be23cf3`](https://github.com/inspect-js/is-weakref/commit/be23cf305f46db8b1c8a26d1c74b096fdba00056)
- [Refactor] use `call-bind` instead of `es-abstract` [`a933a96`](https://github.com/inspect-js/is-weakref/commit/a933a9643ddf7cddfd9f9f3cf44d675cc4c86ce5)
- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`4473ed2`](https://github.com/inspect-js/is-weakref/commit/4473ed2e73fed47cd2fa42b8d9cac17e941d2c08)
- [readme] remove travis badge [`bd3bfcd`](https://github.com/inspect-js/is-weakref/commit/bd3bfcd2c187099d2215232a7621fb960e1e2807)
## v1.0.0 - 2020-08-01
### Commits
- Initial commit [`dd86394`](https://github.com/inspect-js/is-weakref/commit/dd86394d7da000724c6e17c79077879c381e9ea3)
- readme [`f4defca`](https://github.com/inspect-js/is-weakref/commit/f4defcac48d1d99b019b596ab26bd868de1adfe9)
- Tests [`13d8139`](https://github.com/inspect-js/is-weakref/commit/13d8139dedf424239daf357261c39d3f8c33d662)
- npm init [`55a2bb7`](https://github.com/inspect-js/is-weakref/commit/55a2bb7c53b893396a51da969e352702cafe9a0e)
- Implementation [`1ec84e3`](https://github.com/inspect-js/is-weakref/commit/1ec84e36de4315d44c8da540faa27836832bb0f3)
- [meta] add auto-changelog [`ab9ce44`](https://github.com/inspect-js/is-weakref/commit/ab9ce44be717312c5221bf3d2f3f6d2dd8c6ac88)
- [actions] add automatic rebasing / merge commit blocking [`3d3f4d5`](https://github.com/inspect-js/is-weakref/commit/3d3f4d54bed6e455b2a0d0f20c87d454bf78af26)
- [meta] add "funding"; create `FUNDING.yml` [`f35ef3d`](https://github.com/inspect-js/is-weakref/commit/f35ef3de16eb06447acf3c39bdc164ba0e7bdf45)
- [Tests] add `npm run lint` [`af2123d`](https://github.com/inspect-js/is-weakref/commit/af2123d4754c14f7befa66ba01e1d72858723651)
- [Tests] use shared travis-ci configs [`042b4de`](https://github.com/inspect-js/is-weakref/commit/042b4dec08d882ae9137f4ad05ae24a1457da0f8)
- Only apps should have lockfiles [`fcae604`](https://github.com/inspect-js/is-weakref/commit/fcae604cb1422faae9311dd4219032895c0a9a2e)
+52
View File
@@ -0,0 +1,52 @@
# is-weakref <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][11]][1]
Is this value a JS WeakRef? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
## Example
```js
var isWeakRef = require('is-weakref');
assert(!isWeakRef(function () {}));
assert(!isWeakRef(null));
assert(!isWeakRef(function* () { yield 42; return Infinity; });
assert(!isWeakRef(Symbol('foo')));
assert(!isWeakRef(1n));
assert(!isWeakRef(Object(1n)));
assert(!isWeakRef(new Set()));
assert(!isWeakRef(new WeakSet()));
assert(!isWeakRef(new Map()));
assert(!isWeakRef(new WeakMap()));
assert(isWeakRef(new WeakRef({})));
class MyWeakRef extends WeakRef {}
assert(isWeakRef(new MyWeakRef({})));
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/is-weakref
[npm-version-svg]: https://versionbadg.es/inspect-js/is-weakref.svg
[deps-svg]: https://david-dm.org/inspect-js/is-weakref.svg
[deps-url]: https://david-dm.org/inspect-js/is-weakref
[dev-deps-svg]: https://david-dm.org/inspect-js/is-weakref/dev-status.svg
[dev-deps-url]: https://david-dm.org/inspect-js/is-weakref#info=devDependencies
[license-image]: https://img.shields.io/npm/l/is-weakref.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/is-weakref.svg
[downloads-url]: https://npm-stat.com/charts.html?package=is-weakref
[codecov-image]: https://codecov.io/gh/inspect-js/is-weakref/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/inspect-js/is-weakref/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-weakref
[actions-url]: https://github.com/inspect-js/is-weakref/actions
+3
View File
@@ -0,0 +1,3 @@
declare function isWeakRef<T extends WeakKey>(value: unknown): value is WeakRef<T>;
export = isWeakRef;
+82
View File
@@ -0,0 +1,82 @@
{
"name": "is-weakref",
"version": "1.1.1",
"description": "Is this value a JS WeakRef? This module works cross-realm/iframe, and despite ES6 @@toStringTag.",
"main": "index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"sideEffects": false,
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"",
"prepublishOnly": "safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"lint": "eslint --ext=js,mjs .",
"postlint": "tsc && attw -P",
"pretest": "npm run lint",
"tests-only": "nyc tape 'test/**/*.js'",
"test": "npm run tests-only",
"posttest": "npx npm@'>=10.2' audit --production"
},
"repository": {
"type": "git",
"url": "git+https://github.com/inspect-js/is-weakref.git"
},
"keywords": [
"weakref",
"weak",
"ref",
"finalization",
"finalization registry"
],
"author": "Jordan Harband <ljharb@gmail.com>",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/inspect-js/is-weakref/issues"
},
"homepage": "https://github.com/inspect-js/is-weakref#readme",
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.3",
"@ljharb/eslint-config": "^21.1.1",
"@ljharb/tsconfig": "^0.2.3",
"@types/for-each": "^0.3.3",
"@types/object-inspect": "^1.13.0",
"@types/tape": "^5.8.1",
"auto-changelog": "^2.5.0",
"encoding": "^0.1.13",
"eslint": "=8.8.0",
"for-each": "^0.3.4",
"in-publish": "^2.0.1",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"object-inspect": "^1.13.3",
"safe-publish-latest": "^2.0.0",
"tape": "^5.9.0",
"typescript": "next"
},
"dependencies": {
"call-bound": "^1.0.3"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows"
]
},
"engines": {
"node": ">= 0.4"
}
}
+26
View File
@@ -0,0 +1,26 @@
'use strict';
var test = require('tape');
var inspect = require('object-inspect');
var forEach = require('for-each');
var isWeakRef = require('..');
test('isWeakRef', function (t) {
t.equal(typeof isWeakRef, 'function', 'is a function');
var nonWeakRefs = [undefined, null, true, false, 42, 0, Infinity, NaN, /a/g, function () {}, {}, []];
forEach(nonWeakRefs, function (nonWeakRef) {
t.equal(isWeakRef(nonWeakRef), false, inspect(nonWeakRef) + ' is not a WeakRef');
});
t.test('actual WeakRefs', { skip: typeof WeakRef === 'undefined' }, function (st) {
var ref = new WeakRef({});
st.equal(isWeakRef(ref), true, inspect(ref) + ' is a WeakRef');
st.end();
});
t.end();
});
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "@ljharb/tsconfig",
"compilerOptions": {
"target": "ES2021",
},
"exclude": [
"coverage"
]
}