@sudoo/marked
Version:
JavaScript & TypeScript code runner in JavaScript, safe with marked territory, asynchronous
44 lines (43 loc) • 1.18 kB
JavaScript
;
/**
* @author WMXPY
* @namespace Marked
* @description Script Location
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScriptLocation = void 0;
const Root_Protocol = "__$marked-root-protocol";
const Root_Location = "__$marked-root-location";
class ScriptLocation {
static create(protocol, location) {
return new ScriptLocation(protocol, location);
}
static createRoot() {
return ScriptLocation.create(Root_Protocol, Root_Location);
}
constructor(protocol, location) {
this._protocol = protocol;
this._location = location;
}
get protocol() {
return this._protocol;
}
get location() {
return this._location;
}
isRoot() {
return this._protocol === Root_Protocol
&& this._location === Root_Location;
}
compare(targetLocation) {
return this._protocol === targetLocation.protocol
&& this._location === targetLocation.location;
}
hash() {
return `${this._protocol}://${this._location}`;
}
toString() {
return this.hash();
}
}
exports.ScriptLocation = ScriptLocation;