UNPKG

@difizen/libro-ai-native

Version:
31 lines (30 loc) 1.14 kB
export function stringToReadableStream(inputString) { // Convert the string into a Uint8Array var encoder = new TextEncoder(); var uint8Array = encoder.encode(inputString); // Create a new ReadableStream var readableStream = new ReadableStream({ start: function start(controller) { // Enqueue the Uint8Array into the stream controller.enqueue(uint8Array); // Close the stream controller.close(); } }); return readableStream; } export function addCellAIClassname(cell) { var _cell$className; if ((_cell$className = cell.className) !== null && _cell$className !== void 0 && _cell$className.includes('ai-cell-focus')) { return; } else { cell.className = cell.className + ' ai-cell-focus'; } } export function cancelCellAIClassname(cell) { var _cell$className2; if ((_cell$className2 = cell.className) !== null && _cell$className2 !== void 0 && _cell$className2.includes(' ai-cell-focus')) { var _cell$className3; cell.className = (_cell$className3 = cell.className) === null || _cell$className3 === void 0 ? void 0 : _cell$className3.replace(' ai-cell-focus', ''); } }