UNPKG

devexpress-richedit

Version:

DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.

37 lines (36 loc) 905 B
import { isDefined } from "@devexpress/utils/lib/utils/common"; export class UnicodeString { value; _chars; constructor(value) { this.value = value; } get chars() { if (!this._chars) this._chars = isDefined(this.value) ? Array.from(this.value) : []; return this._chars; } get size() { return this.chars.length; } get isEmpty() { return this.chars.length === 0; } charAt(index) { return this.chars.at(index); } substring(start, end) { return new UnicodeString(this.chars.slice(start, end).join('')); } [Symbol.toPrimitive](hint) { if (hint === "string" || hint === "default") return this.value; return NaN; } toString() { return this.value; } valueOf() { return this.value; } }