From 8ed21ff1e803afb57f7e4881941df02e1caeba86 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 13 Aug 2015 02:39:44 +0500 Subject: [PATCH] lodash: changed _.trim(), _.trimLeft() and _.trimRight() methods --- lodash/lodash-tests.ts | 16 +++++++++++ lodash/lodash.d.ts | 60 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d7d4b6f71..68c02896b 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1542,12 +1542,28 @@ result = _.repeat('*', 3); result = _.snakeCase('Foo Bar'); result = _.startCase('--foo-bar'); result = _.startsWith('abc', 'a'); + +// _.trim +result = _.trim(); result = _.trim(' abc '); result = _.trim('-_-abc-_-', '_-'); +result = _('-_-abc-_-').trim(); +result = _('-_-abc-_-').trim('_-'); + +// _.trimLeft +result = _.trimLeft(); result = _.trimLeft(' abc '); result = _.trimLeft('-_-abc-_-', '_-'); +result = _('-_-abc-_-').trimLeft(); +result = _('-_-abc-_-').trimLeft('_-'); + +// _.trimRight +result = _.trimRight(); result = _.trimRight(' abc '); result = _.trimRight('-_-abc-_-', '_-'); +result = _('-_-abc-_-').trimRight(); +result = _('-_-abc-_-').trimRight('_-'); + 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': ' ' }); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index acfa93dec..9e5f7b6bf 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7175,9 +7175,63 @@ declare module _ { snakeCase(str?: string): string; startCase(str?: string): string; startsWith(str?: string, target?: string, position?: number): boolean; - trim(str?: string, chars?: string): string; - trimLeft(str?: string, chars?: string): string; - trimRight(str?: string, chars?: string): string; + } + + //_.trim + interface LoDashStatic { + /** + * Removes leading and trailing whitespace or specified characters from string. + * @param string The string to trim. + * @param chars The characters to trim. + * @return Returns the trimmed string. + */ + trim(string?: string, chars?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.trim + */ + trim(chars?: string): string; + } + + //_.trimLeft + interface LoDashStatic { + /** + * Removes leading whitespace or specified characters from string. + * @param string The string to trim. + * @param chars The characters to trim. + * @return Returns the trimmed string. + */ + trimLeft(string?: string, chars?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.trimLeft + */ + trimLeft(chars?: string): string; + } + + //_.trimRight + interface LoDashStatic { + /** + * Removes trailing whitespace or specified characters from string. + * @param string The string to trim. + * @param chars The characters to trim. + * @return Returns the trimmed string. + */ + trimRight(string?: string, chars?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.trimRight + */ + trimRight(chars?: string): string; + } + + interface LoDashStatic { trunc(str?: string, len?: number): string; trunc(str?: string, options?: { length?: number; omission?: string; separator?: string|RegExp }): string; words(str?: string, pattern?: string|RegExp): string[];