RPS/node_modules/notepack.io/lib/encode.js
// Faster for short strings than Buffer.byteLength
Faster for short strings than Buffer.byteLength
Faster for short strings than Buffer . byteLength
function utf8Length(str) {
  var c = 0, length = 0;
  for (var i = 0, l = str.length; i < l; i++) {
    c = str.charCodeAt(i);
    if (c < 0x80) {
      length += 1;
    }
    else if (c < 0x800) {
      length += 2;
    }
    else if (c < 0xd800 || c >= 0xe000) {
      length += 3;
    }
    else {
      i++;
      length += 4;
    }
  }
  return length;
}
function utf8Length ( str ) { var c = 0 , length = 0 ; for ( var i = 0 , l = str . length ; i < l ; i ++ ) { c = str . charCodeAt ( i ) ; if ( c < 0x80 ) { length += 1 ; } else if ( c < 0x800 ) { length += 2 ; } else if ( c < 0xd800 || c >= 0xe000 ) { length += 3 ; } else { i ++ ; length += 4 ; } } return length ; }
Faster for short strings than Buffer.byteLength
Faster for short strings than Buffer . byteLength