lodash: changed _.parseInt() method

This commit is contained in:
Ilya Mochalov
2015-08-13 21:47:01 +05:00
parent e95958ac84
commit 954754d210
2 changed files with 30 additions and 17 deletions
+7 -2
View File
@@ -1454,8 +1454,6 @@ _.mixin({
var lodash = <typeof _>_.noConflict();
result = <number>_.parseInt('08');
result = <number>_.random(0, 5);
result = <number>_.random(5);
result = <number>_.random(5, true);
@@ -1539,6 +1537,13 @@ result = <string>_.padLeft('abc', 6, '_-');
result = <string>_.padRight('abc', 6);
result = <string>_.padRight('abc', 6, '_-');
result = <string>_.repeat('*', 3);
// _.parseInt
result = <number>_.parseInt('08');
result = <number>_.parseInt('08', 10);
result = <number>_('08').parseInt();
result = <number>_('08').parseInt(10);
result = <string>_.snakeCase('Foo Bar');
result = <string>_.startCase('--foo-bar');
result = <boolean>_.startsWith('abc', 'a');
+23 -15
View File
@@ -7171,6 +7171,29 @@ declare module _ {
pad(str?: string, length?: number, chars?: string): string;
padLeft(str?: string, length?: number, chars?: string): string;
padRight(str?: string, length?: number, chars?: string): string;
}
//_.parseInt
interface LoDashStatic {
/**
* Converts string to an integer of the specified radix. If radix is undefined or 0, a radix of 10 is used
* unless value is a hexadecimal, in which case a radix of 16 is used.
* Note: This method aligns with the ES5 implementation of parseInt.
* @param string The string to convert.
* @param radix The radix to interpret value by.
* @return Returns the converted integer.
*/
parseInt(string: string, radix?: number): number;
}
interface LoDashWrapper<T> {
/**
* @see _.parseInt
*/
parseInt(radix?: number): number;
}
interface LoDashStatic {
repeat(str?: string, n?: number): string;
snakeCase(str?: string): string;
startCase(str?: string): string;
@@ -7183,21 +7206,6 @@ declare module _ {
words(str?: string, pattern?: string|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 *
*************/