Sha256: df03a29abdd419728d39b2b4de7e0e4b17767c1093e634337300db6a59c5aca3

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

var utf8ArrayToStr = (function () {
  var charCache = new Array(128);  // Preallocate the cache for the common single byte chars
  var charFromCodePt = String.fromCodePoint || String.fromCharCode;
  var result:any = [];

  return function (array:any) {
    var codePt, byte1;
    var buffLen = array.length;

    result.length = 0;

    for (var i = 0; i < buffLen;) {
      byte1 = array[i++];

      if (byte1 <= 0x7F) {
        codePt = byte1;
      } else if (byte1 <= 0xDF) {
        codePt = ((byte1 & 0x1F) << 6) | (array[i++] & 0x3F);
      } else if (byte1 <= 0xEF) {
        codePt = ((byte1 & 0x0F) << 12) | ((array[i++] & 0x3F) << 6) | (array[i++] & 0x3F);
      } else if (String.fromCodePoint) {
        codePt = ((byte1 & 0x07) << 18) | ((array[i++] & 0x3F) << 12) | ((array[i++] & 0x3F) << 6) | (array[i++] & 0x3F);
      } else {
        codePt = 63;    // Cannot convertLongFields four byte code points, so use "?" instead
        i += 3;
      }

      result.push(charCache[codePt] || (charCache[codePt] = charFromCodePt(codePt)));
    }

    return result.join('');
  };
})

export const Utf8ArrayToStr = utf8ArrayToStr();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waves_lib-0.1.0 js/node_modules/@waves/marshall/src/libs/Utf8ArrayToStr.ts