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:
@@ -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",
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user