u-redux
v1.0.65
Published
A small OO number converter in Js. Convert (hex|dec|bin) to/from (hex|dec|bin).
Downloads
10
Readme
num-converter-js
A small OO number converter in Js. Convert (hex|dec|bin) to/from (hex|dec|bin).
Prerequisites
- NodeJs / NPM
Installation
cd /path/to/your/project
npm i num-converter-js
Testing
From your application code.
const numConv = require('num-converter-js')
const myHexNum = numConv.decToHex(10)
API
Class: NumberConverterJs
Under ongoing development, but all methods stable as of 0.1.0. (Binary coming soon.)
const htd = numberConverterJs.hexToDec, dth = numberConverterJs.decToHex
const hex1 = '0x123f', hex2 = '123f', hex3 = 123,
dec1 = '123', dec2 = '1.23', dec3 = 0.123, dec4 = .123
// Returns Decimal Values
console.log(`h2d1: ${htd(hex1)} h2d2: ${htd(hex2)} h2d3: ${htd(hex3)}`)
// Returns Hex Values
console.log(`d2h1: ${dth(dec1)} d2h2: ${dth(dec2)} d2h3: ${dth(dec3)} d2h4: ${dth(dec4)}`)
Use hexToDec
&& decToHex
methods to convert numbers. The variable above indicate all of the forms in which you can pass values to the respective functions.
Methods
numConverterJs.hexToDec([hexValue
])
hexValue
- (string|number) - 0x123f, 123f or 123
Returns a Decimal Value.
numConverterJs.decToHex([decValue
])
decValue
- (string|number) - 123, 1.23, 0.123 or .123
Returns a Hex Value.
Contributing
Not currently accepting outside contributors, but feel free to clone, modify and use as you wish.
Authors
License
This project is licensed under the DO_WHATEVER_YOU_WANT License - see the LICENSE file for details