Skip to content

Commit 33b4085

Browse files
committed
mv repeat -> Lib.repeat
1 parent a0bfaf3 commit 33b4085

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/lib/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,21 @@ lib.isIndex = function(v, len) {
150150
lib.noop = require('./noop');
151151
lib.identity = require('./identity');
152152

153+
/**
154+
* create an array of length 'cnt' filled with 'v' at all indices
155+
*
156+
* @param {any} v
157+
* @param {number} cnt
158+
* @return {array}
159+
*/
160+
lib.repeat = function(v, cnt) {
161+
var out = new Array(cnt);
162+
for(var i = 0; i < cnt; i++) {
163+
out[i] = v;
164+
}
165+
return out;
166+
};
167+
153168
/**
154169
* swap x and y of the same attribute in container cont
155170
* specify attr with a ? in place of x/y

src/traces/scattergl/index.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function sceneUpdate(gd, subplot) {
238238

239239
// apply new option to all regl components (used on drag)
240240
scene.update = function update(opt) {
241-
var opts = repeat(opt, scene.count);
241+
var opts = Lib.repeat(opt, scene.count);
242242

243243
if(scene.fill2d) scene.fill2d.update(opts);
244244
if(scene.scatter2d) scene.scatter2d.update(opts);
@@ -366,14 +366,6 @@ function clearViewport(comp, vp) {
366366
gl.clear(gl.COLOR_BUFFER_BIT);
367367
}
368368

369-
function repeat(opt, cnt) {
370-
var opts = new Array(cnt);
371-
for(var i = 0; i < cnt; i++) {
372-
opts[i] = opt;
373-
}
374-
return opts;
375-
}
376-
377369
function plot(gd, subplot, cdata) {
378370
if(!cdata.length) return;
379371

@@ -619,7 +611,7 @@ function plot(gd, subplot, cdata) {
619611
(yaxis._rl || yaxis.range)[1]
620612
]
621613
};
622-
var vpRange = repeat(vpRange0, scene.count);
614+
var vpRange = Lib.repeat(vpRange0, scene.count);
623615

624616
// upload viewport/range data to GPU
625617
if(scene.fill2d) {

0 commit comments

Comments
 (0)