diff --git a/types/smart-truncate/index.d.ts b/types/smart-truncate/index.d.ts new file mode 100644 index 0000000000..a1250c9f54 --- /dev/null +++ b/types/smart-truncate/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for smart-truncate 1.0 +// Project: https://github.com/millerized/smart-truncate +// Definitions by: Omer Yalhi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function smartTruncate(text: string, length: number, options?: { position?: number; mark?: string }): string; diff --git a/types/smart-truncate/smart-truncate-tests.ts b/types/smart-truncate/smart-truncate-tests.ts new file mode 100644 index 0000000000..0e0caefc50 --- /dev/null +++ b/types/smart-truncate/smart-truncate-tests.ts @@ -0,0 +1,7 @@ +import { smartTruncate } from 'smart-truncate'; + +const length = 9; +let result = ''; +result = smartTruncate('Steve Miller', length); +result = smartTruncate('Steve Miller', length, {position: 4}); +result = smartTruncate('abcdefghijklmnopqrstuvwxyz', 7, {position: 3, mark: '—'}); diff --git a/types/smart-truncate/tsconfig.json b/types/smart-truncate/tsconfig.json new file mode 100644 index 0000000000..708868434f --- /dev/null +++ b/types/smart-truncate/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "smart-truncate-tests.ts" + ] +} \ No newline at end of file diff --git a/types/smart-truncate/tslint.json b/types/smart-truncate/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/smart-truncate/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }