UNPKG

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.

156 lines (151 loc) 4.07 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/nodes/index.ts var nodes_exports = {}; __export(nodes_exports, { Block: () => Block, Location: () => Location, Node: () => Node, Position: () => Position, location: () => location }); module.exports = __toCommonJS(nodes_exports); // src/utils.ts var import_is_number = __toESM(require("is-number")); var import_intl_segmenter = require("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); } }; // src/nodes/Location.ts 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; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Block, Location, Node, Position, location }); //# sourceMappingURL=index.js.map