basant307/AI_Governance_Project
048
1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3/**4 * GraphemerIterator5 *6 * Takes a string and a "BreakHandler" method during initialisation7 * and creates an iterable object that returns individual graphemes.8 *9 * @param str {string}10 * @return GraphemerIterator11 */12class GraphemerIterator {13 constructor(str, nextBreak) {14 this._index = 0;15 this._str = str;16 this._nextBreak = nextBreak;17 }18 [Symbol.iterator]() {19 return this;20 }21 next() {22 let brk;23 if ((brk = this._nextBreak(this._str, this._index)) < this._str.length) {24 const value = this._str.slice(this._index, brk);25 this._index = brk;26 return { value: value, done: false };27 }28 if (this._index < this._str.length) {29 const value = this._str.slice(this._index);30 this._index = this._str.length;31 return { value: value, done: false };32 }33 return { value: undefined, done: true };34 }35}36exports.default = GraphemerIterator;37 