@aws-sdk/util-hex-encoding
Advanced tools
Comparing version 3.170.0 to 3.183.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03) | ||
**Note:** Version bump only for package @aws-sdk/util-hex-encoding | ||
# [3.170.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.169.0...v3.170.0) (2022-09-13) | ||
@@ -8,0 +16,0 @@ |
@@ -1,7 +0,7 @@ | ||
var SHORT_TO_HEX = {}; | ||
var HEX_TO_SHORT = {}; | ||
for (var i = 0; i < 256; i++) { | ||
var encodedByte = i.toString(16).toLowerCase(); | ||
const SHORT_TO_HEX = {}; | ||
const HEX_TO_SHORT = {}; | ||
for (let i = 0; i < 256; i++) { | ||
let encodedByte = i.toString(16).toLowerCase(); | ||
if (encodedByte.length === 1) { | ||
encodedByte = "0".concat(encodedByte); | ||
encodedByte = `0${encodedByte}`; | ||
} | ||
@@ -15,5 +15,5 @@ SHORT_TO_HEX[i] = encodedByte; | ||
} | ||
var out = new Uint8Array(encoded.length / 2); | ||
for (var i = 0; i < encoded.length; i += 2) { | ||
var encodedByte = encoded.slice(i, i + 2).toLowerCase(); | ||
const out = new Uint8Array(encoded.length / 2); | ||
for (let i = 0; i < encoded.length; i += 2) { | ||
const encodedByte = encoded.slice(i, i + 2).toLowerCase(); | ||
if (encodedByte in HEX_TO_SHORT) { | ||
@@ -23,3 +23,3 @@ out[i / 2] = HEX_TO_SHORT[encodedByte]; | ||
else { | ||
throw new Error("Cannot decode unrecognized sequence ".concat(encodedByte, " as hexadecimal")); | ||
throw new Error(`Cannot decode unrecognized sequence ${encodedByte} as hexadecimal`); | ||
} | ||
@@ -30,4 +30,4 @@ } | ||
export function toHex(bytes) { | ||
var out = ""; | ||
for (var i = 0; i < bytes.byteLength; i++) { | ||
let out = ""; | ||
for (let i = 0; i < bytes.byteLength; i++) { | ||
out += SHORT_TO_HEX[bytes[i]]; | ||
@@ -34,0 +34,0 @@ } |
export declare function fromHex(encoded: string): Uint8Array; | ||
export declare function toHex(bytes: Uint8Array): string; |
{ | ||
"name": "@aws-sdk/util-hex-encoding", | ||
"version": "3.170.0", | ||
"version": "3.183.0", | ||
"description": "Converts binary buffers to and from lowercase hexadecimal encoding", | ||
@@ -5,0 +5,0 @@ "scripts": { |
33151