我有一个ArrayBuffer对象,我需要能够转换为String对JSON,但我不能得到的价值[Int8Array]出来的对象,即使它是明显存在的。
我已经尝试了所有变体,但它们都返回 undefined
console.log(result);//Returns the array buffer
//Following methods all return undefined?
console.log(result["[[Int8Array]]"]);
console.log(result[[[Int8Array]]]);
console.log(result[[["Int8Array"]]]);
console.log(result[Int8Array]);
console.log(result["Int8Array"]);
Run Code Online (Sandbox Code Playgroud)
如何获取对象中明确可用的所有 Int8Array 或 UInt8Array 值?
因此,在我的程序中,我可以接收各种长度的字符串并将它们发送出去以进行翻译。如果这些字符串具有一定的字符长度,我会收到错误,因此我想在此之前检查并拆分这些字符串(如果有必要)。但我不能只在单词中间分割字符串,单词本身也需要完整并考虑在内。
例如:
let str = "this is an input example of one sentence that contains a bit of words and must be split"
let splitStringArr = [];
// If string is larger than X (for testing make it 20) characters
if(str.length > 20) {
// Split string sentence into smaller strings, keep words intact
//...
// example of result would be
// splitStringArr = ['this is an input', 'example of one sentence' 'that contains...', '...']
// instead of ['this is …Run Code Online (Sandbox Code Playgroud)