Add declarations for coverup

This commit is contained in:
Vadim Belorussov 2017-11-07 13:54:52 +05:00
parent f0b1bb2464
commit 6db5641a3e
4 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,32 @@
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
coverup("4242-4242-4242-4242", { keepLeft: 1, keepRight: 1, compactTo: 4, keepSymbols: true }); // $ExpectError
//=> 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 v0.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 {
export interface Options {
char?: string;
keepLeft?: number;
keepRight?: number;
compactTo?: number;
keepSymbols?: boolean;
}
}

View File

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

View File

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