Merge pull request #21306 from bevalorous/coverup

add declarations for coverup
This commit is contained in:
Daniel Rosenwasser
2017-11-07 10:07:06 -08:00
committed by GitHub
4 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import coverup = require("coverup");
coverup("4242-4242-4242-4242"); // $ExpectType string
// => *******************
coverup("4242-4242-4242-4242", { char: "%" }); // $ExpectType string
// => %%%%%%%%%%%%%%%%%%%
coverup("4242-4242-4242-4242", { keepSymbols: true }); // $ExpectType string
// => ****-****-****-****
coverup("4242-4242-4242-4242", { keepLeft: 1, keepRight: 1, compactTo: 4 }); // $ExpectType string
// => 4****2
coverup("4242-4242-4242-4242", { keepLeft: 4 }); // $ExpectType string
// => 4242***************
coverup("4242-4242-4242-4242", { keepRight: 4 }); // $ExpectType string
// => ***************4242
let options: coverup.Options = {
char: "x",
keepLeft: 3,
keepRight: 3,
};
coverup("4242-4242-4242-4242", options); // $ExpectType string
// => 424xxxxxxxxxxxxx242
options = {
keepLeft: 1,
keepRight: 1,
compactTo: 4,
keepSymbols: true,
};
coverup("4242-4242-4242-4242", options); // $ExpectError "you cannot define both compactTo and keepSymbols"
// => Error: you cannot define both compactTo and keepSymbols

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

@@ -0,0 +1,20 @@
// Type definitions for coverup 0.1
// Project: https://github.com/jsonmaur/coverup
// Definitions by: Vadim Belorussov <https://github.com/bevalorous>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace Coverup;
export = coverup;
declare function coverup(value: string, options?: coverup.Options): string;
declare namespace coverup {
interface Options {
char?: string;
keepLeft?: number;
keepRight?: number;
compactTo?: number;
keepSymbols?: boolean;
}
}

View File

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

View File

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