facturacionelectronicapy-ts-xmlgen
Version:
Genera el contenido del archivo XML del Documento electrónico exigido por la SET
29 lines (28 loc) • 721 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Path = void 0;
class Path {
path;
constructor(key, path = []) {
this.path = path.concat(key);
}
concat(key) {
return new Path(key, this.path);
}
getValueFromPath(object) {
let currentValue = object;
for (const key of this.path) {
try {
currentValue = currentValue[key];
}
catch (error) {
// es posible que el valor simplemente no este presente, por eso no se lanza error
}
}
return currentValue;
}
toString() {
return this.path.join('.');
}
}
exports.Path = Path;