expand-value
Version:
Get deeply nested values from an object, like dot-prop and get-value, but with support for advanced features like bracket-notation and more.
80 lines (79 loc) • 2.18 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/nodes/Location.ts
var Location_exports = {};
__export(Location_exports, {
Location: () => Location,
Position: () => Position,
default: () => Location_default,
location: () => location
});
module.exports = __toCommonJS(Location_exports);
var Position = class {
static {
__name(this, "Position");
}
index;
line;
col;
constructor(loc) {
this.index = loc.index;
this.line = loc.line;
this.col = loc.col;
}
};
var Location = class {
static {
__name(this, "Location");
}
start;
end;
constructor(start, end) {
this.start = start;
this.end = end;
}
slice(input) {
return input.slice(...this.range);
}
get range() {
return [this.start.index, this.end.index];
}
get lines() {
return [this.start.line, this.end.line];
}
};
var location = /* @__PURE__ */ __name((loc) => {
const start = new Position(loc);
return (node) => {
node.loc = new Location(start, new Position(loc));
return node;
};
}, "location");
location.Position = Position;
location.Location = Location;
location.location = location;
var Location_default = Location;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Location,
Position,
location
});
//# sourceMappingURL=Location.js.map