mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
- definition updated - tests updated - prettier formatting applied Thanks!
This commit is contained in:
parent
d2359661f7
commit
d02802bd23
@@ -1,8 +1,6 @@
|
||||
import Balanced = require("balanced-match");
|
||||
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('{', '}', 'pre{in{nested}}post');
|
||||
balanced('{', '}', 'pre{first}between{second}post');
|
||||
balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post');
|
||||
balanced.range('{', '}', 'pre{in{nested}}post');
|
||||
|
||||
Vendored
+22
-4
@@ -1,6 +1,7 @@
|
||||
// Type definitions for balanced-match 1.0
|
||||
// Project: https://github.com/juliangruber/balanced-match
|
||||
// Definitions by: Adam Zerella <https://github.com/adamzerella>
|
||||
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Output {
|
||||
@@ -26,10 +27,27 @@ interface Output {
|
||||
post: string;
|
||||
}
|
||||
|
||||
declare class Balanced {
|
||||
balanced(a: string|RegExp, b: string|RegExp, str: string): Output|void;
|
||||
/**
|
||||
*
|
||||
* For the first non-nested matching pair of a and b in str, return an object with those keys:
|
||||
* start the index of the first match of
|
||||
* `end` the index of the matching b
|
||||
* `pre` the preamble, a and b not included
|
||||
* `body` the match, a and b not included
|
||||
* `post` the postscript, a and b not included
|
||||
* If there's no match, `undefined` will be returned.
|
||||
* If the `str` contains more a than b / there are unmatched pairs,
|
||||
* the first match that was closed will be used.
|
||||
* For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`
|
||||
*/
|
||||
declare function balanced(a: string | RegExp, b: string | RegExp, str: string): Output | void;
|
||||
|
||||
range(a: string|RegExp, b: string|RegExp, str: string): Output|void;
|
||||
declare namespace balanced {
|
||||
/**
|
||||
* For the first non-nested matching pair of `a` and `b` in `str`,
|
||||
* return an array with indexes: `[ <a index>, <b index> ]`.
|
||||
*/
|
||||
function range(a: string | RegExp, b: string | RegExp, str: string): Output | void;
|
||||
}
|
||||
|
||||
export = Balanced;
|
||||
export = balanced;
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [
|
||||
|
||||
],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"balanced-match-tests.ts"
|
||||
"index.d.ts",
|
||||
"balanced-match-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
|
||||
Reference in New Issue
Block a user