Skip to content

Commit 9b83826

Browse files
committed
don't require all of Lib when only isArrayOrTypedArray is needed
1 parent f0395b5 commit 9b83826

File tree

10 files changed

+30
-30
lines changed

10 files changed

+30
-30
lines changed

src/traces/bar/calc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
'use strict';
1111

1212
var isNumeric = require('fast-isnumeric');
13+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1314

14-
var Lib = require('../../lib');
1515
var Axes = require('../../plots/cartesian/axes');
1616
var hasColorscale = require('../../components/colorscale/has_colorscale');
1717
var colorscaleCalc = require('../../components/colorscale/calc');
@@ -64,7 +64,7 @@ module.exports = function calc(gd, trace) {
6464
var base = trace.base,
6565
b;
6666

67-
if(Lib.isArrayOrTypedArray(base)) {
67+
if(isArrayOrTypedArray(base)) {
6868
for(i = 0; i < Math.min(base.length, cd.length); i++) {
6969
b = sa.d2c(base[i], 0, scalendar);
7070
if(isNumeric(b)) {

src/traces/bar/set_positions.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
'use strict';
1111

1212
var isNumeric = require('fast-isnumeric');
13+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1314
var BADNUM = require('../../constants/numerical').BADNUM;
1415

15-
var Lib = require('../../lib');
1616
var Registry = require('../../registry');
1717
var Axes = require('../../plots/cartesian/axes');
1818
var Sieve = require('./sieve.js');
@@ -314,7 +314,7 @@ function applyAttributes(sieve) {
314314
initialPoffset = t.poffset,
315315
newPoffset;
316316

317-
if(Lib.isArrayOrTypedArray(offset)) {
317+
if(isArrayOrTypedArray(offset)) {
318318
// if offset is an array, then clone it into t.poffset.
319319
newPoffset = offset.slice(0, calcTrace.length);
320320

@@ -340,7 +340,7 @@ function applyAttributes(sieve) {
340340
var width = fullTrace.width,
341341
initialBarwidth = t.barwidth;
342342

343-
if(Lib.isArrayOrTypedArray(width)) {
343+
if(isArrayOrTypedArray(width)) {
344344
// if width is an array, then clone it into t.barwidth.
345345
var newBarwidth = width.slice(0, calcTrace.length);
346346

src/traces/heatmap/has_columns.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
'use strict';
1010

11-
var Lib = require('../../lib');
11+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1212

1313
module.exports = function(trace) {
14-
return !Lib.isArrayOrTypedArray(trace.z[0]);
14+
return !isArrayOrTypedArray(trace.z[0]);
1515
};

src/traces/heatmap/make_bound_array.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
'use strict';
1010

11-
var Lib = require('../../lib');
1211
var Registry = require('../../registry');
12+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1313

1414
module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, ax) {
1515
var arrayOut = [],
@@ -20,7 +20,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
2020
dv,
2121
i;
2222

23-
var isArrayOfTwoItemsOrMore = Lib.isArrayOrTypedArray(arrayIn) && arrayIn.length > 1;
23+
var isArrayOfTwoItemsOrMore = isArrayOrTypedArray(arrayIn) && arrayIn.length > 1;
2424

2525
if(isArrayOfTwoItemsOrMore && !isHist && (ax.type !== 'category')) {
2626
var len = arrayIn.length;
@@ -68,7 +68,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
6868
var calendar = trace[ax._id.charAt(0) + 'calendar'];
6969

7070
if(isHist || ax.type === 'category') v0 = ax.r2c(v0In, 0, calendar) || 0;
71-
else if(Lib.isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) v0 = arrayIn[0];
71+
else if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) v0 = arrayIn[0];
7272
else if(v0In === undefined) v0 = 0;
7373
else v0 = ax.d2c(v0In, 0, calendar);
7474

src/traces/heatmap/xyz_defaults.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
'use strict';
1111

1212
var isNumeric = require('fast-isnumeric');
13+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1314

14-
var Lib = require('../../lib');
1515
var Registry = require('../../registry');
1616
var hasColumns = require('./has_columns');
1717

@@ -76,7 +76,7 @@ function isValidZ(z) {
7676

7777
for(var i = 0; i < z.length; i++) {
7878
zi = z[i];
79-
if(!Lib.isArrayOrTypedArray(zi)) {
79+
if(!isArrayOrTypedArray(zi)) {
8080
allRowsAreArrays = false;
8181
break;
8282
}

src/traces/pie/calc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
'use strict';
1010

1111
var isNumeric = require('fast-isnumeric');
12+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1213
var tinycolor = require('tinycolor2');
1314

14-
var Lib = require('../../lib');
1515
var Color = require('../../components/color');
1616
var helpers = require('./helpers');
1717

1818
module.exports = function calc(gd, trace) {
1919
var vals = trace.values;
20-
var hasVals = Lib.isArrayOrTypedArray(vals) && vals.length;
20+
var hasVals = isArrayOrTypedArray(vals) && vals.length;
2121
var labels = trace.labels;
2222
var colors = trace.marker.colors || [];
2323
var cd = [];

src/traces/scatter/calc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
'use strict';
1010

1111
var isNumeric = require('fast-isnumeric');
12+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1213

13-
var Lib = require('../../lib');
1414
var Axes = require('../../plots/cartesian/axes');
1515
var BADNUM = require('../../constants/numerical').BADNUM;
1616

@@ -119,7 +119,7 @@ function calcMarkerSize(trace, serieslen) {
119119
};
120120
}
121121

122-
if(Lib.isArrayOrTypedArray(marker.size)) {
122+
if(isArrayOrTypedArray(marker.size)) {
123123
// I tried auto-type but category and dates dont make much sense.
124124
var ax = {type: 'linear'};
125125
Axes.setConvert(ax);

src/traces/scatter/fillcolor_defaults.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
var Color = require('../../components/color');
13-
var Lib = require('../../lib');
13+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1414

1515
module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coerce) {
1616
var inheritColorFromMarker = false;
@@ -20,10 +20,10 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe
2020
var markerColor = traceOut.marker.color,
2121
markerLineColor = (traceOut.marker.line || {}).color;
2222

23-
if(markerColor && !Lib.isArrayOrTypedArray(markerColor)) {
23+
if(markerColor && !isArrayOrTypedArray(markerColor)) {
2424
inheritColorFromMarker = markerColor;
2525
}
26-
else if(markerLineColor && !Lib.isArrayOrTypedArray(markerLineColor)) {
26+
else if(markerLineColor && !isArrayOrTypedArray(markerLineColor)) {
2727
inheritColorFromMarker = markerLineColor;
2828
}
2929
}

src/traces/scatter/line_defaults.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
'use strict';
1010

11-
var Lib = require('../../lib');
11+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1212
var hasColorscale = require('../../components/colorscale/has_colorscale');
1313
var colorscaleDefaults = require('../../components/colorscale/defaults');
1414

@@ -21,7 +21,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout,
2121
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'});
2222
}
2323
else {
24-
var lineColorDflt = (Lib.isArrayOrTypedArray(markerColor) ? false : markerColor) || defaultColor;
24+
var lineColorDflt = (isArrayOrTypedArray(markerColor) ? false : markerColor) || defaultColor;
2525
coerce('line.color', lineColorDflt);
2626
}
2727

src/traces/surface/convert.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var fill = require('ndarray-fill');
1616
var ops = require('ndarray-ops');
1717
var tinycolor = require('tinycolor2');
1818

19-
var Lib = require('../../lib');
19+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
2020
var str2RgbaArray = require('../../lib/str2rgbarray');
2121

2222
var MIN_RESOLUTION = 128;
@@ -46,17 +46,17 @@ proto.handlePick = function(selection) {
4646
];
4747
var traceCoordinate = [0, 0, 0];
4848

49-
if(!Lib.isArrayOrTypedArray(this.data.x)) {
49+
if(!isArrayOrTypedArray(this.data.x)) {
5050
traceCoordinate[0] = selectIndex[0];
51-
} else if(Lib.isArrayOrTypedArray(this.data.x[0])) {
51+
} else if(isArrayOrTypedArray(this.data.x[0])) {
5252
traceCoordinate[0] = this.data.x[selectIndex[1]][selectIndex[0]];
5353
} else {
5454
traceCoordinate[0] = this.data.x[selectIndex[0]];
5555
}
5656

57-
if(!Lib.isArrayOrTypedArray(this.data.y)) {
57+
if(!isArrayOrTypedArray(this.data.y)) {
5858
traceCoordinate[1] = selectIndex[1];
59-
} else if(Lib.isArrayOrTypedArray(this.data.y[0])) {
59+
} else if(isArrayOrTypedArray(this.data.y[0])) {
6060
traceCoordinate[1] = this.data.y[selectIndex[1]][selectIndex[0]];
6161
} else {
6262
traceCoordinate[1] = this.data.y[selectIndex[1]];
@@ -232,11 +232,11 @@ proto.update = function(data) {
232232
});
233233

234234
// coords x
235-
if(!Lib.isArrayOrTypedArray(x)) {
235+
if(!isArrayOrTypedArray(x)) {
236236
fill(xc, function(row) {
237237
return xaxis.d2l(row, 0, xcalendar) * scaleFactor[0];
238238
});
239-
} else if(Lib.isArrayOrTypedArray(x[0])) {
239+
} else if(isArrayOrTypedArray(x[0])) {
240240
fill(xc, function(row, col) {
241241
return xaxis.d2l(x[col][row], 0, xcalendar) * scaleFactor[0];
242242
});
@@ -248,11 +248,11 @@ proto.update = function(data) {
248248
}
249249

250250
// coords y
251-
if(!Lib.isArrayOrTypedArray(x)) {
251+
if(!isArrayOrTypedArray(x)) {
252252
fill(yc, function(row, col) {
253253
return yaxis.d2l(col, 0, xcalendar) * scaleFactor[1];
254254
});
255-
} else if(Lib.isArrayOrTypedArray(y[0])) {
255+
} else if(isArrayOrTypedArray(y[0])) {
256256
fill(yc, function(row, col) {
257257
return yaxis.d2l(y[col][row], 0, ycalendar) * scaleFactor[1];
258258
});

0 commit comments

Comments
 (0)