Merge pull request #22262 from mattlewis92/twitter-text-v2

twitter-text: update for v2
This commit is contained in:
Paul van Brenk
2017-12-28 11:11:21 -08:00
committed by GitHub
2 changed files with 30 additions and 2 deletions
+27 -2
View File
@@ -1,6 +1,6 @@
// Type definitions for twitter-text v1.14.7
// Type definitions for twitter-text v2.0.0
// Project: https://github.com/twitter/twitter-text
// Definitions by: rhysd <https://rhysd.github.io>
// Definitions by: rhysd <https://github.com/rhysd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -112,3 +112,28 @@ export declare function getUnicodeTextLength(text: string): number;
export declare function convertUnicodeIndices(text: string, entities: EntityWithIndices[], indicesInUTF16?: boolean): void;
export declare function hitHighlight(text: string, hits?: number[][], options?: { tag: string }): string;
export interface ParseTweetOptions {
version?: number;
maxWeightedTweetLength?: number;
scale?: number;
defaultWeight?: number;
transformedURLLength?: number;
ranges?: Array<{
start: number;
end: number;
weight: number;
}>;
}
export interface ParsedTweet {
weightedLength: number;
permillage: number;
valid: boolean;
displayRangeEnd: number;
displayRangeStart: number;
validRangeEnd: number;
validRangeStart: number;
}
export declare function parseTweet(text: string, options?: ParseTweetOptions): ParsedTweet;
+3
View File
@@ -60,3 +60,6 @@ const linked: string = twitter.autoLink("link @user, and expand url... http://t.
]});
const usernames: string[] = twitter.extractMentions("Mentioning @twitter and @jack");
const tweet = twitter.parseTweet('foo');
const tweetWithOptions = twitter.parseTweet('foo', {maxWeightedTweetLength: 140});