Merge pull request #6441 from chrootsu/lodash-trunc

lodash: signatures of the method _.trunc changed
This commit is contained in:
Masahiro Wakame
2015-10-27 00:59:52 +09:00
2 changed files with 39 additions and 11 deletions
+27 -10
View File
@@ -3954,16 +3954,33 @@ 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': ' […]' });
module TestTrunc {
{
let result: string;
result = _.trunc('hi-diddly-ho there, neighborino');
result = _.trunc('hi-diddly-ho there, neighborino', 24);
result = _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' });
result = _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ });
result = _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' […]' });
result = _('hi-diddly-ho there, neighborino').trunc();
result = _('hi-diddly-ho there, neighborino').trunc(24);
result = _('hi-diddly-ho there, neighborino').trunc({ 'length': 24, 'separator': ' ' });
result = _('hi-diddly-ho there, neighborino').trunc({ 'length': 24, 'separator': /,? +/ });
result = _('hi-diddly-ho there, neighborino').trunc({ 'omission': ' […]' });
}
{
let result: _.LoDashExplicitWrapper<string>;
result = _('hi-diddly-ho there, neighborino').chain().trunc();
result = _('hi-diddly-ho there, neighborino').chain().trunc(24);
result = _('hi-diddly-ho there, neighborino').chain().trunc({ 'length': 24, 'separator': ' ' });
result = _('hi-diddly-ho there, neighborino').chain().trunc({ 'length': 24, 'separator': /,? +/ });
result = _('hi-diddly-ho there, neighborino').chain().trunc({ 'omission': ' […]' });
}
}
// _.unescape
result = <string>_.unescape('fred, barney, &amp; pebbles');
+12 -1
View File
@@ -9506,11 +9506,15 @@ declare module _ {
/**
* Truncates string if its 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;
trunc(
string?: string,
options?: TruncOptions|number
): string;
}
interface LoDashImplicitWrapper<T> {
@@ -9520,6 +9524,13 @@ declare module _ {
trunc(options?: TruncOptions|number): string;
}
interface LoDashExplicitWrapper<T> {
/**
* @see _.trunc
*/
trunc(options?: TruncOptions|number): LoDashExplicitWrapper<string>;
}
//_.unescape
interface LoDashStatic {
/**