A suite to track Project Diva score statistics and ratings / D4DJ event data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
projectdivar/server/node_modules/pg-minify/lib/utils.js

38 lines
937 B

const {inspect} = require('util');
/////////////////////////////////////////////////////////////
// Returns {line, column} of an index within multi-line text.
function getIndexPos(text, index) {
let lineIdx = 0, colIdx = index, pos = 0;
do {
pos = text.indexOf('\n', pos);
if (pos === -1 || index < pos + 1) {
break;
}
lineIdx++;
pos++;
colIdx = index - pos;
} while (pos < index);
return {
line: lineIdx + 1,
column: colIdx + 1
};
}
///////////////////////////////////////////
// Returns a space gap for console output.
function messageGap(level) {
return ' '.repeat(level * 4);
}
////////////////////////////////////////////////////
// Type inspection
function addInspection(type, cb) {
type[inspect.custom] = cb;
}
module.exports = {
getIndexPos,
messageGap,
addInspection
};