Socket
Book a DemoInstallSign in
Socket

addhex

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

addhex

A utility for adding hexadecimal values with both library and CLI interfaces

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

AddHex

npm version License: MIT

A lightweight utility for adding hexadecimal values with both library and CLI interfaces. Perfect for developers, engineers, and anyone working with hexadecimal calculations.

Features

  • ✨ Add any number of hex values together
  • 🔄 Convert and output result in lowercase hex
  • 📚 Use as a library in your project
  • 🖥️ Use as a command-line tool
  • 🚀 Handles large numbers with BigInt
  • 🧩 Supports both "0x" prefixed and raw hex formats
  • 📦 Available as ES Module

Installation

Global Installation (for CLI usage)

npm install -g addhex

Local Installation (for programmatic usage)

npm install addhex

Usage

As a Library

// ES Module import
import { addHex } from 'addhex'

// Add two hex values
console.log(addHex('a', 'b')) // '15'

// Add multiple hex values
console.log(addHex('10', '20', '30')) // '60'

// Supports 0x prefix
console.log(addHex('0xff', '0x1')) // '100'

// Mix and match prefix styles
console.log(addHex('ff', '0x1')) // '100'

// Works with large numbers
console.log(addHex('ffffffffffffffff', '1')) // '10000000000000000'

As a CLI Tool

# Basic usage
addhex a b
# Output: 15

# Add multiple values
addhex 10 20 30
# Output: 60

# Works with 0x prefix
addhex 0xff 0x1
# Output: 100

# View help
addhex --help

Demo

An interactive demo is available at https://sandy-mount.github.io/addhex/

API Reference

addHex(...hexValues)

Adds two or more hexadecimal values together.

  • Parameters: ...hexValues - One or more hexadecimal strings (with or without 0x prefix)
  • Returns: A lowercase hexadecimal string (without 0x prefix)
  • Throws: Error if any input is not a valid hexadecimal value

Development

# Clone the repository
git clone https://github.com/sandy-mount/addhex.git
cd addhex

# Install dependencies
npm install

# Run tests
npm test

# Run the CLI during development
npm start a b

License

MIT © Melvin Carvalho

Keywords

hex

FAQs

Package last updated on 10 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts