diff --git a/types/balanced-match/balanced-match-tests.ts b/types/balanced-match/balanced-match-tests.ts new file mode 100644 index 0000000000..c0edcc89a8 --- /dev/null +++ b/types/balanced-match/balanced-match-tests.ts @@ -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'); diff --git a/types/balanced-match/index.d.ts b/types/balanced-match/index.d.ts new file mode 100644 index 0000000000..952eba8ffa --- /dev/null +++ b/types/balanced-match/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for balanced-match 1.0 +// Project: https://github.com/juliangruber/balanced-match +// Definitions by: Adam Zerella +// 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; diff --git a/types/balanced-match/tsconfig.json b/types/balanced-match/tsconfig.json new file mode 100644 index 0000000000..d91bbdd539 --- /dev/null +++ b/types/balanced-match/tsconfig.json @@ -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" + ] +} diff --git a/types/balanced-match/tslint.json b/types/balanced-match/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/balanced-match/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file