UNPKG

lakutata

Version:

An IoC-based universal application framework.

44 lines (40 loc) 1.07 kB
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */ "use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); class ObjectPath { static getPathKeys(t) { return t.replace(/\[(\w+)\]/g, ".$1").split("."); } static get(t, e) { const s = this.getPathKeys(e); let n = t; for (const t of s) { if (n == null) return undefined; n = n[t]; } return n; } static set(t, e, s) { if (s === undefined) return; const n = this.getPathKeys(e); let r = t; for (let t = 0; t < n.length - 1; t++) { const e = n[t]; if (typeof r[e] !== "object") r[e] = {}; r = r[e]; } r[n[n.length - 1]] = s; } static has(t, e) { const s = this.getPathKeys(e); let n = t; for (const t of s) { if (n == null || !(t in n)) return false; n = n[t]; } return true; } } exports.ObjectPath = ObjectPath;