[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-set
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']
+81
View File
@@ -0,0 +1,81 @@
# 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).
## [v2.0.3](https://github.com/inspect-js/is-set/compare/v2.0.2...v2.0.3) - 2024-03-08
### Commits
- [actions] reuse common workflows [`9d26ac6`](https://github.com/inspect-js/is-set/commit/9d26ac673752d89ba855a50616d36f09d49d6113)
- [actions] use `node/install` instead of `node/run`; use `codecov` action [`3c91325`](https://github.com/inspect-js/is-set/commit/3c91325782b9dac5a602e150cd007e51029930f9)
- add types [`8fcc646`](https://github.com/inspect-js/is-set/commit/8fcc646ba3befa5448f987c7c12e0863443c9533)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `safe-publish-latest`, `tape` [`91caa24`](https://github.com/inspect-js/is-set/commit/91caa24511234e8f105f4534b681abdb2139b650)
- [readme] update URLs [`130e57b`](https://github.com/inspect-js/is-set/commit/130e57bc4d6386bd500d6886b9f094dd201cb88b)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `es5-shim`, `object-inspect`, `tape` [`4d75ee2`](https://github.com/inspect-js/is-set/commit/4d75ee27c0351999ba3093d519c12dc8bc0ff0ee)
- [actions] remove redundant finisher [`052fdce`](https://github.com/inspect-js/is-set/commit/052fdce2ee22fe49186c4d848063600f0c3f968d)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `core-js`, `es5-shim`, `object-inspect`, `safe-publish-latest`, `tape` [`eb31797`](https://github.com/inspect-js/is-set/commit/eb317975ea6240cc2dc043db9e4a837b00f82ffc)
- [actions] update rebase action to use reusable workflow [`8c478ba`](https://github.com/inspect-js/is-set/commit/8c478ba28881beb9f07650e409f6ef7df4a92455)
- [actions] update codecov uploader [`a0dac6b`](https://github.com/inspect-js/is-set/commit/a0dac6b9abb0c5a3eff6849cca4ba7f1c0c8dc17)
- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `es6-shim`, `object-inspect`, `tape` [`28d75a3`](https://github.com/inspect-js/is-set/commit/28d75a3ecb22235593b43e32505b90578da0dfab)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`7b2a4a7`](https://github.com/inspect-js/is-set/commit/7b2a4a75bae0f1a9163a83ac8760f10cfbcdb001)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `es5-shim`, `tape` [`20ce047`](https://github.com/inspect-js/is-set/commit/20ce04714d7be5fbee40c757e2ba7194e248c1a2)
- [readme] add actions and codecov badges [`e6e1796`](https://github.com/inspect-js/is-set/commit/e6e1796da1700594a3988466762405462f082cda)
- [meta] add missing `engines.node` [`9ed19af`](https://github.com/inspect-js/is-set/commit/9ed19afb98ad26e29378c2a7f1c82359d5c5a809)
- [meta] use `prepublishOnly` script for npm 7+ [`618f861`](https://github.com/inspect-js/is-set/commit/618f86128277814075fe56f7a69a272c31a48f85)
- [readme] remove dead badges [`76e890e`](https://github.com/inspect-js/is-set/commit/76e890ea165c6cb9088604ea010968d5e3e877c6)
- [meta] add `sideEffects` flag [`e21859b`](https://github.com/inspect-js/is-set/commit/e21859bb58bd5aafb907fe53045ec3bc14d07449)
## [v2.0.2](https://github.com/inspect-js/is-set/compare/v2.0.1...v2.0.2) - 2020-12-13
### Commits
- [Tests] migrate tests to Github Actions [`10a1a86`](https://github.com/inspect-js/is-set/commit/10a1a869d5f76921eed5bb7f1503be6f03eea8a2)
- [meta] do not publish github action workflow files [`9611423`](https://github.com/inspect-js/is-set/commit/9611423c4a6baa08a38f46ddafcca3ed4ea0ad97)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `es6-shim`, `object-inspect`, `tape` [`7d4d9b3`](https://github.com/inspect-js/is-set/commit/7d4d9b3ce8434a96c238cef62a7ce9ce79bd6079)
- [Tests] run `nyc` on all tests [`dff5fb6`](https://github.com/inspect-js/is-set/commit/dff5fb6cec206e51c6a7311fdb866bb0a0783b1a)
- [actions] add "Allow Edits" workflow [`6bed76a`](https://github.com/inspect-js/is-set/commit/6bed76af3119e489e622b3ea30807484dbb7fca9)
- [readme] remove travis badge [`ee9e740`](https://github.com/inspect-js/is-set/commit/ee9e74012ba35e86a4e92d7165548341d4323755)
- [Tests] add `core-js` tests [`9ef1b4e`](https://github.com/inspect-js/is-set/commit/9ef1b4ed0e55cec4154189247b6d7f6ad570e2f1)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`5661354`](https://github.com/inspect-js/is-set/commit/5661354f7a9861998257fdacfa9975feae9415b8)
- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`2cea69e`](https://github.com/inspect-js/is-set/commit/2cea69e16f64d7e706945010e03401a0a66507a3)
- [Dev Deps] update `es5-shim`, `tape` [`9e24b51`](https://github.com/inspect-js/is-set/commit/9e24b5158a0490c6b94deb31e76b06337eaafce6)
- [Dev Deps] update `auto-changelog`; add `aud` [`69ae556`](https://github.com/inspect-js/is-set/commit/69ae5561fe2408f301479dfa65dac0255e16952e)
- Fix typo in README.md, Map -> Set [`5fe826a`](https://github.com/inspect-js/is-set/commit/5fe826a1e11bf810b7174e2dfaf893a5682511d4)
- [Tests] only audit prod deps [`c7c67f6`](https://github.com/inspect-js/is-set/commit/c7c67f6b1a32b2b24709d733a6681cbe1ec67640)
- [meta] normalize line endings [`6ef4ebd`](https://github.com/inspect-js/is-set/commit/6ef4ebdf090bdf1f42eb912b6af2cf31df4abaef)
## [v2.0.1](https://github.com/inspect-js/is-set/compare/v2.0.0...v2.0.1) - 2019-12-17
### Fixed
- [Refactor] avoid top-level return, because babel and webpack are broken [`#5`](https://github.com/inspect-js/is-set/issues/5) [`#4`](https://github.com/inspect-js/is-set/issues/4) [`#3`](https://github.com/inspect-js/is-set/issues/3) [`#78`](https://github.com/inspect-js/node-deep-equal/issues/78) [`#7`](https://github.com/es-shims/Promise.allSettled/issues/7) [`#12`](https://github.com/airbnb/js-shims/issues/12)
### Commits
- [actions] add automatic rebasing / merge commit blocking [`db358ba`](https://github.com/inspect-js/is-set/commit/db358ba503aa86fe2d375e188dcdfa7174a070c8)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`13e5083`](https://github.com/inspect-js/is-set/commit/13e50834eacb1c1830feb598da70ca6d0c53d2f7)
## [v2.0.0](https://github.com/inspect-js/is-set/compare/v1.0.0...v2.0.0) - 2019-11-12
### Commits
- Initial commit [`0299bc8`](https://github.com/inspect-js/is-set/commit/0299bc8fce41dce4586ac2f79c73802ad6a72c3d)
- Tests [`dec24eb`](https://github.com/inspect-js/is-set/commit/dec24eb0b9f57f14be8eedd0e572f94f81572e82)
- readme [`9b16e7f`](https://github.com/inspect-js/is-set/commit/9b16e7ff417b5c7be9829f22e32249d737bb8f6e)
- implementation [`3da6156`](https://github.com/inspect-js/is-set/commit/3da6156dae02e71d541bc8a0d3b751734b98e06d)
- npm init [`89fdc8b`](https://github.com/inspect-js/is-set/commit/89fdc8b3d980f6ca414f71dff2af38ed102321a1)
- [meta] add `funding` field; create `FUNDING.yml` [`77f2be9`](https://github.com/inspect-js/is-set/commit/77f2be9f281439472f81a0378632bc5eeb25a79b)
- [meta] add `safe-publish-latest`, `auto-changelog` [`cef1b4c`](https://github.com/inspect-js/is-set/commit/cef1b4cef15c565e76e3d46e66087821c4c437ae)
- [Tests] add `npm run lint` [`2a8284c`](https://github.com/inspect-js/is-set/commit/2a8284c6d2265ecd5c98bd4a008a82f0b519cd0a)
- [Tests] use shared travis-ci configs [`d2e342f`](https://github.com/inspect-js/is-set/commit/d2e342f3b8477cc74bcab44297d20d10fcf3718b)
- Only apps should have lockfiles [`624072b`](https://github.com/inspect-js/is-set/commit/624072b92774aaa6d851837c882181995d88ece8)
- [Tests] add `npx aud` in `posttest` [`214247c`](https://github.com/inspect-js/is-set/commit/214247c3fcd61b164c18b56524cdc183fc485450)
## v1.0.0 - 2015-02-18
### Commits
- init [`2f11646`](https://github.com/inspect-js/is-set/commit/2f1164617bee9c05c0f7ffae8fca2feed13bade7)
+50
View File
@@ -0,0 +1,50 @@
# is-set <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
Is this value a JS Set? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
## Example
```js
var isSet = require('is-set');
assert(!isSet(function () {}));
assert(!isSet(null));
assert(!isSet(function* () { yield 42; return Infinity; });
assert(!isSet(Symbol('foo')));
assert(!isSet(1n));
assert(!isSet(Object(1n)));
assert(!isSet(new Map()));
assert(!isSet(new WeakSet()));
assert(!isSet(new WeakMap()));
assert(isSet(new Set()));
class MySet extends Set {}
assert(isSet(new MySet()));
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/is-set
[npm-version-svg]: https://versionbadg.es/inspect-js/is-set.svg
[deps-svg]: https://david-dm.org/inspect-js/is-set.svg
[deps-url]: https://david-dm.org/inspect-js/is-set
[dev-deps-svg]: https://david-dm.org/inspect-js/is-set/dev-status.svg
[dev-deps-url]: https://david-dm.org/inspect-js/is-set#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/is-set.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/is-set.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/is-set.svg
[downloads-url]: https://npm-stat.com/charts.html?package=is-set
[codecov-image]: https://codecov.io/gh/inspect-js/is-set/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/inspect-js/is-set/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-set
[actions-url]: https://github.com/inspect-js/is-set/actions
+3
View File
@@ -0,0 +1,3 @@
declare function isSet<V = unknown>(x: unknown): x is Set<V>;
export = isSet;
+46
View File
@@ -0,0 +1,46 @@
'use strict';
var $Map = typeof Map === 'function' && Map.prototype ? Map : null;
var $Set = typeof Set === 'function' && Set.prototype ? Set : null;
var exported;
if (!$Set) {
/** @type {import('.')} */
// eslint-disable-next-line no-unused-vars
exported = function isSet(x) {
// `Set` is not present in this environment.
return false;
};
}
var $mapHas = $Map ? Map.prototype.has : null;
var $setHas = $Set ? Set.prototype.has : null;
if (!exported && !$setHas) {
/** @type {import('.')} */
// eslint-disable-next-line no-unused-vars
exported = function isSet(x) {
// `Set` does not have a `has` method
return false;
};
}
/** @type {import('.')} */
module.exports = exported || function isSet(x) {
if (!x || typeof x !== 'object') {
return false;
}
try {
$setHas.call(x);
if ($mapHas) {
try {
$mapHas.call(x);
} catch (e) {
return true;
}
}
// @ts-expect-error TS can't figure out that $Set is always truthy here
return x instanceof $Set; // core-js workaround, pre-v2.5.0
} catch (e) {}
return false;
};
+72
View File
@@ -0,0 +1,72 @@
{
"name": "is-set",
"version": "2.0.3",
"description": "Is this value a JS Set? This module works cross-realm/iframe, and despite ES6 @@toStringTag.",
"main": "index.js",
"sideEffects": false,
"scripts": {
"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",
"pretest": "npm run lint",
"lint": "eslint --ext=.js,.mjs .",
"postlint": "tsc -p . && attw -P",
"tests-only": "nyc tape 'test/**/*.js'",
"tests:shims": "nyc tape --require=es5-shim --require=es5-shim 'test/**/*.js'",
"tests:corejs": "nyc tape --require=core-js 'test/**/*.js'",
"test": "npm run tests-only && npm run tests:shims && npm run tests:corejs",
"posttest": "npx aud --production"
},
"repository": {
"type": "git",
"url": "git+https://github.com/inspect-js/is-set.git"
},
"keywords": [
"map",
"set",
"collection",
"is",
"robust"
],
"author": "Jordan Harband <ljharb@gmail.com>",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/inspect-js/is-set/issues"
},
"homepage": "https://github.com/inspect-js/is-set#readme",
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.0",
"@ljharb/eslint-config": "^21.1.0",
"@types/for-each": "^0.3.3",
"@types/object-inspect": "^1.8.4",
"@types/tape": "^5.6.4",
"aud": "^2.0.4",
"auto-changelog": "^2.4.0",
"core-js": "^2.6.12",
"es5-shim": "^4.6.7",
"es6-shim": "^0.35.8",
"eslint": "=8.8.0",
"for-each": "^0.3.3",
"in-publish": "^2.0.1",
"nyc": "^10.3.2",
"object-inspect": "^1.13.1",
"safe-publish-latest": "^2.0.0",
"tape": "^5.7.5",
"typescript": "next"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"engines": {
"node": ">= 0.4"
}
}
+59
View File
@@ -0,0 +1,59 @@
'use strict';
var test = require('tape');
var debug = require('object-inspect');
var forEach = require('for-each');
var isSet = require('..');
test('non-collections', function (t) {
forEach([
null,
undefined,
true,
false,
42,
0,
-0,
NaN,
Infinity,
'',
'foo',
/a/g,
[],
{},
function () {}
], function (nonCollection) {
t.equal(isSet(nonCollection), false, debug(nonCollection) + ' is not a Set');
});
t.end();
});
test('Maps', { skip: typeof Map !== 'function' }, function (t) {
var m = new Map();
t.equal(isSet(m), false, debug(m) + ' is not a Set');
t.end();
});
test('Sets', { skip: typeof Set !== 'function' }, function (t) {
var s = new Set();
t.equal(isSet(s), true, debug(s) + ' is a Set');
t.end();
});
test('WeakMaps', { skip: typeof WeakMap !== 'function' }, function (t) {
var wm = new WeakMap();
t.equal(isSet(wm), false, debug(wm) + ' is not a Set');
t.end();
});
test('WeakSets', { skip: typeof WeakSet !== 'function' }, function (t) {
var ws = new WeakSet();
t.equal(isSet(ws), false, debug(ws) + ' is not a Set');
t.end();
});
+49
View File
@@ -0,0 +1,49 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
/* Language and Environment */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
"useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": ["types"], /* Specify multiple folders that act like './node_modules/@types'. */
"resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
/* JavaScript Support */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
"maxNodeModuleJsDepth": 0, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declarationMap": true, /* Create sourcemaps for d.ts files. */
"noEmit": true, /* Disable emitting files from a compilation. */
/* Interop Constraints */
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
/* Completeness */
//"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"exclude": [
"coverage"
]
}