Initial React project

This commit is contained in:
Johan
2026-03-17 00:42:10 +01:00
parent c9031f2275
commit 8bca9680e4
1317 changed files with 48700 additions and 23334 deletions

View File

@@ -1 +1 @@
../baseline-browser-mapping/dist/cli.js
../baseline-browser-mapping/dist/cli.cjs

1
node_modules/.bin/loose-envify generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../loose-envify/cli.js

780
node_modules/.package-lock.json generated vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,43 +1,49 @@
{
"hash": "9f828600",
"configHash": "e8c17b8b",
"lockfileHash": "1dd2cb93",
"browserHash": "2551e78b",
"hash": "d64679c8",
"configHash": "8173562f",
"lockfileHash": "b475d2d6",
"browserHash": "41ef5122",
"optimized": {
"react": {
"src": "../../react/index.js",
"file": "react.js",
"fileHash": "32ad5d7a",
"fileHash": "9cfcf420",
"needsInterop": true
},
"react-dom": {
"src": "../../react-dom/index.js",
"file": "react-dom.js",
"fileHash": "529a1881",
"fileHash": "b004db3a",
"needsInterop": true
},
"react/jsx-dev-runtime": {
"src": "../../react/jsx-dev-runtime.js",
"file": "react_jsx-dev-runtime.js",
"fileHash": "602e9bcd",
"fileHash": "d912a8ac",
"needsInterop": true
},
"react/jsx-runtime": {
"src": "../../react/jsx-runtime.js",
"file": "react_jsx-runtime.js",
"fileHash": "6e5c0fbb",
"needsInterop": true
},
"react-dom/client": {
"src": "../../react-dom/client.js",
"file": "react-dom_client.js",
"fileHash": "056eddc3",
"fileHash": "10b29ac6",
"needsInterop": true
},
"lucide-react": {
"src": "../../lucide-react/dist/esm/lucide-react.js",
"file": "lucide-react.js",
"fileHash": "12698df0",
"fileHash": "a6f95ae6",
"needsInterop": false
},
"react-dom/client": {
"src": "../../react-dom/client.js",
"file": "react-dom_client.js",
"fileHash": "d6b66b84",
"needsInterop": true
},
"react-helmet-async": {
"src": "../../react-helmet-async/lib/index.esm.js",
"file": "react-helmet-async.js",
"fileHash": "a1e28d83",
"needsInterop": false
}
},

1148
node_modules/.vite/deps/react-helmet-async.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

7
node_modules/.vite/deps/react-helmet-async.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1,6 +1,6 @@
{
"name": "@esbuild/darwin-arm64",
"version": "0.27.3",
"version": "0.27.4",
"description": "The macOS ARM 64-bit binary for esbuild, a JavaScript bundler.",
"repository": {
"type": "git",

View File

@@ -951,7 +951,7 @@ caseInsensitive = false } = {}) {
let endsWithSep = false;
let i = j;
// Terminates with `i` at the non-inclusive end of the current segment.
for(; i < glob.length && !c.seps.includes(glob[i]); i++){
for(; i < glob.length && !(c.seps.includes(glob[i]) && groupStack.length === 0); i++){
if (inEscape) {
inEscape = false;
const escapeChars = inRange ? RANGE_ESCAPE_CHARS : REG_EXP_ESCAPE_CHARS;
@@ -1224,7 +1224,7 @@ const constants = {
"(": ")",
"[": "]"
};
const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\))/;
const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\)|@\([^)]+\))/;
if (str === "") {
return false;
}

View File

@@ -1001,7 +1001,7 @@ function assertArgs(from, to) {
/**
* Return the relative path from `from` to `to` based on current working directory.
*
* An example in windws, for instance:
* An example in windows, for instance:
* from = 'C:\\orandea\\test\\aaa'
* to = 'C:\\orandea\\impl\\bbb'
* The output of the function should be: '..\\..\\impl\\bbb'
@@ -1291,7 +1291,7 @@ caseInsensitive = false } = {}) {
let endsWithSep = false;
let i = j;
// Terminates with `i` at the non-inclusive end of the current segment.
for(; i < glob.length && !c.seps.includes(glob[i]); i++){
for(; i < glob.length && !(c.seps.includes(glob[i]) && groupStack.length === 0); i++){
if (inEscape) {
inEscape = false;
const escapeChars = inRange ? RANGE_ESCAPE_CHARS : REG_EXP_ESCAPE_CHARS;
@@ -1565,7 +1565,7 @@ const constants = {
"(": ")",
"[": "]"
};
const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\))/;
const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\)|@\([^)]+\))/;
if (str === "") {
return false;
}

View File

@@ -949,7 +949,7 @@ caseInsensitive = false } = {}) {
let endsWithSep = false;
let i = j;
// Terminates with `i` at the non-inclusive end of the current segment.
for(; i < glob.length && !c.seps.includes(glob[i]); i++){
for(; i < glob.length && !(c.seps.includes(glob[i]) && groupStack.length === 0); i++){
if (inEscape) {
inEscape = false;
const escapeChars = inRange ? RANGE_ESCAPE_CHARS : REG_EXP_ESCAPE_CHARS;
@@ -1222,7 +1222,7 @@ const constants = {
"(": ")",
"[": "]"
};
const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\))/;
const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\)|@\([^)]+\))/;
if (str === "") {
return false;
}

View File

@@ -999,7 +999,7 @@ function assertArgs(from, to) {
/**
* Return the relative path from `from` to `to` based on current working directory.
*
* An example in windws, for instance:
* An example in windows, for instance:
* from = 'C:\\orandea\\test\\aaa'
* to = 'C:\\orandea\\impl\\bbb'
* The output of the function should be: '..\\..\\impl\\bbb'
@@ -1289,7 +1289,7 @@ caseInsensitive = false } = {}) {
let endsWithSep = false;
let i = j;
// Terminates with `i` at the non-inclusive end of the current segment.
for(; i < glob.length && !c.seps.includes(glob[i]); i++){
for(; i < glob.length && !(c.seps.includes(glob[i]) && groupStack.length === 0); i++){
if (inEscape) {
inEscape = false;
const escapeChars = inRange ? RANGE_ESCAPE_CHARS : REG_EXP_ESCAPE_CHARS;
@@ -1563,7 +1563,7 @@ const constants = {
"(": ")",
"[": "]"
};
const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\))/;
const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\)|@\([^)]+\))/;
if (str === "") {
return false;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@eslint/config-array",
"version": "0.21.1",
"version": "0.21.2",
"description": "General purpose glob-based configuration matching.",
"author": "Nicholas C. Zakas",
"type": "module",
@@ -51,7 +51,7 @@
"dependencies": {
"@eslint/object-schema": "^2.1.7",
"debug": "^4.3.1",
"minimatch": "^3.1.2"
"minimatch": "^3.1.5"
},
"devDependencies": {
"@jsr/std__path": "^1.0.4",

View File

@@ -135,10 +135,10 @@ The following companies, organizations, and individuals support ESLint's ongoing
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
<h3>Platinum Sponsors</h3>
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://www.n-ix.com/"><img src="https://images.opencollective.com/n-ix-ltd/575a7a5/logo.png" alt="N-iX Ltd" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a></p><h3>Gold Sponsors</h3>
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a></p><h3>Silver Sponsors</h3>
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://www.crawljobs.com/"><img src="https://images.opencollective.com/crawljobs-poland/fa43a17/logo.png" alt="CrawlJobs" height="32"></a> <a href="https://depot.dev"><img src="https://images.opencollective.com/depot/39125a1/logo.png" alt="Depot" height="32"></a> <a href="https://www.n-ix.com/"><img src="https://images.opencollective.com/n-ix-ltd/575a7a5/logo.png" alt="N-iX Ltd" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
<h3>Technology Sponsors</h3>
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>

View File

@@ -1,6 +1,6 @@
{
"name": "@eslint/eslintrc",
"version": "3.3.3",
"version": "3.3.5",
"description": "The legacy ESLintRC config file format for ESLint",
"type": "module",
"main": "./dist/eslintrc.cjs",
@@ -62,14 +62,14 @@
"typescript": "^5.7.3"
},
"dependencies": {
"ajv": "^6.12.4",
"ajv": "^6.14.0",
"debug": "^4.3.2",
"espree": "^10.0.1",
"globals": "^14.0.0",
"ignore": "^5.2.0",
"import-fresh": "^3.2.1",
"js-yaml": "^4.1.1",
"minimatch": "^3.1.2",
"minimatch": "^3.1.5",
"strip-json-comments": "^3.1.1"
},
"engines": {

View File

@@ -1,6 +1,6 @@
{
"name": "@eslint/js",
"version": "9.39.2",
"version": "9.39.4",
"description": "ESLint JavaScript language implementation",
"funding": "https://eslint.org/donate",
"main": "./src/index.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@rollup/rollup-darwin-arm64",
"version": "4.57.1",
"version": "4.59.0",
"os": [
"darwin"
],

2
node_modules/@types/node/README.md generated vendored
View File

@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v24.
### Additional Details
* Last updated: Tue, 10 Feb 2026 14:48:58 GMT
* Last updated: Fri, 06 Mar 2026 05:19:15 GMT
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
# Credits

View File

@@ -5,6 +5,7 @@
*
* ```js
* import { spawn } from 'node:child_process';
* import { once } from 'node:events';
* const ls = spawn('ls', ['-lh', '/usr']);
*
* ls.stdout.on('data', (data) => {
@@ -15,9 +16,8 @@
* console.error(`stderr: ${data}`);
* });
*
* ls.on('close', (code) => {
* console.log(`child process exited with code ${code}`);
* });
* const [code] = await once(ls, 'close');
* console.log(`child process exited with code ${code}`);
* ```
*
* By default, pipes for `stdin`, `stdout`, and `stderr` are established between
@@ -719,6 +719,7 @@ declare module "child_process" {
*
* ```js
* import { spawn } from 'node:child_process';
* import { once } from 'node:events';
* const ls = spawn('ls', ['-lh', '/usr']);
*
* ls.stdout.on('data', (data) => {
@@ -729,9 +730,8 @@ declare module "child_process" {
* console.error(`stderr: ${data}`);
* });
*
* ls.on('close', (code) => {
* console.log(`child process exited with code ${code}`);
* });
* const [code] = await once(ls, 'close');
* console.log(`child process exited with code ${code}`);
* ```
*
* Example: A very elaborate way to run `ps ax | grep ssh`

16
node_modules/@types/node/crypto.d.ts generated vendored
View File

@@ -2709,12 +2709,12 @@ declare module "crypto" {
privateKey: T2;
}
/**
* Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
* Ed25519, Ed448, X25519, X448, DH, and ML-DSA are currently supported.
* Generates a new asymmetric key pair of the given `type`.
* See the supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
*
* If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
* the respective part of the key is returned as a `KeyObject`.
* behaves as if {@link KeyObject.export `keyObject.export()`} had been called on its result. Otherwise,
* the respective part of the key is returned as a {@link KeyObject `KeyObject`}.
*
* When encoding public keys, it is recommended to use `'spki'`. When encoding
* private keys, it is recommended to use `'pkcs8'` with a strong passphrase,
@@ -3007,12 +3007,12 @@ declare module "crypto" {
options?: SLHDSAKeyPairKeyObjectOptions,
): KeyPairKeyObjectResult;
/**
* Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
* Ed25519, Ed448, X25519, X448, and DH are currently supported.
* Generates a new asymmetric key pair of the given `type`.
* See the supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
*
* If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
* the respective part of the key is returned as a `KeyObject`.
* behaves as if {@link KeyObject.export `keyObject.export()`} had been called on its result. Otherwise,
* the respective part of the key is returned as a {@link KeyObject `KeyObject`}.
*
* It is recommended to encode public keys as `'spki'` and private keys as `'pkcs8'` with encryption for long-term storage:
*

42
node_modules/@types/node/http.d.ts generated vendored
View File

@@ -357,6 +357,14 @@ declare module "http" {
* @since v18.17.0, v20.2.0
*/
rejectNonStandardBodyWrites?: boolean | undefined;
/**
* If set to `true`, requests without `Content-Length` or `Transfer-Encoding` headers (indicating no body)
* will be initialized with an already-ended body stream, so they will never emit any stream events
* (like `'data'` or `'end'`). You can use `req.readableEnded` to detect this case.
* @default false
* @since v24.12.0
*/
optimizeEmptyRequests?: boolean | undefined;
}
type RequestListener<
Request extends typeof IncomingMessage = typeof IncomingMessage,
@@ -939,7 +947,7 @@ declare module "http" {
* been transmitted are equal or not.
*
* Attempting to set a header field name or value that contains invalid characters
* will result in a \[`Error`\]\[\] being thrown.
* will result in a `Error` being thrown.
* @since v0.1.30
*/
writeHead(
@@ -1020,6 +1028,7 @@ declare module "http" {
*
* ```js
* import http from 'node:http';
* const agent = new http.Agent({ keepAlive: true });
*
* // Server has a 5 seconds keep-alive timeout by default
* http
@@ -1661,20 +1670,31 @@ declare module "http" {
/**
* Produces a socket/stream to be used for HTTP requests.
*
* By default, this function is the same as `net.createConnection()`. However,
* custom agents may override this method in case greater flexibility is desired.
* By default, this function behaves identically to `net.createConnection()`, synchronously
* returning the created socket. The optional `callback` parameter in the signature is not
* used by this default implementation.
*
* A socket/stream can be supplied in one of two ways: by returning the
* socket/stream from this function, or by passing the socket/stream to `callback`.
* However, custom agents may override this method to provide greater flexibility,
* for example, to create sockets asynchronously. When overriding `createConnection`:
*
* This method is guaranteed to return an instance of the `net.Socket` class,
* a subclass of `stream.Duplex`, unless the user specifies a socket
* type other than `net.Socket`.
* 1. **Synchronous socket creation**: The overriding method can return the socket/stream directly.
* 2. **Asynchronous socket creation**: The overriding method can accept the `callback` and pass
* the created socket/stream to it (e.g., `callback(null, newSocket)`). If an error occurs during
* socket creation, it should be passed as the first argument to the `callback` (e.g., `callback(err)`).
*
* `callback` has a signature of `(err, stream)`.
* The agent will call the provided `createConnection` function with `options` and this internal
* `callback`. The `callback` provided by the agent has a signature of `(err, stream)`.
* @since v0.11.4
* @param options Options containing connection details. Check `createConnection` for the format of the options
* @param callback Callback function that receives the created socket
* @param options Options containing connection details. Check `net.createConnection()`
* for the format of the options. For custom agents, this object is passed
* to the custom `createConnection` function.
* @param callback (Optional, primarily for custom agents) A function to be called by a custom
* `createConnection` implementation when the socket is created, especially for
* asynchronous operations.
* @returns `stream.Duplex` The created socket. This is returned by the default implementation
* or by a custom synchronous `createConnection` implementation. If a
* custom `createConnection` uses the `callback` for asynchronous operation,
* this return value might not be the primary way to obtain the socket.
*/
createConnection(
options: ClientRequestArgs,

View File

@@ -25,6 +25,12 @@ declare module "https" {
}
/**
* An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
*
* Like `http.Agent`, the `createConnection(options[, callback])` method can be overridden to customize
* how TLS connections are established.
*
* > See [`agent.createConnection()`](https://nodejs.org/docs/latest-v24.x/api/http.html#agentcreateconnectionoptions-callback)
* for details on overriding this method, including asynchronous socket creation with a callback.
* @since v0.4.5
*/
class Agent extends http.Agent {

View File

@@ -1791,6 +1791,18 @@ declare module "inspector" {
*/
headers: Headers;
}
interface EnableParameterType {
/**
* Buffer size in bytes to use when preserving network payloads (XHRs, etc).
* @experimental
*/
maxTotalBufferSize?: number | undefined;
/**
* Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).
* @experimental
*/
maxResourceBufferSize?: number | undefined;
}
interface GetRequestPostDataParameterType {
/**
* Identifier of the network request to get content for.
@@ -2379,6 +2391,7 @@ declare module "inspector" {
/**
* Enables network tracking, network events will now be delivered to the client.
*/
post(method: "Network.enable", params?: Network.EnableParameterType, callback?: (err: Error | null) => void): void;
post(method: "Network.enable", callback?: (err: Error | null) => void): void;
/**
* Returns post data sent with the request. Returns an error when no data was sent with the request.
@@ -3477,7 +3490,7 @@ declare module "inspector/promises" {
/**
* Enables network tracking, network events will now be delivered to the client.
*/
post(method: "Network.enable"): Promise<void>;
post(method: "Network.enable", params?: Network.EnableParameterType): Promise<void>;
/**
* Returns post data sent with the request. Returns an error when no data was sent with the request.
*/

43
node_modules/@types/node/module.d.ts generated vendored
View File

@@ -80,37 +80,48 @@ declare module "module" {
*/
directory?: string;
}
interface EnableCompileCacheOptions {
/**
* Optional. Directory to store the compile cache. If not specified, the directory specified by
* the [`NODE_COMPILE_CACHE=dir`](https://nodejs.org/docs/latest-v24.x/api/cli.html#node_compile_cachedir)
* environment variable will be used if it's set, or `path.join(os.tmpdir(), 'node-compile-cache')` otherwise.
* @since v24.12.0
*/
directory?: string | undefined;
/**
* Optional. If `true`, enables portable compile cache so that the cache can be reused even if the project directory
* is moved. This is a best-effort feature. If not specified, it will depend on whether the environment variable
* [NODE_COMPILE_CACHE_PORTABLE=1](https://nodejs.org/docs/latest-v24.x/api/cli.html#node_compile_cache_portable1) is set.
* @since v24.12.0
*/
portable?: boolean | undefined;
}
/**
* Enable [module compile cache](https://nodejs.org/docs/latest-v24.x/api/module.html#module-compile-cache)
* in the current Node.js instance.
*
* If `cacheDir` is not specified, Node.js will either use the directory specified by the
* `NODE_COMPILE_CACHE=dir` environment variable if it's set, or use
* `path.join(os.tmpdir(), 'node-compile-cache')` otherwise. For general use cases, it's
* recommended to call `module.enableCompileCache()` without specifying the `cacheDir`,
* so that the directory can be overridden by the `NODE_COMPILE_CACHE` environment
* For general use cases, it's recommended to call `module.enableCompileCache()` without specifying the
* `options.directory`, so that the directory can be overridden by the `NODE_COMPILE_CACHE` environment
* variable when necessary.
*
* Since compile cache is supposed to be a quiet optimization that is not required for the
* application to be functional, this method is designed to not throw any exception when the
* compile cache cannot be enabled. Instead, it will return an object containing an error
* message in the `message` field to aid debugging.
* If compile cache is enabled successfully, the `directory` field in the returned object
* contains the path to the directory where the compile cache is stored. The `status`
* field in the returned object would be one of the `module.constants.compileCacheStatus`
* values to indicate the result of the attempt to enable the
* Since compile cache is supposed to be a optimization that is not mission critical, this method is
* designed to not throw any exception when the compile cache cannot be enabled. Instead, it will return
* an object containing an error message in the `message` field to aid debugging. If compile cache is
* enabled successfully, the `directory` field in the returned object contains the path to the directory
* where the compile cache is stored. The `status` field in the returned object would be one of the
* `module.constants.compileCacheStatus` values to indicate the result of the attempt to enable the
* [module compile cache](https://nodejs.org/docs/latest-v24.x/api/module.html#module-compile-cache).
*
* This method only affects the current Node.js instance. To enable it in child worker threads,
* either call this method in child worker threads too, or set the
* `process.env.NODE_COMPILE_CACHE` value to compile cache directory so the behavior can
* be inherited into the child workers. The directory can be obtained either from the
* `directory` field returned by this method, or with {@link getCompileCacheDir}.
* `directory` field returned by this method, or with {@link getCompileCacheDir `module.getCompileCacheDir()`}.
* @since v22.8.0
* @param cacheDir Optional path to specify the directory where the compile cache
* @param options Optional. If a string is passed, it is considered to be `options.directory`.
* will be stored/retrieved.
*/
function enableCompileCache(cacheDir?: string): EnableCompileCacheResult;
function enableCompileCache(options?: string | EnableCompileCacheOptions): EnableCompileCacheResult;
/**
* Flush the [module compile cache](https://nodejs.org/docs/latest-v24.x/api/module.html#module-compile-cache)
* accumulated from modules already loaded

View File

@@ -1,6 +1,6 @@
{
"name": "@types/node",
"version": "24.10.13",
"version": "24.12.0",
"description": "TypeScript definitions for node",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
"license": "MIT",
@@ -150,6 +150,6 @@
"undici-types": "~7.16.0"
},
"peerDependencies": {},
"typesPublisherContentHash": "2ec3065bf306401d19db2ee65619ca53b48d5461db1133c7eeb53d407b8dcbc8",
"typesPublisherContentHash": "2bd5c87e6ae2c44201cb3aab9e54edcee1ed9555c740d1b7788d5f9e9defded9",
"typeScriptVersion": "5.2"
}

View File

@@ -200,14 +200,6 @@ declare module "perf_hooks" {
active: number;
utilization: number;
}
/**
* @param utilization1 The result of a previous call to `eventLoopUtilization()`.
* @param utilization2 The result of a previous call to `eventLoopUtilization()` prior to `utilization1`.
*/
type EventLoopUtilityFunction = (
utilization1?: EventLoopUtilization,
utilization2?: EventLoopUtilization,
) => EventLoopUtilization;
interface MarkOptions {
/**
* Additional optional detail to include with the mark.
@@ -264,11 +256,19 @@ declare module "perf_hooks" {
*/
clearResourceTimings(name?: string): void;
/**
* eventLoopUtilization is similar to CPU utilization except that it is calculated using high precision wall-clock time.
* It represents the percentage of time the event loop has spent outside the event loop's event provider (e.g. epoll_wait).
* No other CPU idle time is taken into consideration.
* This is an alias of `perf_hooks.eventLoopUtilization()`.
*
* _This property is an extension by Node.js. It is not available in Web browsers._
* @since v14.10.0, v12.19.0
* @param utilization1 The result of a previous call to
* `eventLoopUtilization()`.
* @param utilization2 The result of a previous call to
* `eventLoopUtilization()` prior to `utilization1`.
*/
eventLoopUtilization: EventLoopUtilityFunction;
eventLoopUtilization(
utilization1?: EventLoopUtilization,
utilization2?: EventLoopUtilization,
): EventLoopUtilization;
/**
* Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`.
* If you are only interested in performance entries of certain types or that have certain names, see
@@ -371,41 +371,12 @@ declare module "perf_hooks" {
*/
readonly timeOrigin: number;
/**
* This is an alias of `perf_hooks.timerify()`.
*
* _This property is an extension by Node.js. It is not available in Web browsers._
*
* Wraps a function within a new function that measures the running time of the wrapped function.
* A `PerformanceObserver` must be subscribed to the `'function'` event type in order for the timing details to be accessed.
*
* ```js
* import {
* performance,
* PerformanceObserver,
* } from 'node:perf_hooks';
*
* function someFunction() {
* console.log('hello world');
* }
*
* const wrapped = performance.timerify(someFunction);
*
* const obs = new PerformanceObserver((list) => {
* console.log(list.getEntries()[0].duration);
*
* performance.clearMarks();
* performance.clearMeasures();
* obs.disconnect();
* });
* obs.observe({ entryTypes: ['function'] });
*
* // A performance timeline entry will be created
* wrapped();
* ```
*
* If the wrapped function returns a promise, a finally handler will be attached to the promise and the duration will be reported
* once the finally handler is invoked.
* @param fn
* @since v8.5.0
*/
timerify<T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions): T;
timerify<T extends (...args: any[]) => any>(fn: T, options?: TimerifyOptions): T;
/**
* An object which is JSON representation of the performance object. It is similar to
* [`window.performance.toJSON`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/toJSON) in browsers.
@@ -844,6 +815,83 @@ declare module "perf_hooks" {
*/
add(other: RecordableHistogram): void;
}
interface CreateHistogramOptions {
/**
* The lowest discernible value. Must be an integer value greater than 0.
* @default 1
*/
lowest?: number | bigint | undefined;
/**
* The highest recordable value. Must be an integer value that is equal to
* or greater than two times `lowest`.
* @default Number.MAX_SAFE_INTEGER
*/
highest?: number | bigint | undefined;
/**
* The number of accuracy digits. Must be a number between `1` and `5`.
* @default 3
*/
figures?: number | undefined;
}
/**
* Returns a {@link RecordableHistogram `RecordableHistogram`}.
* @since v15.9.0, v14.18.0
*/
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
/**
* The `eventLoopUtilization()` function returns an object that contains the
* cumulative duration of time the event loop has been both idle and active as a
* high resolution milliseconds timer. The `utilization` value is the calculated
* Event Loop Utilization (ELU).
*
* If bootstrapping has not yet finished on the main thread the properties have
* the value of `0`. The ELU is immediately available on
* [Worker threads](https://nodejs.org/docs/latest-v24.x/api/worker_threads.html#worker-threads)
* since bootstrap happens within the event loop.
*
* Both `utilization1` and `utilization2` are optional parameters.
*
* If `utilization1` is passed, then the delta between the current call's `active`
* and `idle` times, as well as the corresponding `utilization` value are
* calculated and returned (similar to `process.hrtime()`).
*
* If `utilization1` and `utilization2` are both passed, then the delta is
* calculated between the two arguments. This is a convenience option because,
* unlike `process.hrtime()`, calculating the ELU is more complex than a
* single subtraction.
*
* ELU is similar to CPU utilization, except that it only measures event loop
* statistics and not CPU usage. It represents the percentage of time the event
* loop has spent outside the event loop's event provider (e.g. `epoll_wait`).
* No other CPU idle time is taken into consideration. The following is an example
* of how a mostly idle process will have a high ELU.
*
* ```js
* import { eventLoopUtilization } from 'node:perf_hooks';
* import { spawnSync } from 'node:child_process';
*
* setImmediate(() => {
* const elu = eventLoopUtilization();
* spawnSync('sleep', ['5']);
* console.log(eventLoopUtilization(elu).utilization);
* });
* ```
*
* Although the CPU is mostly idle while running this script, the value of `utilization`
* is `1`. This is because the call to `child_process.spawnSync()` blocks the event loop
* from proceeding.
*
* Passing in a user-defined object instead of the result of a previous call to
* `eventLoopUtilization()` will lead to undefined behavior. The return values are not
* guaranteed to reflect any correct state of the event loop.
* @since v24.12.0
* @param utilization1 The result of a previous call to `eventLoopUtilization()`.
* @param utilization2 The result of a previous call to `eventLoopUtilization()` prior to `utilization1`.
*/
function eventLoopUtilization(
utilization1?: EventLoopUtilization,
utilization2?: EventLoopUtilization,
): EventLoopUtilization;
/**
* _This property is an extension by Node.js. It is not available in Web browsers._
*
@@ -873,28 +921,40 @@ declare module "perf_hooks" {
* @since v11.10.0
*/
function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;
interface CreateHistogramOptions {
/**
* The minimum recordable value. Must be an integer value greater than 0.
* @default 1
*/
lowest?: number | bigint | undefined;
/**
* The maximum recordable value. Must be an integer value greater than min.
* @default Number.MAX_SAFE_INTEGER
*/
highest?: number | bigint | undefined;
/**
* The number of accuracy digits. Must be a number between 1 and 5.
* @default 3
*/
figures?: number | undefined;
}
/**
* Returns a `RecordableHistogram`.
* @since v15.9.0, v14.18.0
* _This property is an extension by Node.js. It is not available in Web browsers._
*
* Wraps a function within a new function that measures the running time of the
* wrapped function. A `PerformanceObserver` must be subscribed to the `'function'`
* event type in order for the timing details to be accessed.
*
* ```js
* import { timerify, performance, PerformanceObserver } from 'node:perf_hooks';
*
* function someFunction() {
* console.log('hello world');
* }
*
* const wrapped = timerify(someFunction);
*
* const obs = new PerformanceObserver((list) => {
* console.log(list.getEntries()[0].duration);
*
* performance.clearMarks();
* performance.clearMeasures();
* obs.disconnect();
* });
* obs.observe({ entryTypes: ['function'] });
*
* // A performance timeline entry will be created
* wrapped();
* ```
*
* If the wrapped function returns a promise, a finally handler will be attached
* to the promise and the duration will be reported once the finally handler is invoked.
* @since v24.12.0
*/
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
function timerify<T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions): T;
import {
performance as _performance,
PerformanceEntry as _PerformanceEntry,

View File

@@ -235,7 +235,7 @@ declare module "process" {
/**
* A value that is `"strip"` by default,
* `"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if
* Node.js is run with `--no-experimental-strip-types`.
* Node.js is run with `--no-strip-types`.
* @since v22.10.0
*/
readonly typescript: "strip" | "transform" | false;
@@ -344,12 +344,7 @@ declare module "process" {
isTTY?: true | undefined;
}
// Alias for compatibility
interface ProcessEnv extends Dict<string> {
/**
* Can be used to change the default timezone at runtime
*/
TZ?: string | undefined;
}
interface ProcessEnv extends Dict<string> {}
interface HRTime {
/**
* This is the legacy version of {@link process.hrtime.bigint()}

41
node_modules/@types/node/sqlite.d.ts generated vendored
View File

@@ -6,12 +6,7 @@
* import sqlite from 'node:sqlite';
* ```
*
* This module is only available under the `node:` scheme. The following will not
* work:
*
* ```js
* import sqlite from 'sqlite';
* ```
* This module is only available under the `node:` scheme.
*
* The following example shows the basic usage of the `node:sqlite` module to open
* an in-memory database, write data to the database, and then read the data back.
@@ -123,6 +118,14 @@ declare module "node:sqlite" {
* @default false
*/
allowUnknownNamedParameters?: boolean | undefined;
/**
* If `true`, enables the defensive flag. When the defensive flag is enabled,
* language features that allow ordinary SQL to deliberately corrupt the database
* file are disabled. The defensive flag can also be set using `enableDefensive()`.
* @since v24.12.0
* @default true
*/
defensive?: boolean | undefined;
}
interface CreateSessionOptions {
/**
@@ -294,6 +297,16 @@ declare module "node:sqlite" {
* @param allow Whether to allow loading extensions.
*/
enableLoadExtension(allow: boolean): void;
/**
* Enables or disables the defensive flag. When the defensive flag is active,
* language features that allow ordinary SQL to deliberately corrupt the
* database file are disabled.
* See [`SQLITE_DBCONFIG_DEFENSIVE`](https://www.sqlite.org/c3ref/c_dbconfig_defensive.html#sqlitedbconfigdefensive)
* in the SQLite documentation for details.
* @since v24.12.0
* @param active Whether to set the defensive flag.
*/
enableDefensive(active: boolean): void;
/**
* This method is a wrapper around [`sqlite3_db_filename()`](https://sqlite.org/c3ref/db_filename.html)
* @since v24.0.0
@@ -413,7 +426,7 @@ declare module "node:sqlite" {
*/
prepare(sql: string): StatementSync;
/**
* Creates a new `SQLTagStore`, which is an LRU (Least Recently Used) cache for
* Creates a new {@link SQLTagStore `SQLTagStore`}, which is an LRU (Least Recently Used) cache for
* storing prepared statements. This allows for the efficient reuse of prepared
* statements by tagging them with a unique identifier.
*
@@ -427,7 +440,7 @@ declare module "node:sqlite" {
* import { DatabaseSync } from 'node:sqlite';
*
* const db = new DatabaseSync(':memory:');
* const sql = db.createSQLTagStore();
* const sql = db.createTagStore();
*
* db.exec('CREATE TABLE users (id INT, name TEXT)');
*
@@ -450,6 +463,7 @@ declare module "node:sqlite" {
* // ]
* ```
* @since v24.9.0
* @param maxSize The maximum number of prepared statements to cache. **Default**: `1000`.
* @returns A new SQL tag store for caching prepared statements.
*/
createTagStore(maxSize?: number): SQLTagStore;
@@ -468,6 +482,8 @@ declare module "node:sqlite" {
* [`sqlite3changeset_apply()`](https://www.sqlite.org/session/sqlite3changeset_apply.html).
*
* ```js
* import { DatabaseSync } from 'node:sqlite';
*
* const sourceDb = new DatabaseSync(':memory:');
* const targetDb = new DatabaseSync(':memory:');
*
@@ -525,19 +541,24 @@ declare module "node:sqlite" {
* [`sqlite3session_delete()`](https://www.sqlite.org/session/sqlite3session_delete.html).
*/
close(): void;
/**
* Closes the session. If the session is already closed, does nothing.
* @since v24.9.0
*/
[Symbol.dispose](): void;
}
/**
* This class represents a single LRU (Least Recently Used) cache for storing
* prepared statements.
*
* Instances of this class are created via the database.createSQLTagStore() method,
* Instances of this class are created via the database.createTagStore() method,
* not by using a constructor. The store caches prepared statements based on the
* provided SQL query string. When the same query is seen again, the store
* retrieves the cached statement and safely applies the new values through
* parameter binding, thereby preventing attacks like SQL injection.
*
* The cache has a maxSize that defaults to 1000 statements, but a custom size can
* be provided (e.g., database.createSQLTagStore(100)). All APIs exposed by this
* be provided (e.g., database.createTagStore(100)). All APIs exposed by this
* class execute synchronously.
* @since v24.9.0
*/

14
node_modules/@types/node/tls.d.ts generated vendored
View File

@@ -15,31 +15,31 @@ declare module "tls" {
import * as stream from "stream";
const CLIENT_RENEG_LIMIT: number;
const CLIENT_RENEG_WINDOW: number;
interface Certificate {
interface Certificate extends NodeJS.Dict<string | string[]> {
/**
* Country code.
*/
C: string;
C?: string | string[];
/**
* Street.
*/
ST: string;
ST?: string | string[];
/**
* Locality.
*/
L: string;
L?: string | string[];
/**
* Organization.
*/
O: string;
O?: string | string[];
/**
* Organizational unit.
*/
OU: string;
OU?: string | string[];
/**
* Common name.
*/
CN: string;
CN?: string | string[];
}
interface PeerCertificate {
/**

4
node_modules/@types/node/url.d.ts generated vendored
View File

@@ -80,7 +80,7 @@ declare module "url" {
* function getURL(req) {
* const proto = req.headers['x-forwarded-proto'] || 'https';
* const host = req.headers['x-forwarded-host'] || req.headers.host || 'example.com';
* return new URL(req.url || '/', `${proto}://${host}`);
* return new URL(`${proto}://${host}${req.url || '/'}`);
* }
* ```
*
@@ -90,7 +90,7 @@ declare module "url" {
*
* ```js
* function getURL(req) {
* return new URL(req.url || '/', 'https://example.com');
* return new URL(`https://example.com${req.url || '/'}`);
* }
* ```
* @since v0.1.25

10
node_modules/@types/node/util.d.ts generated vendored
View File

@@ -792,6 +792,14 @@ declare module "util" {
*/
export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger;
export { debuglog as debug };
export interface DeprecateOptions {
/**
* When false do not change the prototype of object while emitting the deprecation warning.
* @since v24.12.0
* @default true
*/
modifyPrototype?: boolean | undefined;
}
/**
* The `util.deprecate()` method wraps `fn` (which may be a function or class) in
* such a way that it is marked as deprecated.
@@ -852,7 +860,7 @@ declare module "util" {
* @param code A deprecation code. See the `list of deprecated APIs` for a list of codes.
* @return The deprecated function wrapped to emit a warning.
*/
export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
export function deprecate<T extends Function>(fn: T, msg: string, code?: string, options?: DeprecateOptions): T;
export interface IsDeepStrictEqualOptions {
/**
* If `true`, prototype and constructor

26
node_modules/@types/node/v8.d.ts generated vendored
View File

@@ -401,6 +401,21 @@ declare module "v8" {
* @since v12.8.0
*/
function getHeapCodeStatistics(): HeapCodeStatistics;
/**
* @since v24.12.0
*/
interface SyncCPUProfileHandle {
/**
* Stopping collecting the profile and return the profile data.
* @since v24.12.0
*/
stop(): string;
/**
* Stopping collecting the profile and the profile will be discarded.
* @since v24.12.0
*/
[Symbol.dispose](): void;
}
/**
* @since v24.8.0
*/
@@ -466,6 +481,17 @@ declare module "v8" {
* @since v23.10.0, v22.15.0
*/
function isStringOneByteRepresentation(content: string): boolean;
/**
* Starting a CPU profile then return a `SyncCPUProfileHandle` object. This API supports `using` syntax.
*
* ```js
* const handle = v8.startCpuProfile();
* const profile = handle.stop();
* console.log(profile);
* ```
* @since v24.12.0
*/
function startCpuProfile(): SyncCPUProfileHandle;
/**
* @since v8.0.0
*/

39
node_modules/@types/node/vm.d.ts generated vendored
View File

@@ -748,8 +748,8 @@ declare module "vm" {
* // The "secret" variable refers to the global variable we added to
* // "contextifiedObject" when creating the context.
* export default secret;
* `, { context: referencingModule.context });
* moduleMap.set(specifier, linkedModule);
* `, { context: module.context });
* moduleMap.set(specifier, requestedModule);
* // Resolve the dependencies of the new module as well.
* resolveAndLinkDependencies(requestedModule);
* }
@@ -819,19 +819,34 @@ declare module "vm" {
*/
status: ModuleStatus;
/**
* Evaluate the module.
* Evaluate the module and its depenendencies. Corresponds to the [Evaluate() concrete method](https://tc39.es/ecma262/#sec-moduleevaluation)
* field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records)s in the ECMAScript specification.
*
* This must be called after the module has been linked; otherwise it will reject.
* It could be called also when the module has already been evaluated, in which
* case it will either do nothing if the initial evaluation ended in success
* (`module.status` is `'evaluated'`) or it will re-throw the exception that the
* initial evaluation resulted in (`module.status` is `'errored'`).
* If the module is a `vm.SourceTextModule`, `evaluate()` must be called after the module has been instantiated;
* otherwise `evaluate()` will return a rejected promise.
*
* This method cannot be called while the module is being evaluated
* (`module.status` is `'evaluating'`).
* For a `vm.SourceTextModule`, the promise returned by `evaluate()` may be fulfilled either synchronously or asynchronously:
* 1. If the `vm.SourceTextModule` has no top-level `await` in itself or any of its dependencies, the promise will be
* fulfilled synchronously after the module and all its dependencies have been evaluated.
* 1. If the evaluation succeeds, the promise will be _synchronously_ resolved to `undefined`.
* 2. If the evaluation results in an exception, the promise will be _synchronously_ rejected with the exception that causes the evaluation to fail, which is the same as `module.error`.
* 2. If the `vm.SourceTextModule` has top-level `await` in itself or any of its dependencies, the promise will be fulfilled asynchronously after the module and all its dependencies have been evaluated.
* 1. If the evaluation succeeds, the promise will be _asynchronously_ resolved to `undefined`.
* 2. If the evaluation results in an exception, the promise will be _asynchronously_ rejected with the exception that causes the evaluation to fail.
*
* Corresponds to the [Evaluate() concrete method](https://tc39.es/ecma262/#sec-moduleevaluation) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in the
* ECMAScript specification.
* If the module is a `vm.SyntheticModule`, `evaluate()` always returns a promise that fulfills synchronously,
* see the specification of [Evaluate() of a Synthetic Module Record](https://tc39.es/ecma262/#sec-smr-Evaluate):
* 1. If the `evaluateCallback` passed to its constructor throws an exception synchronously, `evaluate()` returns a promise that will be synchronously rejected with that exception.
* 2. If the `evaluateCallback` does not throw an exception, `evaluate()` returns a promise that will be synchronously resolved to `undefined`.
*
* The `evaluateCallback` of a `vm.SyntheticModule` is executed synchronously within the `evaluate()` call, and its return value is discarded. This means if `evaluateCallback` is an asynchronous function, the promise
* returned by `evaluate()` will not reflect its asynchronous behavior, and any rejections from an asynchronous `evaluateCallback` will be lost.
*
* evaluate() could also be called again after the module has already been evaluated, in which case:
* 1. If the initial evaluation ended in success (`module.status` is `'evaluated'`), it will do nothing and return a promise that resolves to `undefined`.
* 2. If the initial evaluation resulted in an exception (`module.status` is `'errored'`), it will re-reject the exception that the initial evaluation resulted in.
*
* This method cannot be called while the module is being evaluated (`module.status` is `'evaluating'`).
* @return Fulfills with `undefined` upon success.
*/
evaluate(options?: ModuleEvaluateOptions): Promise<void>;

View File

@@ -3,7 +3,7 @@
* JavaScript in parallel. To access it:
*
* ```js
* import worker from 'node:worker_threads';
* import worker_threads from 'node:worker_threads';
* ```
*
* Workers (threads) are useful for performing CPU-intensive JavaScript operations.
@@ -57,8 +57,8 @@
declare module "worker_threads" {
import { Context } from "node:vm";
import { EventEmitter, NodeEventTarget } from "node:events";
import { EventLoopUtilityFunction } from "node:perf_hooks";
import { FileHandle } from "node:fs/promises";
import { Performance } from "node:perf_hooks";
import { Readable, Writable } from "node:stream";
import { ReadableStream, TransformStream, WritableStream } from "node:stream/web";
import { URL } from "node:url";
@@ -91,9 +91,7 @@ declare module "worker_threads" {
readonly port1: MessagePort;
readonly port2: MessagePort;
}
interface WorkerPerformance {
eventLoopUtilization: EventLoopUtilityFunction;
}
interface WorkerPerformance extends Pick<Performance, "eventLoopUtilization"> {}
type Transferable =
| ArrayBuffer
| MessagePort
@@ -410,7 +408,7 @@ declare module "worker_threads" {
readonly resourceLimits?: ResourceLimits | undefined;
/**
* An object that can be used to query performance information from a worker
* instance. Similar to `perf_hooks.performance`.
* instance.
* @since v15.1.0, v14.17.0, v12.22.0
*/
readonly performance: WorkerPerformance;
@@ -446,8 +444,8 @@ declare module "worker_threads" {
*/
terminate(): Promise<number>;
/**
* This method returns a `Promise` that will resolve to an object identical to `process.threadCpuUsage()`,
* or reject with an `ERR_WORKER_NOT_RUNNING` error if the worker is no longer running.
* This method returns a `Promise` that will resolve to an object identical to {@link process.threadCpuUsage()},
* or reject with an [`ERR_WORKER_NOT_RUNNING`](https://nodejs.org/docs/latest-v24.x/api/errors.html#err_worker_not_running) error if the worker is no longer running.
* This methods allows the statistics to be observed from outside the actual thread.
* @since v24.6.0
*/
@@ -556,49 +554,49 @@ declare module "worker_threads" {
* @since v24.2.0
*/
[Symbol.asyncDispose](): Promise<void>;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "error", listener: (err: any) => void): this;
addListener(event: "exit", listener: (exitCode: number) => void): this;
addListener(event: "message", listener: (value: any) => void): this;
addListener(event: "messageerror", listener: (error: Error) => void): this;
addListener(event: "online", listener: () => void): this;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
emit(event: "error", err: Error): boolean;
emit(event: "error", err: any): boolean;
emit(event: "exit", exitCode: number): boolean;
emit(event: "message", value: any): boolean;
emit(event: "messageerror", error: Error): boolean;
emit(event: "online"): boolean;
emit(event: string | symbol, ...args: any[]): boolean;
on(event: "error", listener: (err: Error) => void): this;
on(event: "error", listener: (err: any) => void): this;
on(event: "exit", listener: (exitCode: number) => void): this;
on(event: "message", listener: (value: any) => void): this;
on(event: "messageerror", listener: (error: Error) => void): this;
on(event: "online", listener: () => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "error", listener: (err: any) => void): this;
once(event: "exit", listener: (exitCode: number) => void): this;
once(event: "message", listener: (value: any) => void): this;
once(event: "messageerror", listener: (error: Error) => void): this;
once(event: "online", listener: () => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "error", listener: (err: any) => void): this;
prependListener(event: "exit", listener: (exitCode: number) => void): this;
prependListener(event: "message", listener: (value: any) => void): this;
prependListener(event: "messageerror", listener: (error: Error) => void): this;
prependListener(event: "online", listener: () => void): this;
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "error", listener: (err: any) => void): this;
prependOnceListener(event: "exit", listener: (exitCode: number) => void): this;
prependOnceListener(event: "message", listener: (value: any) => void): this;
prependOnceListener(event: "messageerror", listener: (error: Error) => void): this;
prependOnceListener(event: "online", listener: () => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: "error", listener: (err: Error) => void): this;
removeListener(event: "error", listener: (err: any) => void): this;
removeListener(event: "exit", listener: (exitCode: number) => void): this;
removeListener(event: "message", listener: (value: any) => void): this;
removeListener(event: "messageerror", listener: (error: Error) => void): this;
removeListener(event: "online", listener: () => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
off(event: "error", listener: (err: Error) => void): this;
off(event: "error", listener: (err: any) => void): this;
off(event: "exit", listener: (exitCode: number) => void): this;
off(event: "message", listener: (value: any) => void): this;
off(event: "messageerror", listener: (error: Error) => void): this;
@@ -691,7 +689,7 @@ declare module "worker_threads" {
var locks: LockManager;
/**
* Mark an object as not transferable. If `object` occurs in the transfer list of
* a `port.postMessage()` call, it is ignored.
* a {@link MessagePort.postMessage port.postMessage()} call, it is ignored.
*
* In particular, this makes sense for objects that can be cloned, rather than
* transferred, and which are used by other objects on the sending side.
@@ -813,13 +811,13 @@ declare module "worker_threads" {
*
* if (isMainThread) {
* setEnvironmentData('Hello', 'World!');
* const worker = new Worker(__filename);
* const worker = new Worker(new URL(import.meta.url));
* } else {
* console.log(getEnvironmentData('Hello')); // Prints 'World!'.
* }
* ```
* @since v15.12.0, v14.18.0
* @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
* @param key Any arbitrary, cloneable JavaScript value that can be used as a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map Map} key.
*/
function getEnvironmentData(key: Serializable): Serializable;
/**

72
node_modules/@types/node/zlib.d.ts generated vendored
View File

@@ -108,10 +108,14 @@ declare module "zlib" {
*/
chunkSize?: number | undefined;
windowBits?: number | undefined;
level?: number | undefined; // compression only
memLevel?: number | undefined; // compression only
strategy?: number | undefined; // compression only
dictionary?: NodeJS.ArrayBufferView | ArrayBuffer | undefined; // deflate/inflate only, empty dictionary by default
/** compression only */
level?: number | undefined;
/** compression only */
memLevel?: number | undefined;
/** compression only */
strategy?: number | undefined;
/** deflate/inflate only, empty dictionary by default */
dictionary?: NodeJS.ArrayBufferView | ArrayBuffer | undefined;
/**
* If `true`, returns an object with `buffer` and `engine`.
*/
@@ -201,24 +205,84 @@ declare module "zlib" {
interface ZlibReset {
reset(): void;
}
/**
* @since v10.16.0
*/
class BrotliCompress extends stream.Transform {
constructor(options?: BrotliOptions);
}
interface BrotliCompress extends stream.Transform, Zlib {}
/**
* @since v10.16.0
*/
class BrotliDecompress extends stream.Transform {
constructor(options?: BrotliOptions);
}
interface BrotliDecompress extends stream.Transform, Zlib {}
/**
* @since v0.5.8
*/
class Gzip extends stream.Transform {
constructor(options?: ZlibOptions);
}
interface Gzip extends stream.Transform, Zlib {}
/**
* @since v0.5.8
*/
class Gunzip extends stream.Transform {
constructor(options?: ZlibOptions);
}
interface Gunzip extends stream.Transform, Zlib {}
/**
* @since v0.5.8
*/
class Deflate extends stream.Transform {
constructor(options?: ZlibOptions);
}
interface Deflate extends stream.Transform, Zlib, ZlibReset, ZlibParams {}
/**
* @since v0.5.8
*/
class Inflate extends stream.Transform {
constructor(options?: ZlibOptions);
}
interface Inflate extends stream.Transform, Zlib, ZlibReset {}
/**
* @since v0.5.8
*/
class DeflateRaw extends stream.Transform {
constructor(options?: ZlibOptions);
}
interface DeflateRaw extends stream.Transform, Zlib, ZlibReset, ZlibParams {}
/**
* @since v0.5.8
*/
class InflateRaw extends stream.Transform {
constructor(options?: ZlibOptions);
}
interface InflateRaw extends stream.Transform, Zlib, ZlibReset {}
/**
* @since v0.5.8
*/
class Unzip extends stream.Transform {
constructor(options?: ZlibOptions);
}
interface Unzip extends stream.Transform, Zlib {}
/**
* @since v22.15.0
* @experimental
*/
class ZstdCompress extends stream.Transform {
constructor(options?: ZstdOptions);
}
interface ZstdCompress extends stream.Transform, Zlib {}
/**
* @since v22.15.0
* @experimental
*/
class ZstdDecompress extends stream.Transform {
constructor(options?: ZstdOptions);
}
interface ZstdDecompress extends stream.Transform, Zlib {}
/**
* Computes a 32-bit [Cyclic Redundancy Check](https://en.wikipedia.org/wiki/Cyclic_redundancy_check) checksum of `data`.

View File

@@ -8,7 +8,7 @@ This package contains type definitions for react (https://react.dev/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react.
### Additional Details
* Last updated: Thu, 05 Feb 2026 10:12:25 GMT
* Last updated: Wed, 11 Feb 2026 11:44:57 GMT
* Dependencies: [csstype](https://npmjs.com/package/csstype)
# Credits

View File

@@ -174,4 +174,11 @@ declare module "." {
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {
srcObject: Blob | MediaSource | MediaStream;
}
// @enableOptimisticKey
export const optimisticKey: unique symbol;
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES {
optimisticKey: typeof optimisticKey;
}
}

10
node_modules/@types/react/index.d.ts generated vendored
View File

@@ -226,12 +226,20 @@ declare namespace React {
type ComponentState = any;
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES {}
/**
* A value which uniquely identifies a node among items in an array.
*
* @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs}
*/
type Key = string | number | bigint;
type Key =
| string
| number
| bigint
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES[
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES
];
/**
* @internal The props any component can receive.

View File

@@ -1,6 +1,6 @@
{
"name": "@types/react",
"version": "19.2.13",
"version": "19.2.14",
"description": "TypeScript definitions for react",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react",
"license": "MIT",
@@ -205,6 +205,6 @@
"csstype": "^3.2.2"
},
"peerDependencies": {},
"typesPublisherContentHash": "20f3b89e619c9f614e881f4a928351ed1d1a9c228d36dccb133288229bc0aff6",
"typesPublisherContentHash": "daae8d23e06b3d45da3803abb3f0bad661cffb4c40282d6886d8dfde7d5eea01",
"typeScriptVersion": "5.2"
}

View File

@@ -174,4 +174,11 @@ declare module "." {
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {
srcObject: Blob | MediaSource | MediaStream;
}
// @enableOptimisticKey
export const optimisticKey: unique symbol;
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES {
optimisticKey: typeof optimisticKey;
}
}

View File

@@ -226,12 +226,20 @@ declare namespace React {
type ComponentState = any;
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES {}
/**
* A value which uniquely identifies a node among items in an array.
*
* @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs}
*/
type Key = string | number | bigint;
type Key =
| string
| number
| bigint
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES[
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES
];
/**
* @internal The props any component can receive.

View File

@@ -98,7 +98,7 @@ exports.default = (0, util_1.createRule)({
}
return;
}
const isolatedDeclarations = context.parserOptions.isolatedDeclarations;
const isolatedDeclarations = context.languageOptions.parserOptions.isolatedDeclarations;
if (!isolatedDeclarations && lhs?.typeArguments && !rhs.typeArguments) {
const hasParens = context.sourceCode.getTokenAfter(rhs.callee)?.value === '(';
const extraComments = new Set(context.sourceCode.getCommentsInside(lhs.parent));

View File

@@ -269,17 +269,15 @@ exports.default = (0, util_1.createRule)({
continue;
}
const declarations = candidate.getDeclarations();
// If there are multiple declarations, at least one of them must not be
// the default object toString.
//
// This may only matter for older versions of TS
// see https://github.com/typescript-eslint/typescript-eslint/issues/8585
if (declarations?.length !== 1) {
if (!declarations?.length) {
continue;
}
// Not being the Object interface means this is user-defined.
if (!ts.isInterfaceDeclaration(declarations[0].parent) ||
declarations[0].parent.name.text !== 'Object') {
// If any declaration is not from the Object interface, this is
// user-defined (e.g. overloaded toString on a class or module).
// see https://github.com/typescript-eslint/typescript-eslint/issues/8585
// see https://github.com/typescript-eslint/typescript-eslint/issues/11945
if (declarations.some(declaration => !(ts.isInterfaceDeclaration(declaration.parent) &&
declaration.parent.name.text === 'Object'))) {
return false;
}
foundFallbackOnObject = true;

View File

@@ -69,7 +69,7 @@ exports.default = (0, util_1.createRule)({
},
],
create(context, [options]) {
const { jsDocParsingMode } = context.parserOptions;
const { jsDocParsingMode } = context.languageOptions.parserOptions;
const allow = options.allow;
if (jsDocParsingMode === 'none' || jsDocParsingMode === 'type-info') {
throw new Error(`Cannot be used with jsDocParsingMode: '${jsDocParsingMode}'.`);

View File

@@ -46,7 +46,7 @@ exports.default = (0, util_1.createRule)({
return initializer.operator === '-' ? -inner : inner;
}
case isStaticTemplateLiteral(initializer):
return initializer.quasis[0].value.cooked;
return initializer.quasis[0].value.cooked ?? undefined;
default:
return undefined;
}

View File

@@ -396,14 +396,6 @@ exports.default = (0, util_1.createRule)({
// The right side will be checked if the LogicalExpression is used in a conditional context
checkNode(node.left);
}
function checkIfWhileLoopIsNecessaryConditional(node) {
if (allowConstantLoopConditionsOption === 'only-allowed-literals' &&
node.test.type === utils_1.AST_NODE_TYPES.Literal &&
constantLoopConditionsAllowedLiterals.has(node.test.value)) {
return;
}
checkIfLoopIsNecessaryConditional(node);
}
/**
* Checks that a testable expression of a loop is necessarily conditional, reports otherwise.
*/
@@ -412,6 +404,11 @@ exports.default = (0, util_1.createRule)({
// e.g. `for(;;)`
return;
}
if (allowConstantLoopConditionsOption === 'only-allowed-literals' &&
node.test.type === utils_1.AST_NODE_TYPES.Literal &&
constantLoopConditionsAllowedLiterals.has(node.test.value)) {
return;
}
if (allowConstantLoopConditionsOption === 'always' &&
tsutils.isTrueLiteralType((0, util_1.getConstrainedTypeAtLocation)(services, node.test))) {
return;
@@ -663,7 +660,7 @@ exports.default = (0, util_1.createRule)({
checkIfBoolExpressionIsNecessaryConditional(test, parent.discriminant, test, '===');
}
},
WhileStatement: checkIfWhileLoopIsNecessaryConditional,
WhileStatement: checkIfLoopIsNecessaryConditional,
};
},
});

View File

@@ -169,7 +169,8 @@ exports.default = (0, util_1.createRule)({
}
else if (receiverProperty.key.type === utils_1.AST_NODE_TYPES.TemplateLiteral &&
receiverProperty.key.quasis.length === 1) {
key = receiverProperty.key.quasis[0].value.cooked;
const cooked = (0, util_1.nullThrows)(receiverProperty.key.quasis[0].value.cooked, 'cooked can only be null inside a TaggedTemplateExpression, which is not possible here');
key = cooked;
}
else {
// can't figure out the name, so skip it

View File

@@ -236,6 +236,9 @@ exports.default = (0, util_1.createRule)({
if (signature.thisParameter) {
paramIndex--;
}
if (paramIndex < 0 || paramIndex >= params.length) {
return null;
}
return checker.getTypeOfSymbol(params[paramIndex]);
}
if (parent.type === utils_1.AST_NODE_TYPES.AssignmentPattern) {

View File

@@ -87,6 +87,7 @@ const NULLISH_FLAGS = ts.TypeFlags.Null | ts.TypeFlags.Undefined;
function isValidFalseBooleanCheckType(node, disallowFalseyLiteral, parserServices, options) {
const type = parserServices.getTypeAtLocation(node);
const types = (0, ts_api_utils_1.unionConstituents)(type);
const primitiveAndObjectParts = types.flatMap(type => (0, ts_api_utils_1.intersectionConstituents)(type));
if (disallowFalseyLiteral &&
/*
```
@@ -98,10 +99,10 @@ function isValidFalseBooleanCheckType(node, disallowFalseyLiteral, parserService
We don't want to consider these two cases because the boolean expression
narrows out the non-nullish falsy cases - so converting the chain to `x?.a`
would introduce a build error
*/ (types.some(t => (0, ts_api_utils_1.isBooleanLiteralType)(t) && t.intrinsicName === 'false') ||
types.some(t => (0, ts_api_utils_1.isStringLiteralType)(t) && t.value === '') ||
types.some(t => (0, ts_api_utils_1.isNumberLiteralType)(t) && t.value === 0) ||
types.some(t => (0, ts_api_utils_1.isBigIntLiteralType)(t) && t.value.base10Value === '0'))) {
*/ (primitiveAndObjectParts.some(t => (0, ts_api_utils_1.isBooleanLiteralType)(t) && t.intrinsicName === 'false') ||
primitiveAndObjectParts.some(t => (0, ts_api_utils_1.isStringLiteralType)(t) && t.value === '') ||
primitiveAndObjectParts.some(t => (0, ts_api_utils_1.isNumberLiteralType)(t) && t.value === 0) ||
primitiveAndObjectParts.some(t => (0, ts_api_utils_1.isBigIntLiteralType)(t) && t.value.base10Value === '0'))) {
return false;
}
let allowedFlags = NULLISH_FLAGS | ts.TypeFlags.Object;
@@ -123,7 +124,7 @@ function isValidFalseBooleanCheckType(node, disallowFalseyLiteral, parserService
if (options.checkBigInt === true) {
allowedFlags |= ts.TypeFlags.BigIntLike;
}
return types.every(t => (0, util_1.isTypeFlagSet)(t, allowedFlags));
return primitiveAndObjectParts.every(t => (0, util_1.isTypeFlagSet)(t, allowedFlags));
}
function gatherLogicalOperands(node, parserServices, sourceCode, options) {
const result = [];

View File

@@ -1,6 +1,8 @@
import type { TypeOrValueSpecifier } from '../util';
export type MessageIds = 'rejectAnError';
export type Options = [
{
allow?: TypeOrValueSpecifier[];
allowEmptyReject?: boolean;
allowThrowingAny?: boolean;
allowThrowingUnknown?: boolean;

View File

@@ -20,6 +20,10 @@ exports.default = (0, util_1.createRule)({
type: 'object',
additionalProperties: false,
properties: {
allow: {
...util_1.typeOrValueSpecifiersSchema,
description: 'Type specifiers that can be used as Promise rejection reasons.',
},
allowEmptyReject: {
type: 'boolean',
description: 'Whether to allow calls to `Promise.reject()` with no arguments.',
@@ -38,6 +42,7 @@ exports.default = (0, util_1.createRule)({
},
defaultOptions: [
{
allow: [],
allowEmptyReject: false,
allowThrowingAny: false,
allowThrowingUnknown: false,
@@ -49,6 +54,9 @@ exports.default = (0, util_1.createRule)({
const argument = callExpression.arguments.at(0);
if (argument) {
const type = services.getTypeAtLocation(argument);
if ((0, util_1.typeMatchesSomeSpecifier)(type, options.allow, services.program)) {
return;
}
if (options.allowThrowingAny && (0, util_1.isTypeAnyType)(type)) {
return;
}

View File

@@ -222,7 +222,11 @@ exports.default = (0, util_1.createRule)({
name: context.sourceCode.getText(nameNode),
},
*fix(fixer) {
yield fixer.insertTextBefore(nameNode, 'readonly ');
const readonlyInsertionTarget = esNode.type === utils_1.AST_NODE_TYPES.PropertyDefinition &&
esNode.computed
? (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(nameNode), 'Expected to find a token before computed property name')
: nameNode;
yield fixer.insertTextBefore(readonlyInsertionTarget, 'readonly ');
if (typeAnnotation) {
yield fixer.insertTextAfter(nameNode, `: ${typeAnnotation}`);
}
@@ -239,9 +243,25 @@ exports.default = (0, util_1.createRule)({
}
},
MemberExpression(node) {
if (classScopeStack.length !== 0 && !node.computed) {
if (classScopeStack.length === 0) {
return;
}
const classScope = classScopeStack[classScopeStack.length - 1];
if (!node.computed) {
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
handlePropertyAccessExpression(tsNode, tsNode.parent, classScopeStack[classScopeStack.length - 1]);
handlePropertyAccessExpression(tsNode, tsNode.parent, classScope);
}
else {
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
if (ts.isElementAccessExpression(tsNode) &&
ts.isBinaryExpression(tsNode.parent) &&
tsNode.parent.left === tsNode &&
tsutils.isAssignmentKind(tsNode.parent.operatorToken.kind)) {
const memberName = (0, util_1.getStaticMemberAccessValue)(node, context);
if (typeof memberName === 'string') {
classScope.addVariableModificationByName(tsNode.expression, memberName);
}
}
}
},
};
@@ -285,8 +305,7 @@ class ClassScope {
addDeclaredVariable(node) {
if (!(tsutils.isModifierFlagSet(node, ts.ModifierFlags.Private) ||
node.name.kind === ts.SyntaxKind.PrivateIdentifier) ||
tsutils.isModifierFlagSet(node, ts.ModifierFlags.Accessor | ts.ModifierFlags.Readonly) ||
ts.isComputedPropertyName(node.name)) {
tsutils.isModifierFlagSet(node, ts.ModifierFlags.Accessor | ts.ModifierFlags.Readonly)) {
return;
}
if (this.onlyInlineLambdas &&
@@ -294,25 +313,32 @@ class ClassScope {
!ts.isArrowFunction(node.initializer)) {
return;
}
const memberName = getMemberName(node.name);
if (memberName == null) {
return;
}
(tsutils.isModifierFlagSet(node, ts.ModifierFlags.Static)
? this.privateModifiableStatics
: this.privateModifiableMembers).set(node.name.getText(), node);
: this.privateModifiableMembers).set(memberName, node);
}
addVariableModification(node) {
const modifierType = this.checker.getTypeAtLocation(node.expression);
this.addVariableModificationByName(node.expression, node.name.text);
}
addVariableModificationByName(expression, memberName) {
const modifierType = this.checker.getTypeAtLocation(expression);
const relationOfModifierTypeToClass = this.getTypeToClassRelation(modifierType);
if (relationOfModifierTypeToClass === TypeToClassRelation.Instance &&
this.constructorScopeDepth === DIRECTLY_INSIDE_CONSTRUCTOR) {
this.memberVariableWithConstructorModifications.add(node.name.text);
this.memberVariableWithConstructorModifications.add(memberName);
return;
}
if (relationOfModifierTypeToClass === TypeToClassRelation.Instance ||
relationOfModifierTypeToClass === TypeToClassRelation.ClassAndInstance) {
this.memberVariableModifications.add(node.name.text);
this.memberVariableModifications.add(memberName);
}
if (relationOfModifierTypeToClass === TypeToClassRelation.Class ||
relationOfModifierTypeToClass === TypeToClassRelation.ClassAndInstance) {
this.staticVariableModifications.add(node.name.text);
this.staticVariableModifications.add(memberName);
}
}
enterConstructor(node) {
@@ -390,3 +416,24 @@ class ClassScope {
return this.memberVariableWithConstructorModifications.has(name);
}
}
function getMemberName(name) {
if (ts.isIdentifier(name) ||
ts.isPrivateIdentifier(name) ||
ts.isStringLiteral(name) ||
ts.isNoSubstitutionTemplateLiteral(name) ||
ts.isNumericLiteral(name)) {
return name.text;
}
if (ts.isComputedPropertyName(name)) {
const expression = name.expression;
if (ts.isNumericLiteral(expression)) {
return expression.text;
}
if (ts.isPropertyAccessExpression(expression) &&
ts.isIdentifier(expression.expression) &&
expression.expression.text === 'Symbol') {
return expression.getText();
}
}
return undefined;
}

View File

@@ -164,11 +164,7 @@ exports.default = util.createRule({
if (argNode.type === utils_1.AST_NODE_TYPES.SpreadElement) {
continue;
}
// Check against the contextual type first
if (checkExpressionNode(argNode)) {
continue;
}
// Check against the types from all of the call signatures
// Collect the types from all of the call signatures
const argExpectedReturnTypes = funcSignatures
.map(s => s.parameters[argIdx])
.filter(Boolean)
@@ -176,20 +172,44 @@ exports.default = util.createRule({
.flatMap(paramType => tsutils.unionConstituents(paramType))
.flatMap(paramType => paramType.getCallSignatures())
.map(paramSignature => paramSignature.getReturnType());
const hasSingleSignature = funcSignatures.length === 1;
const allSignaturesReturnVoid = argExpectedReturnTypes.every(type => isVoid(type) ||
// Treat as void even though it might be technically any.
isNullishOrAny(type) ||
// `getTypeOfSymbolAtLocation` returns unresolved type parameters
// (e.g. `T`), even for overloads that match the call.
//
// Since we can't tell whether a generic overload currently matches,
// we treat TypeParameters similar to void.
tsutils.isTypeParameter(type));
// Check against the contextual type first, but only when there is a
// single signature or when all signatures return void, because
// `getContextualType` resolves to the first overload's return type even
// though there may be another one that matches the call.
if ((hasSingleSignature || allSignaturesReturnVoid) &&
checkExpressionNode(argNode)) {
continue;
}
if (
// At least one return type is void
argExpectedReturnTypes.some(type => tsutils.isTypeFlagSet(type, ts.TypeFlags.Void)) &&
argExpectedReturnTypes.some(isVoid) &&
// The rest are nullish or any
argExpectedReturnTypes.every(type => tsutils.isTypeFlagSet(type, ts.TypeFlags.VoidLike |
ts.TypeFlags.Undefined |
ts.TypeFlags.Null |
ts.TypeFlags.Any |
ts.TypeFlags.Never))) {
argExpectedReturnTypes.every(isNullishOrAny)) {
// We treat this argument as void even though it might be technically any.
reportIfNonVoidFunction(argNode);
}
}
}
function isNullishOrAny(type) {
return tsutils.isTypeFlagSet(type, ts.TypeFlags.VoidLike |
ts.TypeFlags.Undefined |
ts.TypeFlags.Null |
ts.TypeFlags.Any |
ts.TypeFlags.Never);
}
function isVoid(type) {
return tsutils.isTypeFlagSet(type, ts.TypeFlags.Void);
}
/**
* Finds errors in an object property.
*

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin",
"version": "8.55.0",
"version": "8.57.1",
"description": "TypeScript plugin for ESLint",
"files": [
"dist",
@@ -52,39 +52,39 @@
"ignore": "^7.0.5",
"natural-compare": "^1.4.0",
"ts-api-utils": "^2.4.0",
"@typescript-eslint/scope-manager": "8.55.0",
"@typescript-eslint/type-utils": "8.55.0",
"@typescript-eslint/visitor-keys": "8.55.0",
"@typescript-eslint/utils": "8.55.0"
"@typescript-eslint/scope-manager": "8.57.1",
"@typescript-eslint/visitor-keys": "8.57.1",
"@typescript-eslint/utils": "8.57.1",
"@typescript-eslint/type-utils": "8.57.1"
},
"devDependencies": {
"@types/json-schema": "^7.0.15",
"@types/mdast": "^4.0.4",
"@types/natural-compare": "*",
"@types/natural-compare": "^1.4.3",
"@types/react": "^18.3.21",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/coverage-v8": "^4.0.18",
"ajv": "^6.12.6",
"eslint": "*",
"json-schema": "*",
"eslint": "^10.0.0",
"json-schema": "^0.4.0",
"markdown-table": "^3.0.4",
"marked": "^15.0.12",
"mdast-util-from-markdown": "^2.0.2",
"mdast-util-mdx": "^3.0.0",
"micromark-extension-mdxjs": "^3.0.0",
"prettier": "3.8.0",
"rimraf": "*",
"rimraf": "^5.0.10",
"title-case": "^4.3.2",
"tsx": "*",
"typescript": "*",
"tsx": "^4.7.2",
"typescript": ">=4.8.4 <6.0.0",
"unist-util-visit": "^5.0.0",
"vitest": "^3.2.4",
"@typescript-eslint/rule-schema-to-typescript-types": "8.55.0",
"@typescript-eslint/rule-tester": "8.55.0"
"vitest": "^4.0.18",
"@typescript-eslint/rule-tester": "8.57.1",
"@typescript-eslint/rule-schema-to-typescript-types": "8.57.1"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
"typescript": ">=4.8.4 <6.0.0",
"@typescript-eslint/parser": "^8.55.0"
"@typescript-eslint/parser": "^8.57.1"
},
"funding": {
"type": "opencollective",

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/parser",
"version": "8.55.0",
"version": "8.57.1",
"description": "An ESLint custom parser which leverages TypeScript ESTree",
"files": [
"dist",
@@ -39,23 +39,23 @@
"eslint"
],
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
"typescript": ">=4.8.4 <6.0.0"
},
"dependencies": {
"debug": "^4.4.3",
"@typescript-eslint/scope-manager": "8.55.0",
"@typescript-eslint/types": "8.55.0",
"@typescript-eslint/typescript-estree": "8.55.0",
"@typescript-eslint/visitor-keys": "8.55.0"
"@typescript-eslint/scope-manager": "8.57.1",
"@typescript-eslint/types": "8.57.1",
"@typescript-eslint/typescript-estree": "8.57.1",
"@typescript-eslint/visitor-keys": "8.57.1"
},
"devDependencies": {
"@vitest/coverage-v8": "^3.2.4",
"eslint": "*",
"glob": "*",
"rimraf": "*",
"typescript": "*",
"vitest": "^3.2.4"
"@vitest/coverage-v8": "^4.0.18",
"eslint": "^10.0.0",
"glob": "^11.1.0",
"rimraf": "^5.0.10",
"typescript": ">=4.8.4 <6.0.0",
"vitest": "^4.0.18"
},
"funding": {
"type": "opencollective",

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/project-service",
"version": "8.55.0",
"version": "8.57.1",
"description": "Standalone TypeScript project service wrapper for linting.",
"files": [
"dist",
@@ -41,14 +41,14 @@
},
"dependencies": {
"debug": "^4.4.3",
"@typescript-eslint/tsconfig-utils": "^8.55.0",
"@typescript-eslint/types": "^8.55.0"
"@typescript-eslint/tsconfig-utils": "^8.57.1",
"@typescript-eslint/types": "^8.57.1"
},
"devDependencies": {
"@vitest/coverage-v8": "^3.2.4",
"rimraf": "*",
"typescript": "*",
"vitest": "^3.2.4"
"@vitest/coverage-v8": "^4.0.18",
"rimraf": "^5.0.10",
"typescript": ">=4.8.4 <6.0.0",
"vitest": "^4.0.18"
},
"funding": {
"type": "opencollective",

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/scope-manager",
"version": "8.55.0",
"version": "8.57.1",
"description": "TypeScript scope analyser for ESLint",
"files": [
"dist",
@@ -37,18 +37,18 @@
"estree"
],
"dependencies": {
"@typescript-eslint/types": "8.55.0",
"@typescript-eslint/visitor-keys": "8.55.0"
"@typescript-eslint/types": "8.57.1",
"@typescript-eslint/visitor-keys": "8.57.1"
},
"devDependencies": {
"@vitest/coverage-v8": "^3.2.4",
"@vitest/pretty-format": "^3.2.4",
"eslint": "*",
"glob": "*",
"rimraf": "*",
"typescript": "*",
"vitest": "^3.2.4",
"@typescript-eslint/typescript-estree": "8.55.0"
"@vitest/coverage-v8": "^4.0.18",
"@vitest/pretty-format": "^4.0.18",
"eslint": "^10.0.0",
"glob": "^11.1.0",
"rimraf": "^5.0.10",
"typescript": ">=4.8.4 <6.0.0",
"vitest": "^4.0.18",
"@typescript-eslint/typescript-estree": "8.57.1"
},
"funding": {
"type": "opencollective",

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/tsconfig-utils",
"version": "8.55.0",
"version": "8.57.1",
"description": "Utilities for collecting TSConfigs for linting scenarios.",
"files": [
"dist",
@@ -39,10 +39,10 @@
"typescript": ">=4.8.4 <6.0.0"
},
"devDependencies": {
"@vitest/coverage-v8": "^3.2.4",
"rimraf": "*",
"typescript": "*",
"vitest": "^3.2.4"
"@vitest/coverage-v8": "^4.0.18",
"rimraf": "^5.0.10",
"typescript": ">=4.8.4 <6.0.0",
"vitest": "^4.0.18"
},
"funding": {
"type": "opencollective",

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/type-utils",
"version": "8.55.0",
"version": "8.57.1",
"description": "Type utilities for working with TypeScript + ESLint together",
"files": [
"dist",
@@ -38,23 +38,23 @@
"dependencies": {
"debug": "^4.4.3",
"ts-api-utils": "^2.4.0",
"@typescript-eslint/types": "8.55.0",
"@typescript-eslint/utils": "8.55.0",
"@typescript-eslint/typescript-estree": "8.55.0"
"@typescript-eslint/types": "8.57.1",
"@typescript-eslint/utils": "8.57.1",
"@typescript-eslint/typescript-estree": "8.57.1"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
"typescript": ">=4.8.4 <6.0.0"
},
"devDependencies": {
"@types/babel__code-frame": "^7.0.6",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/coverage-v8": "^4.0.18",
"ajv": "^6.12.6",
"eslint": "*",
"rimraf": "*",
"typescript": "*",
"vitest": "^3.2.4",
"@typescript-eslint/parser": "8.55.0"
"eslint": "^10.0.0",
"rimraf": "^5.0.10",
"typescript": ">=4.8.4 <6.0.0",
"vitest": "^4.0.18",
"@typescript-eslint/parser": "8.57.1"
},
"funding": {
"type": "opencollective",

View File

@@ -1348,7 +1348,7 @@ export declare interface TemplateElement extends BaseNode {
type: AST_NODE_TYPES.TemplateElement;
tail: boolean;
value: {
cooked: string;
cooked: string | null;
raw: string;
};
}

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/types",
"version": "8.55.0",
"version": "8.57.1",
"description": "Types for the TypeScript-ESTree AST spec",
"files": [
"dist",
@@ -37,12 +37,12 @@
"estree"
],
"devDependencies": {
"@vitest/coverage-v8": "^3.2.4",
"eslint": "*",
"rimraf": "*",
"tsx": "*",
"typescript": "*",
"vitest": "^3.2.4"
"@vitest/coverage-v8": "^4.0.18",
"eslint": "^10.0.0",
"rimraf": "^5.0.10",
"tsx": "^4.7.2",
"typescript": ">=4.8.4 <6.0.0",
"vitest": "^4.0.18"
},
"funding": {
"type": "opencollective",
@@ -60,6 +60,9 @@
"build": {
"dependsOn": [
"copy-ast-spec"
],
"inputs": [
"{projectRoot}/src/generated/**/*"
]
},
"copy-ast-spec": {

View File

@@ -125,11 +125,6 @@ function nodeHasIllegalDecorators(node) {
return !!('illegalDecorators' in node &&
node.illegalDecorators?.length);
}
function getModifiers(node) {
return (
// @ts-expect-error intentional to access `node.modifiers` instead of `ts.getModifiers(node)` to access all modifiers
(node.modifiers ?? []).filter((modifier) => !ts.isDecorator(modifier)));
}
function checkModifiers(node) {
// typescript<5.0.0
if (nodeHasIllegalDecorators(node)) {
@@ -147,7 +142,8 @@ function checkModifiers(node) {
}
}
}
for (const modifier of getModifiers(node)) {
const modifiers = (0, getModifiers_1.getModifiers)(node, /* includeIllegalModifiers */ true) ?? [];
for (const modifier of modifiers) {
if (modifier.kind !== SyntaxKind.ReadonlyKeyword) {
if (node.kind === SyntaxKind.PropertySignature ||
node.kind === SyntaxKind.MethodSignature) {
@@ -233,7 +229,7 @@ function checkModifiers(node) {
if (modifier.kind === SyntaxKind.PublicKeyword ||
modifier.kind === SyntaxKind.ProtectedKeyword ||
modifier.kind === SyntaxKind.PrivateKeyword) {
for (const anotherModifier of getModifiers(node)) {
for (const anotherModifier of modifiers) {
if (anotherModifier !== modifier &&
(anotherModifier.kind === SyntaxKind.PublicKeyword ||
anotherModifier.kind === SyntaxKind.ProtectedKeyword ||
@@ -264,11 +260,28 @@ function checkModifiers(node) {
throw (0, node_utils_1.createError)(modifier, 'A parameter property may not be declared using a binding pattern.');
}
}
// From `checkGrammarObjectLiteralExpression` function in `typescript`
if ((modifier.kind !== SyntaxKind.AsyncKeyword ||
node.kind !== SyntaxKind.MethodDeclaration) &&
node.parent.kind === SyntaxKind.ObjectLiteralExpression) {
throw (0, node_utils_1.createError)(modifier, `'${ts.tokenToString(modifier.kind)}' modifier cannot be used here.`);
checkObjectPropertyModifier(node, modifier);
}
// `ts.getModifiers()` can't access invalid modifiers on object properties
// Eg: `({declare a: 1})`
// See https://github.com/typescript-eslint/typescript-eslint/pull/11931#discussion_r2678961730
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- incorrect type
if (node.parent?.kind === SyntaxKind.ObjectLiteralExpression) {
// @ts-expect-error intentional to access deprecated `node.modifiers`
for (const modifier of node.modifiers ??
[]) {
if (ts.isDecorator(modifier) || modifiers.includes(modifier)) {
continue;
}
checkObjectPropertyModifier(node, modifier);
}
}
}
function checkObjectPropertyModifier(node, modifier) {
// From `checkGrammarObjectLiteralExpression` function in `typescript`
if ((modifier.kind !== SyntaxKind.AsyncKeyword ||
node.kind !== SyntaxKind.MethodDeclaration) &&
node.parent.kind === SyntaxKind.ObjectLiteralExpression) {
throw (0, node_utils_1.createError)(modifier, `'${ts.tokenToString(modifier.kind)}' modifier cannot be used here.`);
}
}

View File

@@ -73,6 +73,14 @@ class Converter {
}
(0, check_syntax_errors_1.checkSyntaxError)(node, parent, this.allowPattern);
}
#isValidEscape(text) {
if (/\\[xu]/.test(text)) {
const hasInvalidUnicodeEscape = /\\u(?![0-9a-fA-F]{4}|{)/.test(text);
const hasInvalidHexEscape = /\\x(?![0-9a-fA-F]{2})/.test(text);
return !hasInvalidUnicodeEscape && !hasInvalidHexEscape;
}
return true;
}
#throwError(node, message) {
if (this.options.allowInvalidAST) {
return;
@@ -1067,7 +1075,8 @@ class Converter {
argument: this.convertChild(node.expression),
});
// Template Literals
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.NoSubstitutionTemplateLiteral: {
const rawText = this.ast.text.slice(node.getStart(this.ast) + 1, node.end - 1);
return this.createNode(node, {
type: ts_estree_1.AST_NODE_TYPES.TemplateLiteral,
expressions: [],
@@ -1076,12 +1085,16 @@ class Converter {
type: ts_estree_1.AST_NODE_TYPES.TemplateElement,
tail: true,
value: {
cooked: node.text,
raw: this.ast.text.slice(node.getStart(this.ast) + 1, node.end - 1),
cooked: node.parent.kind === SyntaxKind.TaggedTemplateExpression &&
!this.#isValidEscape(rawText)
? null
: node.text,
raw: rawText,
},
}),
],
});
}
case SyntaxKind.TemplateExpression: {
const result = this.createNode(node, {
type: ts_estree_1.AST_NODE_TYPES.TemplateLiteral,
@@ -1106,12 +1119,17 @@ class Converter {
case SyntaxKind.TemplateMiddle:
case SyntaxKind.TemplateTail: {
const tail = node.kind === SyntaxKind.TemplateTail;
const rawText = this.ast.text.slice(node.getStart(this.ast) + 1, node.end - (tail ? 1 : 2));
const isTagged = node.kind === SyntaxKind.TemplateHead
? node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression
: node.parent.parent.parent.kind ===
SyntaxKind.TaggedTemplateExpression;
return this.createNode(node, {
type: ts_estree_1.AST_NODE_TYPES.TemplateElement,
tail,
value: {
cooked: node.text,
raw: this.ast.text.slice(node.getStart(this.ast) + 1, node.end - (tail ? 1 : 2)),
cooked: isTagged && !this.#isValidEscape(rawText) ? null : node.text,
raw: rawText,
},
});
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,23 @@
(MIT)
Original code Copyright Julian Gruber <julian@juliangruber.com>
Port to TypeScript Copyright Isaac Z. Schlueter <i@izs.me>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,57 @@
# balanced-match
Match balanced string pairs, like `{` and `}` or `<b>` and
`</b>`. Supports regular expressions as well!
## Example
Get the first matching pair of braces:
```js
import { balanced } from 'balanced-match'
console.log(balanced('{', '}', 'pre{in{nested}}post'))
console.log(balanced('{', '}', 'pre{first}between{second}post'))
console.log(
balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'),
)
```
The matches are:
```bash
$ node example.js
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
{ start: 3,
end: 9,
pre: 'pre',
body: 'first',
post: 'between{second}post' }
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
```
## API
### const m = balanced(a, b, str)
For the first non-nested matching pair of `a` and `b` in `str`, return an
object with those keys:
- **start** the index of the first match of `a`
- **end** the index of the matching `b`
- **pre** the preamble, `a` and `b` not included
- **body** the match, `a` and `b` not included
- **post** the postscript, `a` and `b` not included
If there's no match, `undefined` will be returned.
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
### const r = balanced.range(a, b, str)
For the first non-nested matching pair of `a` and `b` in `str`, return an
array with indexes: `[ <a index>, <b index> ]`.
If there's no match, `undefined` will be returned.
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.

View File

@@ -0,0 +1,9 @@
export declare const balanced: (a: string | RegExp, b: string | RegExp, str: string) => false | {
start: number;
end: number;
pre: string;
body: string;
post: string;
} | undefined;
export declare const range: (a: string, b: string, str: string) => undefined | [number, number];
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GACnB,GAAG,MAAM,GAAG,MAAM,EAClB,GAAG,MAAM,GAAG,MAAM,EAClB,KAAK,MAAM;;;;;;aAgBZ,CAAA;AAOD,eAAO,MAAM,KAAK,GAChB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,KAAK,MAAM,KACV,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CA2C7B,CAAA"}

View File

@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.range = exports.balanced = void 0;
const balanced = (a, b, str) => {
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
const r = ma !== null && mb != null && (0, exports.range)(ma, mb, str);
return (r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + ma.length, r[1]),
post: str.slice(r[1] + mb.length),
});
};
exports.balanced = balanced;
const maybeMatch = (reg, str) => {
const m = str.match(reg);
return m ? m[0] : null;
};
const range = (a, b, str) => {
let begs, beg, left, right = undefined, result;
let ai = str.indexOf(a);
let bi = str.indexOf(b, ai + 1);
let i = ai;
if (ai >= 0 && bi > 0) {
if (a === b) {
return [ai, bi];
}
begs = [];
left = str.length;
while (i >= 0 && !result) {
if (i === ai) {
begs.push(i);
ai = str.indexOf(a, i + 1);
}
else if (begs.length === 1) {
const r = begs.pop();
if (r !== undefined)
result = [r, bi];
}
else {
beg = begs.pop();
if (beg !== undefined && beg < left) {
left = beg;
right = bi;
}
bi = str.indexOf(b, i + 1);
}
i = ai < bi && ai >= 0 ? ai : bi;
}
if (begs.length && right !== undefined) {
result = [left, right];
}
}
return result;
};
exports.range = range;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAO,MAAM,QAAQ,GAAG,CACtB,CAAkB,EAClB,CAAkB,EAClB,GAAW,EACX,EAAE;IACF,MAAM,EAAE,GAAG,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvD,MAAM,EAAE,GAAG,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEvD,MAAM,CAAC,GAAG,EAAE,KAAK,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,IAAA,aAAK,EAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IAEzD,OAAO,CACL,CAAC,IAAI;QACH,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QACX,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACT,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;KAClC,CACF,CAAA;AACH,CAAC,CAAA;AAnBY,QAAA,QAAQ,YAmBpB;AAED,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE;IAC9C,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxB,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACxB,CAAC,CAAA;AAEM,MAAM,KAAK,GAAG,CACnB,CAAS,EACT,CAAS,EACT,GAAW,EACmB,EAAE;IAChC,IAAI,IAAc,EAChB,GAAuB,EACvB,IAAY,EACZ,KAAK,GAAuB,SAAS,EACrC,MAAoC,CAAA;IACtC,IAAI,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACvB,IAAI,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAA;IAEV,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACZ,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QACjB,CAAC;QACD,IAAI,GAAG,EAAE,CAAA;QACT,IAAI,GAAG,GAAG,CAAC,MAAM,CAAA;QAEjB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;gBACb,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;gBACZ,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;YAC5B,CAAC;iBAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;gBACpB,IAAI,CAAC,KAAK,SAAS;oBAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;YACvC,CAAC;iBAAM,CAAC;gBACN,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;gBAChB,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,IAAI,EAAE,CAAC;oBACpC,IAAI,GAAG,GAAG,CAAA;oBACV,KAAK,GAAG,EAAE,CAAA;gBACZ,CAAC;gBAED,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;YAC5B,CAAC;YAED,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAClC,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACvC,MAAM,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AA/CY,QAAA,KAAK,SA+CjB","sourcesContent":["export const balanced = (\n a: string | RegExp,\n b: string | RegExp,\n str: string,\n) => {\n const ma = a instanceof RegExp ? maybeMatch(a, str) : a\n const mb = b instanceof RegExp ? maybeMatch(b, str) : b\n\n const r = ma !== null && mb != null && range(ma, mb, str)\n\n return (\n r && {\n start: r[0],\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + ma.length, r[1]),\n post: str.slice(r[1] + mb.length),\n }\n )\n}\n\nconst maybeMatch = (reg: RegExp, str: string) => {\n const m = str.match(reg)\n return m ? m[0] : null\n}\n\nexport const range = (\n a: string,\n b: string,\n str: string,\n): undefined | [number, number] => {\n let begs: number[],\n beg: number | undefined,\n left: number,\n right: number | undefined = undefined,\n result: undefined | [number, number]\n let ai = str.indexOf(a)\n let bi = str.indexOf(b, ai + 1)\n let i = ai\n\n if (ai >= 0 && bi > 0) {\n if (a === b) {\n return [ai, bi]\n }\n begs = []\n left = str.length\n\n while (i >= 0 && !result) {\n if (i === ai) {\n begs.push(i)\n ai = str.indexOf(a, i + 1)\n } else if (begs.length === 1) {\n const r = begs.pop()\n if (r !== undefined) result = [r, bi]\n } else {\n beg = begs.pop()\n if (beg !== undefined && beg < left) {\n left = beg\n right = bi\n }\n\n bi = str.indexOf(b, i + 1)\n }\n\n i = ai < bi && ai >= 0 ? ai : bi\n }\n\n if (begs.length && right !== undefined) {\n result = [left, right]\n }\n }\n\n return result\n}\n"]}

View File

@@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View File

@@ -0,0 +1,9 @@
export declare const balanced: (a: string | RegExp, b: string | RegExp, str: string) => false | {
start: number;
end: number;
pre: string;
body: string;
post: string;
} | undefined;
export declare const range: (a: string, b: string, str: string) => undefined | [number, number];
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GACnB,GAAG,MAAM,GAAG,MAAM,EAClB,GAAG,MAAM,GAAG,MAAM,EAClB,KAAK,MAAM;;;;;;aAgBZ,CAAA;AAOD,eAAO,MAAM,KAAK,GAChB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,KAAK,MAAM,KACV,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CA2C7B,CAAA"}

View File

@@ -0,0 +1,54 @@
export const balanced = (a, b, str) => {
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
const r = ma !== null && mb != null && range(ma, mb, str);
return (r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + ma.length, r[1]),
post: str.slice(r[1] + mb.length),
});
};
const maybeMatch = (reg, str) => {
const m = str.match(reg);
return m ? m[0] : null;
};
export const range = (a, b, str) => {
let begs, beg, left, right = undefined, result;
let ai = str.indexOf(a);
let bi = str.indexOf(b, ai + 1);
let i = ai;
if (ai >= 0 && bi > 0) {
if (a === b) {
return [ai, bi];
}
begs = [];
left = str.length;
while (i >= 0 && !result) {
if (i === ai) {
begs.push(i);
ai = str.indexOf(a, i + 1);
}
else if (begs.length === 1) {
const r = begs.pop();
if (r !== undefined)
result = [r, bi];
}
else {
beg = begs.pop();
if (beg !== undefined && beg < left) {
left = beg;
right = bi;
}
bi = str.indexOf(b, i + 1);
}
i = ai < bi && ai >= 0 ? ai : bi;
}
if (begs.length && right !== undefined) {
result = [left, right];
}
}
return result;
};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,CAAkB,EAClB,CAAkB,EAClB,GAAW,EACX,EAAE;IACF,MAAM,EAAE,GAAG,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvD,MAAM,EAAE,GAAG,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEvD,MAAM,CAAC,GAAG,EAAE,KAAK,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IAEzD,OAAO,CACL,CAAC,IAAI;QACH,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QACX,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACT,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;KAClC,CACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE;IAC9C,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxB,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,CAAS,EACT,CAAS,EACT,GAAW,EACmB,EAAE;IAChC,IAAI,IAAc,EAChB,GAAuB,EACvB,IAAY,EACZ,KAAK,GAAuB,SAAS,EACrC,MAAoC,CAAA;IACtC,IAAI,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACvB,IAAI,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAA;IAEV,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACZ,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QACjB,CAAC;QACD,IAAI,GAAG,EAAE,CAAA;QACT,IAAI,GAAG,GAAG,CAAC,MAAM,CAAA;QAEjB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;gBACb,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;gBACZ,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;YAC5B,CAAC;iBAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;gBACpB,IAAI,CAAC,KAAK,SAAS;oBAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;YACvC,CAAC;iBAAM,CAAC;gBACN,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;gBAChB,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,IAAI,EAAE,CAAC;oBACpC,IAAI,GAAG,GAAG,CAAA;oBACV,KAAK,GAAG,EAAE,CAAA;gBACZ,CAAC;gBAED,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;YAC5B,CAAC;YAED,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAClC,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACvC,MAAM,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["export const balanced = (\n a: string | RegExp,\n b: string | RegExp,\n str: string,\n) => {\n const ma = a instanceof RegExp ? maybeMatch(a, str) : a\n const mb = b instanceof RegExp ? maybeMatch(b, str) : b\n\n const r = ma !== null && mb != null && range(ma, mb, str)\n\n return (\n r && {\n start: r[0],\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + ma.length, r[1]),\n post: str.slice(r[1] + mb.length),\n }\n )\n}\n\nconst maybeMatch = (reg: RegExp, str: string) => {\n const m = str.match(reg)\n return m ? m[0] : null\n}\n\nexport const range = (\n a: string,\n b: string,\n str: string,\n): undefined | [number, number] => {\n let begs: number[],\n beg: number | undefined,\n left: number,\n right: number | undefined = undefined,\n result: undefined | [number, number]\n let ai = str.indexOf(a)\n let bi = str.indexOf(b, ai + 1)\n let i = ai\n\n if (ai >= 0 && bi > 0) {\n if (a === b) {\n return [ai, bi]\n }\n begs = []\n left = str.length\n\n while (i >= 0 && !result) {\n if (i === ai) {\n begs.push(i)\n ai = str.indexOf(a, i + 1)\n } else if (begs.length === 1) {\n const r = begs.pop()\n if (r !== undefined) result = [r, bi]\n } else {\n beg = begs.pop()\n if (beg !== undefined && beg < left) {\n left = beg\n right = bi\n }\n\n bi = str.indexOf(b, i + 1)\n }\n\n i = ai < bi && ai >= 0 ? ai : bi\n }\n\n if (begs.length && right !== undefined) {\n result = [left, right]\n }\n }\n\n return result\n}\n"]}

View File

@@ -0,0 +1,3 @@
{
"type": "module"
}

View File

@@ -0,0 +1,68 @@
{
"name": "balanced-match",
"description": "Match balanced character pairs, like \"{\" and \"}\"",
"version": "4.0.4",
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/balanced-match.git"
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"type": "module",
"scripts": {
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"prepare": "tshy",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "tap",
"snap": "tap",
"format": "prettier --write .",
"benchmark": "node benchmark/index.js",
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
},
"devDependencies": {
"@types/brace-expansion": "^1.1.2",
"@types/node": "^25.2.1",
"mkdirp": "^3.0.1",
"prettier": "^3.3.2",
"tap": "^21.6.2",
"tshy": "^3.0.2",
"typedoc": "^0.28.5"
},
"keywords": [
"match",
"regexp",
"test",
"balanced",
"parse"
],
"license": "MIT",
"engines": {
"node": "18 || 20 || >=22"
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"module": "./dist/esm/index.js"
}

View File

@@ -1,2 +0,0 @@
tidelift: "npm/brace-expansion"
patreon: juliangruber

View File

@@ -1,6 +1,8 @@
MIT License
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
Copyright Julian Gruber <julian@juliangruber.com>
TypeScript port Copyright Isaac Z. Schlueter <i@izs.me>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,18 +1,15 @@
# brace-expansion
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
as known from sh/bash, in JavaScript.
[![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
[![CI](https://github.com/juliangruber/brace-expansion/actions/workflows/ci.yml/badge.svg)](https://github.com/juliangruber/brace-expansion/actions/workflows/ci.yml)
[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
[![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/)
[![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)
## Example
```js
var expand = require('brace-expansion');
import { expand } from 'brace-expansion'
expand('file-{a,b,c}.jpg')
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
@@ -48,25 +45,36 @@ expand('ppp{,config,oe{,conf}}')
## API
```js
var expand = require('brace-expansion');
import { expand } from 'brace-expansion'
```
### var expanded = expand(str)
### const expanded = expand(str, [options])
Return an array of all possible and valid expansions of `str`. If none are
found, `[str]` is returned.
Return an array of all possible and valid expansions of `str`. If
none are found, `[str]` is returned.
The `options` object can provide a `max` value to cap the number
of expansions allowed. This is limited to `100_000` by default,
to prevent DoS attacks.
```js
const expansions = expand('{1..100}'.repeat(5), {
max: 100,
})
// expansions.length will be 100, not 100^5
```
Valid expansions are:
```js
/^(.*,)+(.+)?$/
;/^(.*,)+(.+)?$/
// {a,b,...}
```
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
```js
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
;/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
// {x..y[..incr]}
```
@@ -75,7 +83,7 @@ If `x` or `y` start with a leading `0`, all the numbers will be padded
to have equal length. Negative numbers and backwards iteration work too.
```js
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
;/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
// {x..y[..incr]}
```
@@ -84,52 +92,3 @@ An alphabetic sequence from `x` to `y` inclusive, with optional increment.
number.
For compatibility reasons, the string `${` is not eligible for brace expansion.
## Installation
With [npm](https://npmjs.org) do:
```bash
npm install brace-expansion
```
## Contributors
- [Julian Gruber](https://github.com/juliangruber)
- [Isaac Z. Schlueter](https://github.com/isaacs)
## Sponsors
This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
## Security contact information
To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
## License
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,6 @@
export declare const EXPANSION_MAX = 100000;
export type BraceExpansionOptions = {
max?: number;
};
export declare function expand(str: string, options?: BraceExpansionOptions): string[];
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,aAAa,SAAU,CAAA;AAwDpC,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,YAkBtE"}

View File

@@ -0,0 +1,199 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EXPANSION_MAX = void 0;
exports.expand = expand;
const balanced_match_1 = require("balanced-match");
const escSlash = '\0SLASH' + Math.random() + '\0';
const escOpen = '\0OPEN' + Math.random() + '\0';
const escClose = '\0CLOSE' + Math.random() + '\0';
const escComma = '\0COMMA' + Math.random() + '\0';
const escPeriod = '\0PERIOD' + Math.random() + '\0';
const escSlashPattern = new RegExp(escSlash, 'g');
const escOpenPattern = new RegExp(escOpen, 'g');
const escClosePattern = new RegExp(escClose, 'g');
const escCommaPattern = new RegExp(escComma, 'g');
const escPeriodPattern = new RegExp(escPeriod, 'g');
const slashPattern = /\\\\/g;
const openPattern = /\\{/g;
const closePattern = /\\}/g;
const commaPattern = /\\,/g;
const periodPattern = /\\\./g;
exports.EXPANSION_MAX = 100_000;
function numeric(str) {
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
}
function escapeBraces(str) {
return str
.replace(slashPattern, escSlash)
.replace(openPattern, escOpen)
.replace(closePattern, escClose)
.replace(commaPattern, escComma)
.replace(periodPattern, escPeriod);
}
function unescapeBraces(str) {
return str
.replace(escSlashPattern, '\\')
.replace(escOpenPattern, '{')
.replace(escClosePattern, '}')
.replace(escCommaPattern, ',')
.replace(escPeriodPattern, '.');
}
/**
* Basically just str.split(","), but handling cases
* where we have nested braced sections, which should be
* treated as individual members, like {a,{b,c},d}
*/
function parseCommaParts(str) {
if (!str) {
return [''];
}
const parts = [];
const m = (0, balanced_match_1.balanced)('{', '}', str);
if (!m) {
return str.split(',');
}
const { pre, body, post } = m;
const p = pre.split(',');
p[p.length - 1] += '{' + body + '}';
const postParts = parseCommaParts(post);
if (post.length) {
;
p[p.length - 1] += postParts.shift();
p.push.apply(p, postParts);
}
parts.push.apply(parts, p);
return parts;
}
function expand(str, options = {}) {
if (!str) {
return [];
}
const { max = exports.EXPANSION_MAX } = options;
// I don't know why Bash 4.3 does this, but it does.
// Anything starting with {} will have the first two bytes preserved
// but *only* at the top level, so {},a}b will not expand to anything,
// but a{},b}c will be expanded to [a}c,abc].
// One could argue that this is a bug in Bash, but since the goal of
// this module is to match Bash's rules, we escape a leading {}
if (str.slice(0, 2) === '{}') {
str = '\\{\\}' + str.slice(2);
}
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
}
function embrace(str) {
return '{' + str + '}';
}
function isPadded(el) {
return /^-?0\d/.test(el);
}
function lte(i, y) {
return i <= y;
}
function gte(i, y) {
return i >= y;
}
function expand_(str, max, isTop) {
/** @type {string[]} */
const expansions = [];
const m = (0, balanced_match_1.balanced)('{', '}', str);
if (!m)
return [str];
// no need to expand pre, since it is guaranteed to be free of brace-sets
const pre = m.pre;
const post = m.post.length ? expand_(m.post, max, false) : [''];
if (/\$$/.test(m.pre)) {
for (let k = 0; k < post.length && k < max; k++) {
const expansion = pre + '{' + m.body + '}' + post[k];
expansions.push(expansion);
}
}
else {
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
const isSequence = isNumericSequence || isAlphaSequence;
const isOptions = m.body.indexOf(',') >= 0;
if (!isSequence && !isOptions) {
// {a},b}
if (m.post.match(/,(?!,).*\}/)) {
str = m.pre + '{' + m.body + escClose + m.post;
return expand_(str, max, true);
}
return [str];
}
let n;
if (isSequence) {
n = m.body.split(/\.\./);
}
else {
n = parseCommaParts(m.body);
if (n.length === 1 && n[0] !== undefined) {
// x{{a,b}}y ==> x{a}y x{b}y
n = expand_(n[0], max, false).map(embrace);
//XXX is this necessary? Can't seem to hit it in tests.
/* c8 ignore start */
if (n.length === 1) {
return post.map(p => m.pre + n[0] + p);
}
/* c8 ignore stop */
}
}
// at this point, n is the parts, and we know it's not a comma set
// with a single entry.
let N;
if (isSequence && n[0] !== undefined && n[1] !== undefined) {
const x = numeric(n[0]);
const y = numeric(n[1]);
const width = Math.max(n[0].length, n[1].length);
let incr = n.length === 3 && n[2] !== undefined ? Math.abs(numeric(n[2])) : 1;
let test = lte;
const reverse = y < x;
if (reverse) {
incr *= -1;
test = gte;
}
const pad = n.some(isPadded);
N = [];
for (let i = x; test(i, y); i += incr) {
let c;
if (isAlphaSequence) {
c = String.fromCharCode(i);
if (c === '\\') {
c = '';
}
}
else {
c = String(i);
if (pad) {
const need = width - c.length;
if (need > 0) {
const z = new Array(need + 1).join('0');
if (i < 0) {
c = '-' + z + c.slice(1);
}
else {
c = z + c;
}
}
}
}
N.push(c);
}
}
else {
N = [];
for (let j = 0; j < n.length; j++) {
N.push.apply(N, expand_(n[j], max, false));
}
}
for (let j = 0; j < N.length; j++) {
for (let k = 0; k < post.length && expansions.length < max; k++) {
const expansion = pre + N[j] + post[k];
if (!isTop || isSequence || expansion) {
expansions.push(expansion);
}
}
}
}
return expansions;
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View File

@@ -0,0 +1,6 @@
export declare const EXPANSION_MAX = 100000;
export type BraceExpansionOptions = {
max?: number;
};
export declare function expand(str: string, options?: BraceExpansionOptions): string[];
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,aAAa,SAAU,CAAA;AAwDpC,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,YAkBtE"}

View File

@@ -0,0 +1,195 @@
import { balanced } from 'balanced-match';
const escSlash = '\0SLASH' + Math.random() + '\0';
const escOpen = '\0OPEN' + Math.random() + '\0';
const escClose = '\0CLOSE' + Math.random() + '\0';
const escComma = '\0COMMA' + Math.random() + '\0';
const escPeriod = '\0PERIOD' + Math.random() + '\0';
const escSlashPattern = new RegExp(escSlash, 'g');
const escOpenPattern = new RegExp(escOpen, 'g');
const escClosePattern = new RegExp(escClose, 'g');
const escCommaPattern = new RegExp(escComma, 'g');
const escPeriodPattern = new RegExp(escPeriod, 'g');
const slashPattern = /\\\\/g;
const openPattern = /\\{/g;
const closePattern = /\\}/g;
const commaPattern = /\\,/g;
const periodPattern = /\\\./g;
export const EXPANSION_MAX = 100_000;
function numeric(str) {
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
}
function escapeBraces(str) {
return str
.replace(slashPattern, escSlash)
.replace(openPattern, escOpen)
.replace(closePattern, escClose)
.replace(commaPattern, escComma)
.replace(periodPattern, escPeriod);
}
function unescapeBraces(str) {
return str
.replace(escSlashPattern, '\\')
.replace(escOpenPattern, '{')
.replace(escClosePattern, '}')
.replace(escCommaPattern, ',')
.replace(escPeriodPattern, '.');
}
/**
* Basically just str.split(","), but handling cases
* where we have nested braced sections, which should be
* treated as individual members, like {a,{b,c},d}
*/
function parseCommaParts(str) {
if (!str) {
return [''];
}
const parts = [];
const m = balanced('{', '}', str);
if (!m) {
return str.split(',');
}
const { pre, body, post } = m;
const p = pre.split(',');
p[p.length - 1] += '{' + body + '}';
const postParts = parseCommaParts(post);
if (post.length) {
;
p[p.length - 1] += postParts.shift();
p.push.apply(p, postParts);
}
parts.push.apply(parts, p);
return parts;
}
export function expand(str, options = {}) {
if (!str) {
return [];
}
const { max = EXPANSION_MAX } = options;
// I don't know why Bash 4.3 does this, but it does.
// Anything starting with {} will have the first two bytes preserved
// but *only* at the top level, so {},a}b will not expand to anything,
// but a{},b}c will be expanded to [a}c,abc].
// One could argue that this is a bug in Bash, but since the goal of
// this module is to match Bash's rules, we escape a leading {}
if (str.slice(0, 2) === '{}') {
str = '\\{\\}' + str.slice(2);
}
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
}
function embrace(str) {
return '{' + str + '}';
}
function isPadded(el) {
return /^-?0\d/.test(el);
}
function lte(i, y) {
return i <= y;
}
function gte(i, y) {
return i >= y;
}
function expand_(str, max, isTop) {
/** @type {string[]} */
const expansions = [];
const m = balanced('{', '}', str);
if (!m)
return [str];
// no need to expand pre, since it is guaranteed to be free of brace-sets
const pre = m.pre;
const post = m.post.length ? expand_(m.post, max, false) : [''];
if (/\$$/.test(m.pre)) {
for (let k = 0; k < post.length && k < max; k++) {
const expansion = pre + '{' + m.body + '}' + post[k];
expansions.push(expansion);
}
}
else {
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
const isSequence = isNumericSequence || isAlphaSequence;
const isOptions = m.body.indexOf(',') >= 0;
if (!isSequence && !isOptions) {
// {a},b}
if (m.post.match(/,(?!,).*\}/)) {
str = m.pre + '{' + m.body + escClose + m.post;
return expand_(str, max, true);
}
return [str];
}
let n;
if (isSequence) {
n = m.body.split(/\.\./);
}
else {
n = parseCommaParts(m.body);
if (n.length === 1 && n[0] !== undefined) {
// x{{a,b}}y ==> x{a}y x{b}y
n = expand_(n[0], max, false).map(embrace);
//XXX is this necessary? Can't seem to hit it in tests.
/* c8 ignore start */
if (n.length === 1) {
return post.map(p => m.pre + n[0] + p);
}
/* c8 ignore stop */
}
}
// at this point, n is the parts, and we know it's not a comma set
// with a single entry.
let N;
if (isSequence && n[0] !== undefined && n[1] !== undefined) {
const x = numeric(n[0]);
const y = numeric(n[1]);
const width = Math.max(n[0].length, n[1].length);
let incr = n.length === 3 && n[2] !== undefined ? Math.abs(numeric(n[2])) : 1;
let test = lte;
const reverse = y < x;
if (reverse) {
incr *= -1;
test = gte;
}
const pad = n.some(isPadded);
N = [];
for (let i = x; test(i, y); i += incr) {
let c;
if (isAlphaSequence) {
c = String.fromCharCode(i);
if (c === '\\') {
c = '';
}
}
else {
c = String(i);
if (pad) {
const need = width - c.length;
if (need > 0) {
const z = new Array(need + 1).join('0');
if (i < 0) {
c = '-' + z + c.slice(1);
}
else {
c = z + c;
}
}
}
}
N.push(c);
}
}
else {
N = [];
for (let j = 0; j < n.length; j++) {
N.push.apply(N, expand_(n[j], max, false));
}
}
for (let j = 0; j < N.length; j++) {
for (let k = 0; k < post.length && expansions.length < max; k++) {
const expansion = pre + N[j] + post[k];
if (!isTop || isSequence || expansion) {
expansions.push(expansion);
}
}
}
}
return expansions;
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
{
"type": "module"
}

View File

@@ -1,203 +0,0 @@
var balanced = require('balanced-match');
module.exports = expandTop;
var escSlash = '\0SLASH'+Math.random()+'\0';
var escOpen = '\0OPEN'+Math.random()+'\0';
var escClose = '\0CLOSE'+Math.random()+'\0';
var escComma = '\0COMMA'+Math.random()+'\0';
var escPeriod = '\0PERIOD'+Math.random()+'\0';
function numeric(str) {
return parseInt(str, 10) == str
? parseInt(str, 10)
: str.charCodeAt(0);
}
function escapeBraces(str) {
return str.split('\\\\').join(escSlash)
.split('\\{').join(escOpen)
.split('\\}').join(escClose)
.split('\\,').join(escComma)
.split('\\.').join(escPeriod);
}
function unescapeBraces(str) {
return str.split(escSlash).join('\\')
.split(escOpen).join('{')
.split(escClose).join('}')
.split(escComma).join(',')
.split(escPeriod).join('.');
}
// Basically just str.split(","), but handling cases
// where we have nested braced sections, which should be
// treated as individual members, like {a,{b,c},d}
function parseCommaParts(str) {
if (!str)
return [''];
var parts = [];
var m = balanced('{', '}', str);
if (!m)
return str.split(',');
var pre = m.pre;
var body = m.body;
var post = m.post;
var p = pre.split(',');
p[p.length-1] += '{' + body + '}';
var postParts = parseCommaParts(post);
if (post.length) {
p[p.length-1] += postParts.shift();
p.push.apply(p, postParts);
}
parts.push.apply(parts, p);
return parts;
}
function expandTop(str) {
if (!str)
return [];
// I don't know why Bash 4.3 does this, but it does.
// Anything starting with {} will have the first two bytes preserved
// but *only* at the top level, so {},a}b will not expand to anything,
// but a{},b}c will be expanded to [a}c,abc].
// One could argue that this is a bug in Bash, but since the goal of
// this module is to match Bash's rules, we escape a leading {}
if (str.substr(0, 2) === '{}') {
str = '\\{\\}' + str.substr(2);
}
return expand(escapeBraces(str), true).map(unescapeBraces);
}
function embrace(str) {
return '{' + str + '}';
}
function isPadded(el) {
return /^-?0\d/.test(el);
}
function lte(i, y) {
return i <= y;
}
function gte(i, y) {
return i >= y;
}
function expand(str, isTop) {
var expansions = [];
var m = balanced('{', '}', str);
if (!m) return [str];
// no need to expand pre, since it is guaranteed to be free of brace-sets
var pre = m.pre;
var post = m.post.length
? expand(m.post, false)
: [''];
if (/\$$/.test(m.pre)) {
for (var k = 0; k < post.length; k++) {
var expansion = pre+ '{' + m.body + '}' + post[k];
expansions.push(expansion);
}
} else {
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
var isSequence = isNumericSequence || isAlphaSequence;
var isOptions = m.body.indexOf(',') >= 0;
if (!isSequence && !isOptions) {
// {a},b}
if (m.post.match(/,(?!,).*\}/)) {
str = m.pre + '{' + m.body + escClose + m.post;
return expand(str);
}
return [str];
}
var n;
if (isSequence) {
n = m.body.split(/\.\./);
} else {
n = parseCommaParts(m.body);
if (n.length === 1) {
// x{{a,b}}y ==> x{a}y x{b}y
n = expand(n[0], false).map(embrace);
if (n.length === 1) {
return post.map(function(p) {
return m.pre + n[0] + p;
});
}
}
}
// at this point, n is the parts, and we know it's not a comma set
// with a single entry.
var N;
if (isSequence) {
var x = numeric(n[0]);
var y = numeric(n[1]);
var width = Math.max(n[0].length, n[1].length)
var incr = n.length == 3
? Math.abs(numeric(n[2]))
: 1;
var test = lte;
var reverse = y < x;
if (reverse) {
incr *= -1;
test = gte;
}
var pad = n.some(isPadded);
N = [];
for (var i = x; test(i, y); i += incr) {
var c;
if (isAlphaSequence) {
c = String.fromCharCode(i);
if (c === '\\')
c = '';
} else {
c = String(i);
if (pad) {
var need = width - c.length;
if (need > 0) {
var z = new Array(need + 1).join('0');
if (i < 0)
c = '-' + z + c.slice(1);
else
c = z + c;
}
}
}
N.push(c);
}
} else {
N = [];
for (var j = 0; j < n.length; j++) {
N.push.apply(N, expand(n[j], false));
}
}
for (var j = 0; j < N.length; j++) {
for (var k = 0; k < post.length; k++) {
var expansion = pre + N[j] + post[k];
if (!isTop || isSequence || expansion)
expansions.push(expansion);
}
}
}
return expansions;
}

Some files were not shown because too many files have changed in this diff Show More