mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #31318 from BendingBender/subsume
Add types for subsume v2
This commit is contained in:
Vendored
+7
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for subsume 1.0
|
||||
// Type definitions for subsume 2.0
|
||||
// Project: https://github.com/sindresorhus/subsume#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -7,6 +7,7 @@ export = Subsume;
|
||||
|
||||
declare class Subsume {
|
||||
static parse(text: string, id: string): Subsume.ParseResult;
|
||||
static parseAll(text: string, ids?: string[]): Subsume.ParseResults;
|
||||
|
||||
id: string;
|
||||
prefix: string;
|
||||
@@ -23,4 +24,9 @@ declare namespace Subsume {
|
||||
data?: string;
|
||||
rest: string;
|
||||
}
|
||||
|
||||
interface ParseResults {
|
||||
data: Map<string, string>;
|
||||
rest: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,5 +18,13 @@ res; // $ExpectType ParseResult
|
||||
res.data; // $ExpectType string | undefined
|
||||
res.rest; // $ExpectType string
|
||||
|
||||
const input = 'some@@[7febcd0b3806fbc48c01d7cea4ed1219]@@🦄##[7febcd0b3806fbc48c01d7cea4ed1219]## random text';
|
||||
Subsume.parse(text, '7febcd0b3806fbc48c01d7cea4ed1219'); // $ExpectType ParseResult
|
||||
const input =
|
||||
'some@@[7febcd0b3806fbc48c01d7cea4ed1219]@@🦄##[7febcd0b3806fbc48c01d7cea4ed1219]## random text';
|
||||
Subsume.parse(input, '7febcd0b3806fbc48c01d7cea4ed1219'); // $ExpectType ParseResult
|
||||
|
||||
const input2 =
|
||||
'some@@[7febcd0b3806fbc48c01d7cea4ed1219]@@🦄##[7febcd0b3806fbc48c01d7cea4ed1219]## ' +
|
||||
'random@@[7febcd0b3806fbc48c01d7cea4ed1218]@@🦄##[7febcd0b3806fbc48c01d7cea4ed1218]## ' +
|
||||
'text@@[7febcd0b3806fbc48c01d7cea4ed1217]@@🦄##[7febcd0b3806fbc48c01d7cea4ed1217]##';
|
||||
Subsume.parseAll(input2); // $ExpectType ParseResults
|
||||
Subsume.parseAll(input2, ['7febcd0b3806fbc48c01d7cea4ed1219']); // $ExpectType ParseResults
|
||||
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"subsume-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for subsume 1.0
|
||||
// Project: https://github.com/sindresorhus/subsume#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = Subsume;
|
||||
|
||||
declare class Subsume {
|
||||
static parse(text: string, id: string): Subsume.ParseResult;
|
||||
|
||||
id: string;
|
||||
prefix: string;
|
||||
postfix: string;
|
||||
regex: RegExp;
|
||||
|
||||
constructor(id?: string);
|
||||
compose(text: string): string;
|
||||
parse(text: string): Subsume.ParseResult;
|
||||
}
|
||||
|
||||
declare namespace Subsume {
|
||||
interface ParseResult {
|
||||
data?: string;
|
||||
rest: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import Subsume = require('subsume');
|
||||
|
||||
const subsume = new Subsume();
|
||||
new Subsume('foo');
|
||||
|
||||
subsume.id; // $ExpectType string
|
||||
subsume.prefix; // $ExpectType string
|
||||
subsume.postfix; // $ExpectType string
|
||||
subsume.regex; // $ExpectType RegExp
|
||||
|
||||
const text = subsume.compose('🦄');
|
||||
text; // $ExpectType string
|
||||
|
||||
const output = `some${text} random text`;
|
||||
|
||||
const res = subsume.parse(output);
|
||||
res; // $ExpectType ParseResult
|
||||
res.data; // $ExpectType string | undefined
|
||||
res.rest; // $ExpectType string
|
||||
|
||||
const input = 'some@@[7febcd0b3806fbc48c01d7cea4ed1219]@@🦄##[7febcd0b3806fbc48c01d7cea4ed1219]## random text';
|
||||
Subsume.parse(text, '7febcd0b3806fbc48c01d7cea4ed1219'); // $ExpectType ParseResult
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"subsume": [
|
||||
"subsume/v1"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"subsume-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user