From 08671c96f7b075d1ef379257778d9d0494a08545 Mon Sep 17 00:00:00 2001 From: DomiR Date: Fri, 15 Jan 2016 02:14:47 +0100 Subject: [PATCH] (feature) Add _.toInteger --- lodash/lodash-tests.ts | 55 ++++++++++++++++++++++++++++++++---------- lodash/lodash.d.ts | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 13 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 3a748e852..ed64e9179 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -6523,21 +6523,50 @@ module TestToArray { // _.toPlainObject module TestToPlainObject { - let result: TResult; - result = _.toPlainObject(); - result = _.toPlainObject(true); - result = _.toPlainObject(1); - result = _.toPlainObject('a'); - result = _.toPlainObject([]); - result = _.toPlainObject({}); + { + let result: TResult; + result = _.toPlainObject(); + result = _.toPlainObject(true); + result = _.toPlainObject(1); + result = _.toPlainObject('a'); + result = _.toPlainObject([]); + result = _.toPlainObject({}); + } - result = _(true).toPlainObject().value(); - result = _(1).toPlainObject().value(); - result = _('a').toPlainObject().value(); - result = _([1]).toPlainObject().value(); - result = _([]).toPlainObject().value(); - result = _({}).toPlainObject().value(); + { + let result: _.LoDashImplicitObjectWrapper; + + result = _(true).toPlainObject(); + result = _(1).toPlainObject(); + result = _('a').toPlainObject(); + result = _([1]).toPlainObject(); + result = _([]).toPlainObject(); + result = _({}).toPlainObject(); + } +} + +// _.toInteger +module TestToInteger { + { + let result: number; + result = _.toInteger(true); + result = _.toInteger(1); + result = _.toInteger('a'); + result = _.toInteger([]); + result = _.toInteger({}); + } + + { + let result: _.LoDashImplicitWrapper; + + result = _(true).toInteger(); + result = _(1).toInteger(); + result = _('a').toInteger(); + result = _([1]).toInteger(); + result = _([]).toInteger(); + result = _({}).toInteger(); + } } /******** diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 56b21f99c..063ae8522 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -10476,6 +10476,49 @@ declare module _ { toPlainObject(): LoDashImplicitObjectWrapper; } + //_.toInteger + interface LoDashStatic { + /** + * Converts `value` to an integer. + * + * **Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toInteger(3); + * // => 3 + * + * _.toInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3'); + * // => 3 + */ + toInteger(value: any): number; + } + + interface LoDashImplicitWrapperBase { + /** + * @see _.toInteger + */ + toInteger(): LoDashImplicitWrapper; + } + + interface LoDashExplicitWrapperBase { + /** + * @see _.toInteger + */ + toInteger(): LoDashExplicitWrapper; + } + /******** * Math * ********/