Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arturbomtempo-dev/convert2base-package
NPM package developed to perform the main base conversions involving binary, octal, decimal and hexadecimal numbers.
https://github.com/arturbomtempo-dev/convert2base-package
base-conversion binary convert2base decimal hexadecimal nodejs npm npm-package octal typescript
Last synced: 5 days ago
JSON representation
NPM package developed to perform the main base conversions involving binary, octal, decimal and hexadecimal numbers.
- Host: GitHub
- URL: https://github.com/arturbomtempo-dev/convert2base-package
- Owner: arturbomtempo-dev
- License: mit
- Created: 2024-04-19T13:29:50.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-01-06T06:30:30.000Z (about 1 month ago)
- Last Synced: 2025-01-27T14:53:39.084Z (17 days ago)
- Topics: base-conversion, binary, convert2base, decimal, hexadecimal, nodejs, npm, npm-package, octal, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/convert2base
- Size: 122 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Citation: CITATION.cff
Awesome Lists containing this project
README
## Introduction
Convert2Base is a versatile npm package designed for Node.js projects, facilitating essential base conversions such as binary, octal, decimal, and hexadecimal. It aims to streamline these calculations, offering a straightforward approach to integrating base conversion functionalities into Node.js applications.
## Installation
You can install the Base Conversion Kit using `npm`:
```bash
npm install convert2base
```## Importing
To import the Convert2Base package into your project, you can use one of the two main ways of importing a library with JavaScript: through Node.js require or with ES6 imports.
```javascript
// Using ES6 imports
import {
binToOct,
binToDec,
binToHex,
octToBin,
octToDec,
octToHex,
decToBin,
decToOct,
decToHex,
hexToBin,
hexToOct,
hexToDec,
} from 'convert2base';// Using Node.js `require()`
const convertToBase = require('convert2base');
```## Usage
The Convert2Base package has 12 functions for converting between the main existing base numbers:
- binToOct("number")
- binToDec("number")
- binToHex("number")
- octToBin("number")
- octToDec("number")
- octToHex("number")
- decToBin("number")
- decToOct("number")
- decToHex("number")
- hexToBin("number")
- hexToOct("number")
- hexToDec("number")
Example using ES6 imports
```javascript
import {
binToOct,
binToDec,
binToHex,
octToBin,
octToDec,
octToHex,
decToBin,
decToOct,
decToHex,
hexToBin,
hexToOct,
hexToDec,
} from 'convert2base';console.log('Testing binToOct:');
console.log(binToOct('101010')); // Output: '52'console.log('Testing binToDec:');
console.log(binToDec('101010')); // Output: '42'console.log('Testing binToHex:');
console.log(binToHex('101010')); // Output: '2A'console.log('Testing octToBin:');
console.log(octToBin('52')); // Output: '101010'console.log('Testing octToDec:');
console.log(octToDec('52')); // Output: '42'console.log('Testing octToHex:');
console.log(octToHex('52')); // Output: '2A'console.log('Testing decToBin:');
console.log(decToBin('42')); // Output: '101010'console.log('Testing decToOct:');
console.log(decToOct('42')); // Output: '52'console.log('Testing decToHex:');
console.log(decToHex('42')); // Output: '2A'console.log('Testing hexToBin:');
console.log(hexToBin('2A')); // Output: '00101010'console.log('Testing hexToOct:');
console.log(hexToOct('2A')); // Output: '52'console.log('Testing hexToDec:');
console.log(hexToDec('2A')); // Output: '42'
```
Example using Node.js `require()`:
```javascript
const convertToBase = require('convert2base');console.log('Testing binToOct:');
console.log(convertToBase.binToOct('101010')); // Output: '52'console.log('Testing binToDec:');
console.log(convertToBase.binToDec('101010')); // Output: '42'console.log('Testing binToHex:');
console.log(convertToBase.binToHex('101010')); // Output: '2A'console.log('Testing octToBin:');
console.log(convertToBase.octToBin('52')); // Output: '101010'console.log('Testing octToDec:');
console.log(convertToBase.octToDec('52')); // Output: '42'console.log('Testing octToHex:');
console.log(convertToBase.octToHex('52')); // Output: '2A'console.log('Testing decToBin:');
console.log(convertToBase.decToBin('42')); // Output: '101010'console.log('Testing decToOct:');
console.log(convertToBase.decToOct('42')); // Output: '52'console.log('Testing decToHex:');
console.log(convertToBase.decToHex('42')); // Output: '2A'console.log('Testing hexToBin:');
console.log(convertToBase.hexToBin('2A')); // Output: '00101010'console.log('Testing hexToOct:');
console.log(convertToBase.hexToOct('2A')); // Output: '52'console.log('Testing hexToDec:');
console.log(convertToBase.hexToDec('2A')); // Output: '42'
```You can view and run the example code for using the package at [src/test.ts](https://github.com/ArturColen/Convert2Base-Package/blob/main/src/test.ts) or via [Repl.it](https://replit.com/@ArturColen/Convert2BaseTest).
## Contact
If you want to get in touch regarding matters related to this project, you have two main channels: Artur Bomtempo’s [LinkedIn](https://www.linkedin.com/in/artur-bomtempo/) or [e-mail](mailto:[email protected]).
## Contributors
The complete Convert2Base project was developed by Artur Bomtempo and Letícia França. Artur contributed to the NPM package and API, while Letícia created the entire graphical interface of the project, which is hosted on the web.
| [
Artur Bomtempo](https://arturbomtempo.dev) | [
Letícia França](https://www.leticiafranca.com.br) |
| :-------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------: |## License
Copyright (c) 2025 Artur Bomtempo Colen e Letícia Silva França
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.