mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(pre-suf): new type definition (#43866)
- declaration file - tests https://github.com/kaelzhang/node-pre-suf Thanks!
This commit is contained in:
parent
275fd285c4
commit
a0a52a6a3d
27
types/pre-suf/index.d.ts
vendored
Normal file
27
types/pre-suf/index.d.ts
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Type definitions for pre-suf 1.1
|
||||
// Project: https://github.com/kaelzhang/node-pre-suf#readme
|
||||
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Manipulate strings with prefixes and suffixes.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ensures that the new string will have prefix at the beginning of str.
|
||||
* If str does not begin with prefix, prefix will be added to the beggining of str.
|
||||
*/
|
||||
export function ensureLeading(str: string, prefix: string): string;
|
||||
/**
|
||||
* Removes the leading prefix of str.
|
||||
*/
|
||||
export function removeLeading(str: string, prefix: string): string;
|
||||
/**
|
||||
* Ensures that the new string will have suffix at the end of str.
|
||||
* If str does not end with suffix, suffix will be added at the end of str.
|
||||
*/
|
||||
export function ensureEnding(str: string, suffix: string): string;
|
||||
/**
|
||||
* Removes the ending suffix of str.
|
||||
*/
|
||||
export function removeEnding(str: string, suffix: string): string;
|
||||
14
types/pre-suf/pre-suf-tests.ts
Normal file
14
types/pre-suf/pre-suf-tests.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import presuf = require('pre-suf');
|
||||
|
||||
presuf.ensureLeading('a', '/'); // $ExpectType string
|
||||
presuf.removeLeading('a', '/'); // $ExpectType string
|
||||
presuf.ensureEnding('a', '/'); // $ExpectType string
|
||||
presuf.removeEnding('/a/ab/a', '/a'); // $ExpectType string
|
||||
// $ExpectError
|
||||
presuf.ensureLeading();
|
||||
// $ExpectError
|
||||
presuf.removeLeading();
|
||||
// $ExpectError
|
||||
presuf.ensureEnding();
|
||||
// $ExpectError
|
||||
presuf.removeEnding();
|
||||
23
types/pre-suf/tsconfig.json
Normal file
23
types/pre-suf/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"pre-suf-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/pre-suf/tslint.json
Normal file
1
types/pre-suf/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user