_log(' == products ==> ', 'i', (new Error()), products);
export const _log = function(msg, style, error, data) {
let infoLine = error.stack.split('\n')[1];
// very ugly but I found it consistent
let startingIndex = infoLine.indexOf('(') + 1;
let endingIndex = infoLine.indexOf(')');
let fileNameAndLine = (infoLine.substring(startingIndex, endingIndex))
...
console.log(`%c ${msg} at ${fileNameAndLine}`, s, data);
}
How can I determine the current line number in JavaScript?