Files
SnowLuma/.pnpm-store/v11/files/dc/d73b1e0490212ac11214e7541a5eb486f408e5b8d9fb6bb736a5da28b0886e81ec890c0a75a21a4e6bcde5f76fee7ea95236277134cad4fead231c46ad26dd
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

114 lines
2.9 KiB
Plaintext

import { type Form } from './parse-class.js';
export type { Form };
export type MatcherOptions = {
/** perform a case-insensitive match */
nocase?: boolean;
/** do not treat strings starting with `.` specially */
dot?: boolean;
/** do not match extglobs (treat them as normal strings) */
noext?: boolean;
/**
* normalize unicode in the pattern and the tested strings, with
* this form. `true` means `'NFC'`.
*/
normalize?: boolean | Form;
};
export type Item = {
t: 'lit';
ch: string;
} | {
t: 'any' | 'star';
} | {
t: 'class';
re: RegExp;
} | {
t: 'ext';
type: string;
alts: Item[][];
};
export type Token = Item | {
t: 'open';
type: string;
} | {
t: 'bar';
} | {
t: 'close';
};
export type NegNode = {
t: 'neg';
id: number;
sub: Node;
next: Node;
};
export type SplitNode = {
t: 'split';
id: number;
out: Node[];
};
export type Node = ({
t: 'lit';
id: number;
next: Node;
} & Lit) | {
t: 'any' | 'star';
id: number;
next: Node;
} | {
t: 'class';
id: number;
re: RegExp;
next: Node;
} | SplitNode | NegNode | {
t: 'match';
id: number;
};
/**
* A literal char. With `nocase:true`, `re` folds case, and `ascii`
* holds its results for ASCII chars, by char code: 1 for a match,
* and 2 for not.
*/
export type Lit = {
ch: string;
re?: RegExp;
ascii?: Uint8Array;
};
/**
* For each node id, the gen of the last state that has the node as
* a thread, and of the last state that walked through it. A state is
* built to the end before the states around it go on, and the nodes
* of a negated sub-pattern are only in its states (other than the
* match node, which is never marked). So one mark for each node is
* enough to know if the state being built has it. The Sims of a
* matcher never run at the same time, so they share one Marks.
*/
export type Marks = {
has: Float64Array;
seen: Float64Array;
gen: number;
};
/**
* A node in a graph with no splits or negations. Such a graph is a
* chain of nodes that each match one char, or a `*`.
*/
export type LinearNode = Exclude<Node, SplitNode | NegNode | {
t: 'match';
}>;
export declare class Matcher {
#private;
pattern: string;
options: MatcherOptions;
constructor(pattern: string, options?: MatcherOptions);
test(s: string): boolean;
/**
* The same as {@link Matcher#test}, but the string is not checked
* for `/` chars, so the result for a string that has one is not
* defined. Only use it for a string that is known to be one path
* portion, such as a part of a path that was split on `/`. It can
* be faster, because some patterns do not need to look at each char
* of the string.
*/
testUnchecked(s: string): boolean;
/** a readable listing of the state machine */
toString(): string;
}
//# sourceMappingURL=index.d.ts.map