Update to NPM version
This commit is contained in:
38
ProjectSourceCode/node_modules/pg-minify/lib/utils.js
generated
vendored
Normal file
38
ProjectSourceCode/node_modules/pg-minify/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
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
|
||||
};
|
||||
Reference in New Issue
Block a user