1
0
mirror of https://github.com/Picovoice/porcupine.git synced 2022-01-28 03:27:53 +03:00

updated web packages

This commit is contained in:
Iliad
2021-12-14 13:44:32 -08:00
parent 50f767e5ae
commit bd86321b07
2 changed files with 8 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "$",
"version": "2.0.1",
"version": "2.0.2",
"description": "Porcupine library for web browsers (via WebAssembly)",
"author": "Picovoice Inc",
"license": "Apache-2.0",

View File

@@ -13,20 +13,20 @@
* Convert a null terminated phrase stored inside an array buffer to a string
*
* @param arrayBuffer input array buffer
* @param index the index at which the phrase is stored
* @param indexStart the index at which the phrase is stored
* @return retrieved string
*/
export function arrayBufferToStringAtIndex(
arrayBuffer: Uint8Array,
index: number,
indexStart: number,
): string {
let stringBuffer = '';
let indexBuffer = index;
while (arrayBuffer[indexBuffer] !== 0) {
stringBuffer += String.fromCharCode(arrayBuffer[indexBuffer++]);
let indexEnd = indexStart;
while (arrayBuffer[indexEnd] !== 0) {
indexEnd++;
}
return stringBuffer;
const utf8decoder = new TextDecoder('utf-8');
return utf8decoder.decode(arrayBuffer.subarray(indexStart, indexEnd));
}
/**