lodash: changed _.trim(), _.trimLeft() and _.trimRight() methods

This commit is contained in:
Ilya Mochalov
2015-08-13 21:45:36 +05:00
parent e95958ac84
commit 8ed21ff1e8
2 changed files with 73 additions and 3 deletions
+16
View File
@@ -1542,12 +1542,28 @@ result = <string>_.repeat('*', 3);
result = <string>_.snakeCase('Foo Bar');
result = <string>_.startCase('--foo-bar');
result = <boolean>_.startsWith('abc', 'a');
// _.trim
result = <string>_.trim();
result = <string>_.trim(' abc ');
result = <string>_.trim('-_-abc-_-', '_-');
result = <string>_('-_-abc-_-').trim();
result = <string>_('-_-abc-_-').trim('_-');
// _.trimLeft
result = <string>_.trimLeft();
result = <string>_.trimLeft(' abc ');
result = <string>_.trimLeft('-_-abc-_-', '_-');
result = <string>_('-_-abc-_-').trimLeft();
result = <string>_('-_-abc-_-').trimLeft('_-');
// _.trimRight
result = <string>_.trimRight();
result = <string>_.trimRight(' abc ');
result = <string>_.trimRight('-_-abc-_-', '_-');
result = <string>_('-_-abc-_-').trimRight();
result = <string>_('-_-abc-_-').trimRight('_-');
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': ' ' });
+57 -3
View File
@@ -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<T> {
/**
* @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<T> {
/**
* @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<T> {
/**
* @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[];