(feature) Add _.toInteger

This commit is contained in:
DomiR
2016-01-23 14:43:48 +01:00
parent 34a25f6aef
commit 08671c96f7
2 changed files with 85 additions and 13 deletions
+42 -13
View File
@@ -6523,21 +6523,50 @@ module TestToArray {
// _.toPlainObject
module TestToPlainObject {
let result: TResult;
result = _.toPlainObject<TResult>();
result = _.toPlainObject<TResult>(true);
result = _.toPlainObject<TResult>(1);
result = _.toPlainObject<TResult>('a');
result = _.toPlainObject<TResult>([]);
result = _.toPlainObject<TResult>({});
{
let result: TResult;
result = _.toPlainObject<TResult>();
result = _.toPlainObject<TResult>(true);
result = _.toPlainObject<TResult>(1);
result = _.toPlainObject<TResult>('a');
result = _.toPlainObject<TResult>([]);
result = _.toPlainObject<TResult>({});
}
result = _(true).toPlainObject<TResult>().value();
result = _(1).toPlainObject<TResult>().value();
result = _('a').toPlainObject<TResult>().value();
result = _([1]).toPlainObject<TResult>().value();
result = _<string>([]).toPlainObject<TResult>().value();
result = _({}).toPlainObject<TResult>().value();
{
let result: _.LoDashImplicitObjectWrapper<TResult>;
result = _(true).toPlainObject<TResult>();
result = _(1).toPlainObject<TResult>();
result = _('a').toPlainObject<TResult>();
result = _([1]).toPlainObject<TResult>();
result = _<string>([]).toPlainObject<TResult>();
result = _({}).toPlainObject<TResult>();
}
}
// _.toInteger
module TestToInteger {
{
let result: number;
result = _.toInteger(true);
result = _.toInteger(1);
result = _.toInteger('a');
result = _.toInteger([]);
result = _.toInteger({});
}
{
let result: _.LoDashImplicitWrapper<number>;
result = _(true).toInteger();
result = _(1).toInteger();
result = _('a').toInteger();
result = _([1]).toInteger();
result = _<string>([]).toInteger();
result = _({}).toInteger();
}
}
/********
+43
View File
@@ -10476,6 +10476,49 @@ declare module _ {
toPlainObject<TResult extends {}>(): LoDashImplicitObjectWrapper<TResult>;
}
//_.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<T, TWrapper> {
/**
* @see _.toInteger
*/
toInteger(): LoDashImplicitWrapper<number>;
}
interface LoDashExplicitWrapperBase<T, TWrapper> {
/**
* @see _.toInteger
*/
toInteger(): LoDashExplicitWrapper<number>;
}
/********
* Math *
********/