mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-10 20:20:12 +00:00
Merge pull request #33494 from adamzerella/types/html-truncate
[html-truncate] Add typing for html-truncate
This commit is contained in:
13
types/html-truncate/html-truncate-tests.ts
Normal file
13
types/html-truncate/html-truncate-tests.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import Truncate = require("html-truncate");
|
||||
|
||||
Truncate('hello world', 4);
|
||||
|
||||
Truncate('<p><div>hello world</div></p>', 4, {
|
||||
keepImageTag: true,
|
||||
ellipsis: true
|
||||
});
|
||||
|
||||
Truncate('<p><div>hello world</div></p>', 6, {
|
||||
keepImageTag: false,
|
||||
ellipsis: '---'
|
||||
});
|
||||
23
types/html-truncate/index.d.ts
vendored
Normal file
23
types/html-truncate/index.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// Type definitions for html-truncate 1.2
|
||||
// Project: https://github.com/huang47/nodejs-html-truncate
|
||||
// Definitions by: Adam Zerella <https://github.com/adamzerella>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
interface TruncateOptions {
|
||||
/**
|
||||
* Flag to specify if keep image tag, false by default.
|
||||
*/
|
||||
keepImageTag: boolean;
|
||||
/**
|
||||
* Omission symbol for truncated string, '...' by default.
|
||||
*/
|
||||
ellipsis: boolean|string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate HTML text and also keep tag safe.
|
||||
*/
|
||||
declare function truncate(input: string, maxLength: number, options?: TruncateOptions): string;
|
||||
|
||||
export = truncate;
|
||||
25
types/html-truncate/tsconfig.json
Normal file
25
types/html-truncate/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [
|
||||
|
||||
],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"html-truncate-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/html-truncate/tslint.json
Normal file
3
types/html-truncate/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user