| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { type_manager } from "./functions.js";
- class parser {
- #locale;
- #content;
- constructor(content, locale) {
- if (!(content instanceof Object)) {
- throw "Content to create parser from must be an object.";
- }
- if (!type_manager.is_string(locale)) {
- throw "Location of potential missing object must be string.";
- }
- this.#content = content;
- this.#locale = locale;
- }
- exists(target) {
- if (!type_manager.is_string(target)) {
- throw "Name of the element to parse must be an string.";
- }
- return this.#content.hasOwnProperty(target);
- }
- get(target) {
- if (!this.exists(target)) {
- throw "Can not get " + target + " from " + this.#locale + ".";
- }
- return this.#content[target];
- }
- get properties() {
- return Object.getOwnPropertyNames(this.#content);
- }
- get_parser(target) {
- return new parser(this.get(target), this.#locale + "." + target);
- }
- }
- export { parser };
|