mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
micromatch: add options for scan method (#41858)
This commit is contained in:
committed by
Wesley Wigham
parent
ef7406af8c
commit
eab005010b
Vendored
+57
-1
@@ -266,6 +266,60 @@ declare namespace micromatch {
|
||||
*/
|
||||
windows?: boolean;
|
||||
}
|
||||
|
||||
interface ScanOptions extends Options {
|
||||
/**
|
||||
* When `true`, the returned object will include an array of `tokens` (objects), representing each path "segment" in the scanned glob pattern.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
tokens?: boolean;
|
||||
/**
|
||||
* When `true`, the returned object will include an array of strings representing each path "segment" in the scanned glob pattern.
|
||||
* This is automatically enabled when `options.tokens` is `true`.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
parts?: boolean;
|
||||
}
|
||||
|
||||
interface ScanInfo {
|
||||
prefix: string;
|
||||
input: string;
|
||||
start: number;
|
||||
base: string;
|
||||
glob: string;
|
||||
isBrace: boolean;
|
||||
isBracket: boolean;
|
||||
isGlob: boolean;
|
||||
isExtglob: boolean;
|
||||
isGlobstar: boolean;
|
||||
negated: boolean;
|
||||
}
|
||||
|
||||
interface ScanInfoToken {
|
||||
value: string;
|
||||
depth: number;
|
||||
isGlob: boolean;
|
||||
|
||||
backslashes?: boolean;
|
||||
isBrace?: boolean;
|
||||
isBracket?: boolean;
|
||||
isExtglob?: boolean;
|
||||
isGlobstar?: boolean;
|
||||
isPrefix?: boolean;
|
||||
negated?: boolean;
|
||||
}
|
||||
|
||||
interface ScanInfoWithParts extends ScanInfo {
|
||||
slashes: number[];
|
||||
parts: string[];
|
||||
}
|
||||
|
||||
interface ScanInfoWithTokens extends ScanInfoWithParts {
|
||||
maxDepth: number;
|
||||
tokens: ScanInfoToken[];
|
||||
}
|
||||
}
|
||||
|
||||
interface Micromatch {
|
||||
@@ -610,7 +664,9 @@ interface Micromatch {
|
||||
/**
|
||||
* Scan a glob pattern to separate the pattern into segments.
|
||||
*/
|
||||
scan(pattern: string, options?: micromatch.Options): object;
|
||||
scan(pattern: string, options: { parts: true } & micromatch.ScanOptions): micromatch.ScanInfoWithParts;
|
||||
scan(pattern: string, options: { tokens: true } & micromatch.ScanOptions): micromatch.ScanInfoWithTokens;
|
||||
scan(pattern: string, options?: micromatch.ScanOptions): micromatch.ScanInfo;
|
||||
}
|
||||
|
||||
export as namespace micromatch;
|
||||
|
||||
@@ -64,3 +64,12 @@ const regex: RegExp = mm.makeRe('*.js');
|
||||
// .braces
|
||||
strArrResult = mm.braces('*.js');
|
||||
strArrResult = mm.braces('*.js', { expand: true });
|
||||
|
||||
// $ExpectType ScanInfo
|
||||
mm.scan('*');
|
||||
|
||||
// $ExpectType ScanInfoWithTokens
|
||||
mm.scan('*', { tokens: true });
|
||||
|
||||
// $ExpectType ScanInfoWithParts
|
||||
mm.scan('*', { parts: true });
|
||||
|
||||
Reference in New Issue
Block a user