add regexgen support (#47096)

This commit is contained in:
Septs 2020-08-28 12:00:35 +08:00 committed by GitHub
parent 24f1e8d601
commit 384aa8b545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 0 deletions

20
types/regexgen/index.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
// Type definitions for regexgen 1.3
// Project: https://github.com/devongovett/regexgen
// Definitions by: Septs <https://github.com/septs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 4.0
declare function regexgen(inputs: string[], flags?: RegExp['flags']): RegExp;
declare namespace regexgen {
class Trie {
add(input: string): void;
addAll(inputs: string[]): void;
minimize(): void;
toString(flags?: RegExp['flags']): string;
toRegExp(flags?: RegExp['flags']): RegExp;
}
}
export = regexgen;

View File

@ -0,0 +1,8 @@
import regexgen = require('regexgen');
regexgen(['foobar', 'foobaz', 'foozap', 'fooza']);
const t = new regexgen.Trie();
t.add('foobar');
t.add('foobaz');
t.toRegExp();

View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "regexgen-tests.ts"]
}

View File

@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}