@shopify/prettier-plugin-liquid
Version:
Prettier Liquid/HTML plugin by Shopify
35 lines • 876 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertNever = assertNever;
exports.locStart = locStart;
exports.locEnd = locEnd;
exports.deepGet = deepGet;
exports.dropLast = dropLast;
function assertNever(x) {
throw new Error(`Unexpected object: ${x.type}`);
}
function locStart(node) {
if (typeof node === 'string')
return -1;
return node.position.start;
}
function locEnd(node) {
if (typeof node === 'string')
return -1;
return node.position.end;
}
function deepGet(path, obj) {
return path.reduce((curr, k) => {
if (curr && curr[k] !== undefined)
return curr[k];
return undefined;
}, obj);
}
function dropLast(n, xs) {
const result = [...xs];
for (let i = 0; i < n; i++) {
result.pop();
}
return result;
}
//# sourceMappingURL=utils.js.map