mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-28 12:43:06 +08:00
lodash: changed _.trunc() method
This commit is contained in:
@@ -1706,11 +1706,17 @@ result = <string>_.trimRight('-_-abc-_-', '_-');
|
||||
result = <string>_('-_-abc-_-').trimRight();
|
||||
result = <string>_('-_-abc-_-').trimRight('_-');
|
||||
|
||||
// _.trunc
|
||||
result = <string>_.trunc('hi-diddly-ho there, neighborino');
|
||||
result = <string>_.trunc('hi-diddly-ho there, neighborino', 24);
|
||||
result = <string>_.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' });
|
||||
result = <string>_.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ });
|
||||
result = <string>_.trunc('hi-diddly-ho there, neighborino', { 'omission': ' […]' });
|
||||
result = <string>_('hi-diddly-ho there, neighborino').trunc();
|
||||
result = <string>_('hi-diddly-ho there, neighborino').trunc(24);
|
||||
result = <string>_('hi-diddly-ho there, neighborino').trunc({ 'length': 24, 'separator': ' ' });
|
||||
result = <string>_('hi-diddly-ho there, neighborino').trunc({ 'length': 24, 'separator': /,? +/ });
|
||||
result = <string>_('hi-diddly-ho there, neighborino').trunc({ 'omission': ' […]' });
|
||||
|
||||
// _.unescape
|
||||
result = <string>_.unescape('fred, barney, & pebbles');
|
||||
|
||||
Vendored
+25
-2
@@ -7587,9 +7587,32 @@ declare module _ {
|
||||
trimRight(chars?: string): string;
|
||||
}
|
||||
|
||||
//_.trunc
|
||||
interface TruncOptions {
|
||||
/** The maximum string length. */
|
||||
length?: number;
|
||||
/** The string to indicate text is omitted. */
|
||||
omission?: string;
|
||||
/** The separator pattern to truncate to. */
|
||||
separator?: string|RegExp;
|
||||
}
|
||||
|
||||
interface LoDashStatic {
|
||||
trunc(str?: string, len?: number): string;
|
||||
trunc(str?: string, options?: { length?: number; omission?: string; separator?: string|RegExp }): string;
|
||||
/**
|
||||
* Truncates string if it’s longer than the given maximum string length. The last characters of the truncated
|
||||
* string are replaced with the omission string which defaults to "…".
|
||||
* @param string The string to truncate.
|
||||
* @param options The options object or maximum string length.
|
||||
* @return Returns the truncated string.
|
||||
*/
|
||||
trunc(string?: string, options?: TruncOptions|number): string;
|
||||
}
|
||||
|
||||
interface LoDashWrapper<T> {
|
||||
/**
|
||||
* @see _.trunc
|
||||
*/
|
||||
trunc(options?: TruncOptions|number): string;
|
||||
}
|
||||
|
||||
//_.unescape
|
||||
|
||||
Reference in New Issue
Block a user