Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let pixelsToAdd = diffStartAndZeroed / diffFactor;
// console.log(pixelsToAdd)
// console.log(hoverTime, hoverTime.format(), pixelsToAdd);
// console.log(Math.floor(leftOffset / gridWidth));
//! offset grids needed since each zoom in won't be centered
//! maybe non equal past/future dates - this.getDateArray(80, 40, timeScale, hoverTime);
//! additional offset needed for midPoint and/or position
let offSetGrids = Math.floor(leftOffset / gridWidth);
// console.log(Math.floor(gridNumber/2), offSetGrids, gridNumber/2)
//# MOST EXPENSIVE FUNCTION!!!! Greater the gridNumber === longer. 960 els ~23ms vs 100 at 3.5ms)
let current = this.getDateArray(Math.floor(gridNumber/2), Math.floor(gridNumber/2), timeScale, hoverTime);
// console.log(current)
let deque = new Deque(current.dates);
//# NEED FUNCTION TO CHECK IF DRAGGER IS WITHIN RANGE
//# get front and back dates
let frontDate = moment.utc(deque.peekFront().rawDate);
let backDate = moment.utc(deque.peekBack().rawDate);
// console.log(frontDate.format())
// check if dragger date is between front/back dates, null set to ignore granularity (go to ms), [] for inclusive of front/back dates
let isBetween = draggerDateActual.isBetween(frontDate, backDate, null, '[]');
// let pixelsToAddToDragger = 0;
let draggerPosition = 0;
let draggerVisible = false;
if (isBetween) {
// let frontDateValue = moment.utc(frontDate.rawDate).valueOf(); // ZERO
// let draggerPositionFromFront = draggerDateActualValue - frontDateValue;
// pixelsToAddToDragger = Math.abs(frontDate.diff(draggerDateActual, timeScale, true) * gridWidth);
//# handle date array creation
let current = this.getDateArray(Math.floor(gridNumber/2), Math.floor(gridNumber/2), timeScale, time);
let frontDate = moment.utc(current.dates[0].rawDate);
let draggerPosition = Math.abs(frontDate.diff(draggerTime, timeScale, true) * gridWidth);
let draggerPositionB = Math.abs(frontDate.diff(moment.utc(draggerTimeStateBDraggerBTest), timeScale, true) * gridWidth);
// this.addLine(initDateStart);
// console.log(numberOfVisibleTiles, dragSentinelChangeNumber)
// console.log(draggerPosition, pixelsToAdd, midPoint)
// console.log(this.getDraggerPosition(draggerTimeStateBDraggerBTest, current.dates[0].rawDate, 'day', gridWidth))
this.setState({
compareMode: false,
timeScaleSelectValue: timeScale,
deque: new Deque(current.dates),
// draggerPosition: draggerPosition + pixelsToAdd,
draggerPosition: draggerPosition + midPoint - 49,
draggerVisible: draggerVisible,
draggerPositionB: draggerPositionB + midPoint - 49,
draggerVisibleB: draggerVisibleB,
redLineOffset: draggerPosition + pixelsToAdd + 49,
numberOfVisibleTiles: numberOfVisibleTiles,
dragSentinelChangeNumber: dragSentinelChangeNumber,
axisWidth: axisWidth,
timeScale: timeScale,
selectedDate: time,
// midTileDate: selectedDate.format(),
currentDateRange: current.dates,
gridWidth: gridWidth,
draggerTimeState: time,
draggerTimeStateB: draggerTimeStateBDraggerBTest,
export function serializeNodes(rootNodes: MagicalNode[]) {
// because of circular references, we don't want to visit a node more than once
let visitedNodes = new Set();
let queue = new Deque(rootNodes);
while (queue.length) {
let currentNode = queue.shift()!;
visitedNodes.add(currentNode);
// console.log(currentNode);
// we don't want to open any nodes deeper than 5 nodes by default
let childPositionedNodes = getChildPositionedMagicalNodes({
node: currentNode,
path: []
}).filter(({ node }) => !visitedNodes.has(node));
queue.push(...childPositionedNodes.map(x => x.node));
}
let newNodes: HashedMagicalNode[] = [];
dbStore.set(name, sublevel(levelup(leveldown(name), opts, function (err) {
/* istanbul ignore if */
if (err) {
dbStore.delete(name);
return callback(err);
}
db = dbStore.get(name);
db._docCount = -1;
db._queue = new Deque();
/* istanbul ignore else */
if (typeof opts.migrate === 'object') { // migration for leveldown
opts.migrate.doMigrationOne(name, db, afterDBCreated);
} else {
afterDBCreated();
}
})));
}
dbStore.set(name, sublevel(levelup(name, opts, function (err) {
/* istanbul ignore if */
if (err) {
dbStore.delete(name);
return callback(err);
}
db = dbStore.get(name);
db._docCount = -1;
db._queue = new Deque();
/* istanbul ignore else */
if (opts.migrate) { // migration for leveldown
migrate.toSublevel(name, db, afterDBCreated);
} else {
afterDBCreated();
}
})));
}
dbStore.set(name, sublevel(levelup(name, opts, function (err) {
/* istanbul ignore if */
if (err) {
dbStore.delete(name)
return callback(err)
}
db = dbStore.get(name)
db._docCount = -1
db._queue = new Deque()
afterDBCreated()
})))
}
constructor(maxPendingPromises = Infinity, maxQueuedPromises = Infinity) {
this.pendingPromises = 0;
this.maxPendingPromises = maxPendingPromises;
this.maxQueuedPromises = maxQueuedPromises;
this.queue = new Deque();
this.length = 0;
}