ta-react-xarrows
Version:
Draw arrows (or lines) between components in React!
54 lines • 1.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.measureFunc = exports.factorDpathStr = exports.typeOf = exports.getElementByPropGiven = void 0;
exports.getElementByPropGiven = function (ref) {
var myRef;
if (typeof ref === 'string') {
// myRef = document.getElementById(ref);
myRef = document.getElementById(ref);
}
else
myRef = ref.current;
return myRef;
};
exports.typeOf = function (arg) {
var type = typeof arg;
if (type === 'object') {
if (arg === null)
type = 'null';
else if (Array.isArray(arg))
type = 'array';
}
return type;
};
// receives string representing a d path and factoring only the numbers
exports.factorDpathStr = function (d, factor) {
var l = d.split(/(\d+(?:\.\d+)?)/);
l = l.map(function (s) {
if (Number(s))
return (Number(s) * factor).toString();
else
return s;
});
return l.join('');
};
// debug
exports.measureFunc = function (callbackFunc, name) {
if (name === void 0) { name = ''; }
var t = performance.now();
var returnVal = callbackFunc();
console.log('time ', name, ':', performance.now() - t);
return returnVal;
};
// export const measureFunc = (func: Function, name = '') => (...args) => {
// const t = performance.now();
//
// console.log(this, func.name, ...args);
// const returnVal = func(...args);
// console.log('time ', func.name || name, ':', performance.now() - t);
// return returnVal;
// };
//// example
// instead: myFunc(arg1,arg2)
// call: measureFunc(myFunc)(arg1,arg2)
//# sourceMappingURL=index.js.map