From 954754d210bb0a3835bcb4ab14ef08f034d30858 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 13 Aug 2015 02:18:48 +0500 Subject: [PATCH] lodash: changed _.parseInt() method --- lodash/lodash-tests.ts | 9 +++++++-- lodash/lodash.d.ts | 38 +++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d7d4b6f71..e3b60da0f 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1454,8 +1454,6 @@ _.mixin({ var lodash = _.noConflict(); -result = _.parseInt('08'); - result = _.random(0, 5); result = _.random(5); result = _.random(5, true); @@ -1539,6 +1537,13 @@ result = _.padLeft('abc', 6, '_-'); result = _.padRight('abc', 6); result = _.padRight('abc', 6, '_-'); result = _.repeat('*', 3); + +// _.parseInt +result = _.parseInt('08'); +result = _.parseInt('08', 10); +result = _('08').parseInt(); +result = _('08').parseInt(10); + result = _.snakeCase('Foo Bar'); result = _.startCase('--foo-bar'); result = _.startsWith('abc', 'a'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index acfa93dec..9eedb148a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -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 { + /** + * @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 * *************/