Socket
Socket
Sign inDemoInstall

@smithy/util-hex-encoding

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/util-hex-encoding - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

89

dist-cjs/index.js

@@ -1,38 +0,65 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toHex = exports.fromHex = void 0;
const SHORT_TO_HEX = {};
const HEX_TO_SHORT = {};
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
fromHex: () => fromHex,
toHex: () => toHex
});
module.exports = __toCommonJS(src_exports);
var SHORT_TO_HEX = {};
var HEX_TO_SHORT = {};
for (let i = 0; i < 256; i++) {
let encodedByte = i.toString(16).toLowerCase();
if (encodedByte.length === 1) {
encodedByte = `0${encodedByte}`;
}
SHORT_TO_HEX[i] = encodedByte;
HEX_TO_SHORT[encodedByte] = i;
let encodedByte = i.toString(16).toLowerCase();
if (encodedByte.length === 1) {
encodedByte = `0${encodedByte}`;
}
SHORT_TO_HEX[i] = encodedByte;
HEX_TO_SHORT[encodedByte] = i;
}
function fromHex(encoded) {
if (encoded.length % 2 !== 0) {
throw new Error("Hex encoded strings must have an even number length");
if (encoded.length % 2 !== 0) {
throw new Error("Hex encoded strings must have an even number length");
}
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) {
out[i / 2] = HEX_TO_SHORT[encodedByte];
} else {
throw new Error(`Cannot decode unrecognized sequence ${encodedByte} as hexadecimal`);
}
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) {
out[i / 2] = HEX_TO_SHORT[encodedByte];
}
else {
throw new Error(`Cannot decode unrecognized sequence ${encodedByte} as hexadecimal`);
}
}
return out;
}
return out;
}
exports.fromHex = fromHex;
__name(fromHex, "fromHex");
function toHex(bytes) {
let out = "";
for (let i = 0; i < bytes.byteLength; i++) {
out += SHORT_TO_HEX[bytes[i]];
}
return out;
let out = "";
for (let i = 0; i < bytes.byteLength; i++) {
out += SHORT_TO_HEX[bytes[i]];
}
return out;
}
exports.toHex = toHex;
__name(toHex, "toHex");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
fromHex,
toHex
});
{
"name": "@smithy/util-hex-encoding",
"version": "2.0.0",
"version": "2.1.0",
"description": "Converts binary buffers to and from lowercase hexadecimal encoding",
"scripts": {
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:es": "tsc -p tsconfig.es.json",
"build:types": "tsc -p tsconfig.types.json",
"build:cjs": "node ../../scripts/inline util-hex-encoding",
"build:es": "yarn g:tsc -p tsconfig.es.json",
"build:types": "yarn g:tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"stage-release": "rimraf ./.release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
"lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
"format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"",
"test": "jest"
"test": "yarn g:jest"
},

@@ -51,6 +51,4 @@ "author": {

"downlevel-dts": "0.10.1",
"jest": "28.1.1",
"rimraf": "3.0.2",
"typedoc": "0.23.23",
"typescript": "~4.9.5"
"typedoc": "0.23.23"
},

@@ -57,0 +55,0 @@ "typedoc": {

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