dilswer
Version:
Blazingly fast data validation library with TypeScript integration.
35 lines (33 loc) • 905 B
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
// src/validation-algorithms/path.ts
var Path = class _Path {
constructor() {
__publicField(this, "previous");
__publicField(this, "part");
}
static init(root) {
const path = new _Path();
path.part = root;
return path;
}
concat(nextPart) {
const next = new _Path();
next.previous = this;
next.part = nextPart;
return next;
}
flatten() {
const parts = [];
let current = this;
while (current) {
parts.push(current.part.toString());
current = current.previous;
}
return parts.reverse();
}
};
export {
Path
};