Merge pull request #28458 from danwbyrne/cli-truncate

adds typings for the 'cli-truncate' package
This commit is contained in:
Armando Aguirre
2018-08-28 16:50:32 -07:00
committed by GitHub
4 changed files with 57 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import cliTruncate = require('cli-truncate');
// Truncate at different positions
// $ExpectType string
cliTruncate('unicorn', 4); // default position: 'end'
// $ExpectType string
cliTruncate('unicorn', 4, {position: 'start'});
// $ExpectType string
cliTruncate('unicorn', 4, {position: 'middle'});
// Truncate Unicode surrogate pairs
// $ExpectType string
cliTruncate('uni\uD83C\uDE00corn', 5);
// Truncate full-width characters
// $ExpectType string
cliTruncate('안녕하세요', 3);
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for cli-truncate 1.1
// Project: https://github.com/sindresorhus/cli-truncate
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = cliTruncate;
declare function cliTruncate(
input: string,
columns: number,
options?: {position?: 'start' | 'middle' | 'end'},
): string;
+23
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",
"cli-truncate-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}