Socket
Socket
Sign inDemoInstall

@protobufjs/utf8

Package Overview
Dependencies
0
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

40

index.js

@@ -16,6 +16,5 @@ "use strict";

utf8.length = function length(string) {
var strlen = string.length >>> 0;
var len = 0,
c = 0;
for (var i = 0; i < strlen; ++i) {
for (var i = 0; i < string.length; ++i) {
c = string.charCodeAt(i);

@@ -44,22 +43,21 @@ if (c < 128)

var len = end - start;
if (len > 0) {
var string = [],
i = 0, // char offset
t; // temporary
while (start < end) {
t = buffer[start++];
if (t < 128)
string[i++] = t;
else if (t > 191 && t < 224)
string[i++] = (t & 31) << 6 | buffer[start++] & 63;
else if (t > 239 && t < 365) {
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
string[i++] = 0xD800 + (t >> 10);
string[i++] = 0xDC00 + (t & 1023);
} else
string[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
}
return String.fromCharCode.apply(String, string.slice(0, i));
if (len < 1)
return "";
var string = [],
i = 0, // char offset
t; // temporary
while (start < end) {
t = buffer[start++];
if (t < 128)
string[i++] = t;
else if (t > 191 && t < 224)
string[i++] = (t & 31) << 6 | buffer[start++] & 63;
else if (t > 239 && t < 365) {
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
string[i++] = 0xD800 + (t >> 10);
string[i++] = 0xDC00 + (t & 1023);
} else
string[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
}
return "";
return String.fromCharCode.apply(String, string.slice(0, i));
};

@@ -66,0 +64,0 @@

{
"name": "@protobufjs/utf8",
"description": "A minimal UTF8 implementation for number arrays.",
"version": "1.0.1",
"version": "1.0.2",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",

@@ -6,0 +6,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc