Added type defs for balanced-match (#35051)

This commit is contained in:
Adam Zerella
2019-04-28 23:55:41 -07:00
committed by Wesley Wigham
parent 088f477d65
commit d8e0586da4
4 changed files with 71 additions and 0 deletions
@@ -0,0 +1,8 @@
import Balanced = require("balanced-match");
const balanced = new Balanced();
balanced.balanced('{', '}', 'pre{in{nested}}post');
balanced.balanced('{', '}', 'pre{first}between{second}post');
balanced.balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post');
balanced.range('{', '}', 'pre{in{nested}}post');
+35
View File
@@ -0,0 +1,35 @@
// Type definitions for balanced-match 1.0
// Project: https://github.com/juliangruber/balanced-match
// Definitions by: Adam Zerella <https://github.com/adamzerella>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Output {
/**
* The index of the first match of a
*/
start: number;
/**
* The index of the matching b
*/
end: number;
/**
* The preamble, a and b not included
*/
pre: string;
/**
* The match, a and b not included
*/
body: string;
/**
* The postscript, a and b not included
*/
post: string;
}
declare class Balanced {
balanced(a: string|RegExp, b: string|RegExp, str: string): Output|void;
range(a: string|RegExp, b: string|RegExp, str: string): Output|void;
}
export = Balanced;
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [
],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"balanced-match-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}