normalize-hex
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

normalize-hex

Normalize a hex string

License NPM version

Install

npm install normalize-hex

Getting started

const normalizeHex = require('normalize-hex')
 
console.log(normalizeHex('abc')) // 'abc'
console.log(normalizeHex('abc', { evenLength: true })) // '0abc'
console.log(normalizeHex('abc', { addPrefix: true })) // '0xabc'
console.log(normalizeHex('abc', { evenLength: true, addPrefix: true })) // '0x0abc'
console.log(normalizeHex('0xabc')) // 'abc'
console.log(normalizeHex('')) // '0'
console.log(normalizeHex('', { evenLength: true, addPrefix: true })) // '0x00'

Test

npm test

License

MIT

Package Sidebar

Install

npm i normalize-hex

Weekly Downloads

788

Version

0.0.6

License

MIT

Unpacked Size

5.33 kB

Total Files

7

Last publish

Collaborators

  • miguelmota