@fedify/fedify
Version:
An ActivityPub server framework
33 lines (29 loc) • 1.1 kB
JavaScript
import { Temporal } from "@js-temporal/polyfill";
import { URLPattern } from "urlpattern-polyfill";
globalThis.addEventListener = () => {};
import { parseLanguageTag } from "@phensley/language-tag";
//#region runtime/langstr.ts
/**
* A language-tagged string which corresponds to the `rdf:langString` type.
*/
var LanguageString = class extends String {
language;
/**
* Constructs a new `LanguageString`.
* @param value A string value written in the given language.
* @param language The language of the string. If a string is given, it will
* be parsed as a `LanguageTag`.
*/
constructor(value, language) {
super(value);
this.language = typeof language === "string" ? parseLanguageTag(language) : language;
}
[Symbol.for("Deno.customInspect")](inspect, options) {
return `<${this.language.compact()}> ${inspect(this.toString(), options)}`;
}
[Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
return `<${this.language.compact()}> ${inspect(this.toString(), options)}`;
}
};
//#endregion
export { LanguageString };