diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 35b94040d3..def5a628f7 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3954,16 +3954,33 @@ result = _('-_-abc-_-').trimRight(); result = _('-_-abc-_-').trimRight('_-'); // _.trunc -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': ' […]' }); +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; + + 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 = _.unescape('fred, barney, & pebbles'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 3ee0959db0..875c61d487 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9506,11 +9506,15 @@ declare module _ { /** * 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; + trunc( + string?: string, + options?: TruncOptions|number + ): string; } interface LoDashImplicitWrapper { @@ -9520,6 +9524,13 @@ declare module _ { trunc(options?: TruncOptions|number): string; } + interface LoDashExplicitWrapper { + /** + * @see _.trunc + */ + trunc(options?: TruncOptions|number): LoDashExplicitWrapper; + } + //_.unescape interface LoDashStatic { /**