Socket
Socket
Sign inDemoInstall

@ethersproject/strings

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/strings - npm Package Compare versions

Comparing version 5.0.0-beta.125 to 5.0.0-beta.126

2

_version.d.ts

@@ -1,1 +0,1 @@

export declare const version = "5.0.0-beta.125";
export declare const version = "5.0.0-beta.126";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "5.0.0-beta.125";
exports.version = "5.0.0-beta.126";

@@ -10,4 +10,5 @@ import { BytesLike } from "@ethersproject/bytes";

export declare function toUtf8Bytes(str: string, form?: UnicodeNormalizationForm): Uint8Array;
export declare function _toEscapedUtf8String(bytes: BytesLike, ignoreErrors?: boolean): string;
export declare function toUtf8String(bytes: BytesLike, ignoreErrors?: boolean): string;
export declare function formatBytes32String(text: string): string;
export declare function parseBytes32String(bytes: BytesLike): string;

@@ -57,3 +57,3 @@ "use strict";

// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499
function toUtf8String(bytes, ignoreErrors) {
function processUtf8String(bytes, processFunc, ignoreErrors) {
bytes = bytes_1.arrayify(bytes);

@@ -67,3 +67,3 @@ var result = "";

if (c >> 7 === 0) {
result += String.fromCharCode(c);
result += processFunc(c);
continue;

@@ -152,10 +152,44 @@ }

if (res <= 0xffff) {
result += String.fromCharCode(res);
result += processFunc(res);
continue;
}
res -= 0x10000;
result += String.fromCharCode(((res >> 10) & 0x3ff) + 0xd800, (res & 0x3ff) + 0xdc00);
result += processFunc(((res >> 10) & 0x3ff) + 0xd800, (res & 0x3ff) + 0xdc00);
}
return result;
}
function escapeChar(value) {
var hex = ("0000" + value.toString(16));
return "\\u" + hex.substring(hex.length - 4);
}
function _toEscapedUtf8String(bytes, ignoreErrors) {
return '"' + processUtf8String(bytes, function (left, right) {
if (right == null) {
if (left < 256) {
switch (left) {
case 8: return "\\b";
case 9: return "\\t";
case 10: return "\\n";
case 13: return "\\r";
case 34: return "\\\"";
case 92: return "\\\\";
}
if (left >= 32 && left < 127) {
return String.fromCharCode(left);
}
}
return escapeChar(left);
}
return escapeChar(left) + escapeChar(right);
}, ignoreErrors) + '"';
}
exports._toEscapedUtf8String = _toEscapedUtf8String;
function toUtf8String(bytes, ignoreErrors) {
return processUtf8String(bytes, function (left, right) {
if (right == null) {
return String.fromCharCode(left);
}
return String.fromCharCode(left, right);
}, ignoreErrors);
}
exports.toUtf8String = toUtf8String;

@@ -162,0 +196,0 @@ function formatBytes32String(text) {

{
"name": "@ethersproject/strings",
"version": "5.0.0-beta.125",
"version": "5.0.0-beta.126",
"description": "String utility functions.",

@@ -25,3 +25,3 @@ "main": "index.js",

},
"tarballHash": "0x9e647e336090067257da0bb65710eb42992ce8bd99fc0a8af4b29c360afdf73b"
"tarballHash": "0x4a8d8de5aa1d3e72db5a2bb3554c7efa1681257b0b3d2c0764d3edf8c221879b"
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc