Merge pull request #5032 from chrootsu/lodash-round

lodash: added _.round() method
This commit is contained in:
Masahiro Wakame
2015-07-28 23:18:05 +09:00
2 changed files with 32 additions and 0 deletions
+14
View File
@@ -534,6 +534,20 @@ result = <_.LoDashWrapper<number>>_([4, 2, 8, 6]).min();
result = <_.LoDashWrapper<IStoogesAge>>_(stoogesAges).min(function (stooge) { return stooge.age; });
result = <_.LoDashWrapper<IStoogesAge>>_(stoogesAges).min('age');
// _.round
result = <number>_.round(4.006);
// → 4
result = <number>_.round(4.006, 2);
// → 4.01
result = <number>_.round(4060, -2);
// → 4100
result = <number>_(4.006).round();
// → 4
result = <number>_(4.006).round(2);
// → 4.01
result = <number>_(4060).round(-2);
// → 4100
result = <number>_.sum([4, 2, 8, 6]);
result = <number>_.sum([4, 2, 8, 6], function(v) { return v; });
result = <number>_.sum({a: 2, b: 4});
+18
View File
@@ -3794,6 +3794,24 @@ declare module _ {
whereValue: W): LoDashWrapper<T>;
}
//_.round
interface LoDashStatic {
/**
* Calculates n rounded to precision.
* @param n The number to round.
* @param precision The precision to round to.
* @return Returns the rounded number.
*/
round(n: number, precision?: number): number;
}
interface LoDashWrapper<T> {
/**
* @see _.round
*/
round(precision?: number): number;
}
//_.sum
interface LoDashStatic {
/**