mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-28 08:17:54 +08:00
Merge pull request #21306 from bevalorous/coverup
add declarations for coverup
This commit is contained in:
38
types/coverup/coverup-tests.ts
Normal file
38
types/coverup/coverup-tests.ts
Normal 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
20
types/coverup/index.d.ts
vendored
Normal 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;
|
||||
}
|
||||
}
|
||||
23
types/coverup/tsconfig.json
Normal file
23
types/coverup/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/coverup/tslint.json
Normal file
1
types/coverup/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user