Merge pull request #3642 from hanazuki/lodash

lodash: Add definitions for string-related functions
This commit is contained in:
Masahiro Wakame
2015-02-17 00:12:49 +09:00
2 changed files with 79 additions and 16 deletions
+35
View File
@@ -1096,6 +1096,41 @@ result = <string>_.unescape('Moe, Larry &amp; Curly');
result = <string>_.uniqueId('contact_');
result = <string>_.uniqueId();
/*********
* String
*********/
result = <string>_.camelCase('Foo Bar');
result = <string>_.capitalize('fred');
result = <string>_.deburr('déjà vu');
result = <boolean>_.endsWith('abc', 'c');
result = <string>_.escape('fred, barney, & pebbles');
result = <string>_.escapeRegExp('[lodash](https://lodash.com/)');
result = <string>_.kebabCase('Foo Bar');
result = <string>_.pad('abc', 8);
result = <string>_.pad('abc', 8, '_-');
result = <string>_.padLeft('abc', 6);
result = <string>_.padLeft('abc', 6, '_-');
result = <string>_.padRight('abc', 6);
result = <string>_.padRight('abc', 6, '_-');
result = <string>_.repeat('*', 3);
result = <string>_.snakeCase('Foo Bar');
result = <string>_.startCase('--foo-bar');
result = <boolean>_.startsWith('abc', 'a');
result = <string>_.trim(' abc ');
result = <string>_.trim('-_-abc-_-', '_-');
result = <string>_.trimLeft(' abc ');
result = <string>_.trimLeft('-_-abc-_-', '_-');
result = <string>_.trimRight(' abc ');
result = <string>_.trimRight('-_-abc-_-', '_-');
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[]>_.words('fred, barney, & pebbles');
result = <string[]>_.words('fred, barney, & pebbles', /[^, ]+/g);
/**********
* Utilities *
***********/
+44 -16
View File
@@ -6133,6 +6133,50 @@ declare module _ {
values(object: any): any[];
}
/**********
* String *
**********/
interface LoDashStatic {
camelCase(str?: string): string;
capitalize(str?: string): string;
deburr(str?: string): string;
endsWith(str?: string, target?: string, position?: number): boolean;
escape(str?: string): string;
escapeRegExp(str?: string): string;
kebabCase(str?: string): string;
pad(str?: string, length?: number, chars?: string): string;
padLeft(str?: string, length?: number, chars?: string): string;
padRight(str?: string, length?: number, chars?: string): string;
repeat(str?: string, n?: number): string;
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;
trunc(str?: string, len?: number): string;
trunc(str?: string, options?: { length?: number; omission?: string; separator?: string }): string;
trunc(str?: string, options?: { length?: number; omission?: string; separator?: RegExp }): string;
words(str?: string, pattern?: string): string[];
words(str?: string, pattern?: RegExp): string[];
}
//_.parseInt
interface LoDashStatic {
/**
* Converts the given value into an integer of the specified radix. If radix is undefined or 0 a
* radix of 10 is used unless the value is a hexadecimal, in which case a radix of 16 is used.
*
* Note: This method avoids differences in native ES3 and ES5 parseInt implementations. See
* http://es5.github.io/#E.
* @param value The value to parse.
* @param radix The radix used to interpret the value to parse.
* @return The new integer value.
**/
parseInt(value: string, radix?: number): number;
}
/*************
* Utilities *
*************/
@@ -6174,22 +6218,6 @@ declare module _ {
noConflict(): typeof _;
}
//_.parseInt
interface LoDashStatic {
/**
* Converts the given value into an integer of the specified radix. If radix is undefined or 0 a
* radix of 10 is used unless the value is a hexadecimal, in which case a radix of 16 is used.
*
* Note: This method avoids differences in native ES3 and ES5 parseInt implementations. See
* http://es5.github.io/#E.
* @param value The value to parse.
* @param radix The radix used to interpret the value to parse.
* @return The new integer value.
**/
parseInt(value: string): number;
}
//_.property
interface LoDashStatic {
/**