Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Typescript definition tests for d3/d3-timer module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Timer from 'd3-timer';
// Test now definition
const now: number = d3Timer.now();
// Test timer and timerFlush definitions ------------
let t0: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); });
let t1: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150);
let t2: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.restart((elapsed: number) => { console.log(elapsed); });
t0.restart((elapsed: number) => { console.log(elapsed); }, 150);
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();
d3Timer.timerFlush();
t1.stop(); t2.stop();
/**
* Typescript definition tests for d3/d3-timer module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Timer from 'd3-timer';
// Test now definition
let now: number = d3Timer.now();
// Test timer and timerFlush definitions ------------
let t0: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); });
let t1: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150);
let t2: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.restart((elapsed: number) => { console.log(elapsed); });
t0.restart((elapsed: number) => { console.log(elapsed); }, 150);
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();
d3Timer.timerFlush();
t1.stop(); t2.stop();
}
return resonanceCustomTween
}
tweens.push(getResonanceCustomTween)
} else {
this.setState(() => {
return { [stateKey]: val }
})
// This assures any existing transitions are stopped
tweens.push(tween.call(this, null, stateKey, val))
}
}
const timingConfig = { ...preset, ...timing, time: timeNow() }
schedule(this, stateKey, newId(), timingConfig, tweens, events)
})
}
};
return resonanceCustomTween;
};
tweens.push(getResonanceCustomTween);
} else {
this.setState(() => {
return { [stateKey]: val };
});
// This assures any existing transitions are stopped
tweens.push(tween.call(this, null, stateKey, val));
}
}
const timingConfig = { ...preset, ...timing, time: timeNow() };
schedule(this, stateKey, newId(), timingConfig, tweens, events);
});
}
function inherit(node, id) {
var timing;
while (!(timing = node.__transition) || !(timing = timing[id])) {
if (!(node = node.parentNode)) {
return defaultTiming.time = now(), defaultTiming;
}
}
return timing;
}
function inherit(node, id) {
var timing;
while (!(timing = node.__transition) || !(timing = timing[id])) {
if (!(node = node.parentNode)) {
return defaultTiming.time = now(), defaultTiming;
}
}
return timing;
}
subscribe(callback, duration) {
duration = this.shouldAnimate ? duration : 0;
return this.subscribers.push({
startTime: now(),
callback,
duration
});
}
this.subscribers.forEach((s) => {
s.callback(now() - s.startTime, s.duration);
});
}
Object.keys(transitions[ref]).forEach((attr) => {
const value = transitions[ref][attr];
if (Array.isArray(value)) {
if (value.length === 1) {
tweens.push(tween.call(this[ref], attr, value[0]));
} else {
this[ref].setAttribute(attr, value[0]);
tweens.push(tween.call(this[ref], attr, value[1]));
}
} else {
this[ref].setAttribute(attr, value);
}
});
const timingConfig = { ...preset, ...timing, time: now() };
schedule(this, ref, newId(), timingConfig, tweens, events);
});
}