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.
70 lines (67 loc) • 1.5 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// src/utils.ts
import isNumber from "is-number";
import { Segmenter } from "intl-segmenter";
var { defineProperty } = Reflect;
var define = /* @__PURE__ */ __name((node, key, value) => {
defineProperty(node, key, {
configurable: true,
enumerable: false,
writable: true,
value
});
}, "define");
// src/nodes/Node.ts
var Node = class {
static {
__name(this, "Node");
}
type;
value;
output;
symbol;
parent;
constructor(node) {
this.type = node.type;
this.value = node.value || "";
if (node.output != null && node.output !== "") {
this.output = node.output;
}
if (node.symbol) {
this.symbol = node.symbol;
}
define(this, "alt", node.alt);
define(this, "match", node.match);
define(this, "loc", node.loc);
}
get siblings() {
return this.parent?.nodes || [];
}
};
// src/nodes/Block.ts
var Block = class extends Node {
static {
__name(this, "Block");
}
nodes;
constructor(node) {
super(node);
this.nodes = node.nodes || [];
}
append(input) {
this.parent && this.parent.append(input);
this.output = this.output || "";
this.output += input;
}
push(node) {
define(node, "parent", this);
this.nodes.push(node);
}
};
var Block_default = Block;
export {
Block,
Block_default as default
};
//# sourceMappingURL=Block.mjs.map