|
42 | 42 | d3.min = function(array, f) { |
43 | 43 | var i = -1, n = array.length, a, b; |
44 | 44 | if (arguments.length === 1) { |
45 | | - while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined; |
| 45 | + while (++i < n) if ((b = array[i]) != null && b >= b) { |
| 46 | + a = b; |
| 47 | + break; |
| 48 | + } |
46 | 49 | while (++i < n) if ((b = array[i]) != null && a > b) a = b; |
47 | 50 | } else { |
48 | | - while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined; |
| 51 | + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { |
| 52 | + a = b; |
| 53 | + break; |
| 54 | + } |
49 | 55 | while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; |
50 | 56 | } |
51 | 57 | return a; |
52 | 58 | }; |
53 | 59 | d3.max = function(array, f) { |
54 | 60 | var i = -1, n = array.length, a, b; |
55 | 61 | if (arguments.length === 1) { |
56 | | - while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined; |
| 62 | + while (++i < n) if ((b = array[i]) != null && b >= b) { |
| 63 | + a = b; |
| 64 | + break; |
| 65 | + } |
57 | 66 | while (++i < n) if ((b = array[i]) != null && b > a) a = b; |
58 | 67 | } else { |
59 | | - while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined; |
| 68 | + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { |
| 69 | + a = b; |
| 70 | + break; |
| 71 | + } |
60 | 72 | while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b; |
61 | 73 | } |
62 | 74 | return a; |
63 | 75 | }; |
64 | 76 | d3.extent = function(array, f) { |
65 | 77 | var i = -1, n = array.length, a, b, c; |
66 | 78 | if (arguments.length === 1) { |
67 | | - while (++i < n && !((a = c = array[i]) != null && a <= a)) a = c = undefined; |
| 79 | + while (++i < n) if ((b = array[i]) != null && b >= b) { |
| 80 | + a = c = b; |
| 81 | + break; |
| 82 | + } |
68 | 83 | while (++i < n) if ((b = array[i]) != null) { |
69 | 84 | if (a > b) a = b; |
70 | 85 | if (c < b) c = b; |
71 | 86 | } |
72 | 87 | } else { |
73 | | - while (++i < n && !((a = c = f.call(array, array[i], i)) != null && a <= a)) a = undefined; |
| 88 | + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { |
| 89 | + a = c = b; |
| 90 | + break; |
| 91 | + } |
74 | 92 | while (++i < n) if ((b = f.call(array, array[i], i)) != null) { |
75 | 93 | if (a > b) a = b; |
76 | 94 | if (c < b) c = b; |
|
100 | 118 | } else { |
101 | 119 | while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j; |
102 | 120 | } |
103 | | - return j ? s / j : undefined; |
| 121 | + if (j) return s / j; |
104 | 122 | }; |
105 | 123 | d3.quantile = function(values, p) { |
106 | 124 | var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h; |
|
113 | 131 | } else { |
114 | 132 | while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a); |
115 | 133 | } |
116 | | - return numbers.length ? d3.quantile(numbers.sort(d3_ascending), .5) : undefined; |
| 134 | + if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5); |
117 | 135 | }; |
118 | 136 | function d3_bisector(compare) { |
119 | 137 | return { |
|
0 commit comments