@antv/util
Advanced tools
Comparing version 2.0.10 to 2.0.11
import isArray from './is-array'; | ||
import { default as getMax } from './max'; | ||
import { default as getMin } from './min'; | ||
var getRange = function (values) { | ||
// 存在 NaN 时,min,max 判定会出问题 | ||
var filterValues = values.filter(function (v) { return !isNaN(v); }); | ||
if (!filterValues.length) { // 如果没有数值则直接返回0 | ||
if (!filterValues.length) { | ||
// 如果没有数值则直接返回0 | ||
return { | ||
@@ -18,4 +21,4 @@ min: 0, | ||
} | ||
var max = Math.max.apply(null, filterValues); | ||
var min = Math.min.apply(null, filterValues); | ||
var max = getMax(filterValues); | ||
var min = getMin(filterValues); | ||
return { | ||
@@ -22,0 +25,0 @@ min: min, |
@@ -40,3 +40,5 @@ export { default as contains, default as includes } from './contains'; | ||
export { default as isPositive } from './is-positive'; | ||
export { default as max } from './max'; | ||
export { default as maxBy } from './max-by'; | ||
export { default as min } from './min'; | ||
export { default as minBy } from './min-by'; | ||
@@ -99,2 +101,3 @@ export { default as mod } from './mod'; | ||
export { default as pick } from './pick'; | ||
export { default as omit } from './omit'; | ||
export { default as throttle } from './throttle'; | ||
@@ -101,0 +104,0 @@ export { default as toArray } from './to-array'; |
@@ -44,3 +44,5 @@ // array | ||
export { default as isPositive } from './is-positive'; | ||
export { default as max } from './max'; | ||
export { default as maxBy } from './max-by'; | ||
export { default as min } from './min'; | ||
export { default as minBy } from './min-by'; | ||
@@ -107,2 +109,3 @@ export { default as mod } from './mod'; | ||
export { default as pick } from './pick'; | ||
export { default as omit } from './omit'; | ||
export { default as throttle } from './throttle'; | ||
@@ -109,0 +112,0 @@ export { default as toArray } from './to-array'; |
@@ -1,2 +0,3 @@ | ||
declare const reduce: <T, G>(arr: G[], fn: (result: T, data: G, idx: number) => T, init: T) => T; | ||
import { ObjectType } from './types'; | ||
declare const reduce: <T, G>(arr: ObjectType<T> | G[], fn: (result: T, data: G, idx: string | number) => T, init: T) => T; | ||
export default reduce; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var is_array_1 = require("./is-array"); | ||
var max_1 = require("./max"); | ||
var min_1 = require("./min"); | ||
var getRange = function (values) { | ||
// 存在 NaN 时,min,max 判定会出问题 | ||
var filterValues = values.filter(function (v) { return !isNaN(v); }); | ||
if (!filterValues.length) { // 如果没有数值则直接返回0 | ||
if (!filterValues.length) { | ||
// 如果没有数值则直接返回0 | ||
return { | ||
@@ -20,4 +23,4 @@ min: 0, | ||
} | ||
var max = Math.max.apply(null, filterValues); | ||
var min = Math.min.apply(null, filterValues); | ||
var max = max_1.default(filterValues); | ||
var min = min_1.default(filterValues); | ||
return { | ||
@@ -24,0 +27,0 @@ min: min, |
@@ -40,3 +40,5 @@ export { default as contains, default as includes } from './contains'; | ||
export { default as isPositive } from './is-positive'; | ||
export { default as max } from './max'; | ||
export { default as maxBy } from './max-by'; | ||
export { default as min } from './min'; | ||
export { default as minBy } from './min-by'; | ||
@@ -99,2 +101,3 @@ export { default as mod } from './mod'; | ||
export { default as pick } from './pick'; | ||
export { default as omit } from './omit'; | ||
export { default as throttle } from './throttle'; | ||
@@ -101,0 +104,0 @@ export { default as toArray } from './to-array'; |
@@ -86,4 +86,8 @@ "use strict"; | ||
Object.defineProperty(exports, "isPositive", { enumerable: true, get: function () { return is_positive_1.default; } }); | ||
var max_1 = require("./max"); | ||
Object.defineProperty(exports, "max", { enumerable: true, get: function () { return max_1.default; } }); | ||
var max_by_1 = require("./max-by"); | ||
Object.defineProperty(exports, "maxBy", { enumerable: true, get: function () { return max_by_1.default; } }); | ||
var min_1 = require("./min"); | ||
Object.defineProperty(exports, "min", { enumerable: true, get: function () { return min_1.default; } }); | ||
var min_by_1 = require("./min-by"); | ||
@@ -208,2 +212,4 @@ Object.defineProperty(exports, "minBy", { enumerable: true, get: function () { return min_by_1.default; } }); | ||
Object.defineProperty(exports, "pick", { enumerable: true, get: function () { return pick_1.default; } }); | ||
var omit_1 = require("./omit"); | ||
Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return omit_1.default; } }); | ||
var throttle_1 = require("./throttle"); | ||
@@ -210,0 +216,0 @@ Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return throttle_1.default; } }); |
@@ -1,2 +0,3 @@ | ||
declare const reduce: <T, G>(arr: G[], fn: (result: T, data: G, idx: number) => T, init: T) => T; | ||
import { ObjectType } from './types'; | ||
declare const reduce: <T, G>(arr: ObjectType<T> | G[], fn: (result: T, data: G, idx: string | number) => T, init: T) => T; | ||
export default reduce; |
{ | ||
"name": "@antv/util", | ||
"version": "2.0.10", | ||
"version": "2.0.11", | ||
"description": "A common util collection for antv projects", | ||
@@ -47,2 +47,3 @@ "main": "lib/index.js", | ||
"@antv/torch": "^1.0.0", | ||
"chai": "^4.2.0", | ||
"less": "^3.9.0", | ||
@@ -49,0 +50,0 @@ "npm-run-all": "^4.1.5" |
import isArray from './is-array'; | ||
import { default as getMax } from './max'; | ||
import { default as getMin } from './min'; | ||
@@ -11,3 +13,4 @@ export interface RangeType { | ||
let filterValues = values.filter((v) => !isNaN(v)); | ||
if (!filterValues.length) { // 如果没有数值则直接返回0 | ||
if (!filterValues.length) { | ||
// 如果没有数值则直接返回0 | ||
return { | ||
@@ -25,4 +28,4 @@ min: 0, | ||
} | ||
const max = Math.max.apply(null, filterValues); | ||
const min = Math.min.apply(null, filterValues); | ||
const max = getMax(filterValues); | ||
const min = getMin(filterValues); | ||
return { | ||
@@ -29,0 +32,0 @@ min, |
@@ -48,3 +48,5 @@ // array | ||
export { default as isPositive } from './is-positive'; | ||
export { default as max } from './max'; | ||
export { default as maxBy } from './max-by'; | ||
export { default as min } from './min'; | ||
export { default as minBy } from './min-by'; | ||
@@ -116,2 +118,3 @@ export { default as mod } from './mod'; | ||
export { default as pick } from './pick'; | ||
export { default as omit } from './omit'; | ||
export { default as throttle } from './throttle'; | ||
@@ -118,0 +121,0 @@ export { default as toArray } from './to-array'; |
import each from './each'; | ||
import isArray from './is-array'; | ||
import isPlainObject from './is-plain-object'; | ||
import { ObjectType } from './types'; | ||
const reduce = function<T, G>(arr: G[], fn: (result: T, data: G, idx: number) => T, init: T) { | ||
const reduce = function<T, G>(arr: G[]|ObjectType<T>, fn: (result: T, data: G, idx: string | number) => T, init: T) { | ||
if (!isArray(arr) && !isPlainObject(arr)) { | ||
@@ -7,0 +8,0 @@ return arr; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
335459
786
6551
4