GithubHelp home page GithubHelp logo

arturcolen / gf-converter-package Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 59 KB

NPM package developed to perform the main base conversions involving binary, octal, decimal and hexadecimal numbers.

License: MIT License

TypeScript 100.00%
nodejs npm npm-package typescript base-conversion binary decimal hexadecimal octal

gf-converter-package's Introduction

GF Converter Package

GF Converter

Made with Node.js NPM Package version Status: in production MIT License

Introduction

GF Converter 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:

npm install gf-converter

Importing

To import the GF Converter 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.

// Using ES6 imports
import {
    binToOct,
    binToDec,
    binToHex,
    octToBin,
    octToDec,
    octToHex,
    decToBin,
    decToOct,
    decToHex,
    hexToBin,
    hexToOct,
    hexToDec,
} from 'gf-converter';

// Using Node.js `require()`
const gfConverter = require('gf-converter');

Usage

The GF Converter 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

import {
    binToOct,
    binToDec,
    binToHex,
    octToBin,
    octToDec,
    octToHex,
    decToBin,
    decToOct,
    decToHex,
    hexToBin,
    hexToOct,
    hexToDec,
} from 'gf-converter';

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():

const gfConverter = require('gf-converter');

console.log('Testing binToOct:');
console.log(gfConverter.binToOct('101010')); // Output: '52'

console.log('Testing binToDec:');
console.log(gfConverter.binToDec('101010')); // Output: '42'

console.log('Testing binToHex:');
console.log(gfConverter.binToHex('101010')); // Output: '2A'

console.log('Testing octToBin:');
console.log(gfConverter.octToBin('52')); // Output: '101010'

console.log('Testing octToDec:');
console.log(gfConverter.octToDec('52')); // Output: '42'

console.log('Testing octToHex:');
console.log(gfConverter.octToHex('52')); // Output: '2A'

console.log('Testing decToBin:');
console.log(gfConverter.decToBin('42')); // Output: '101010'

console.log('Testing decToOct:');
console.log(gfConverter.decToOct('42')); // Output: '52'

console.log('Testing decToHex:');
console.log(gfConverter.decToHex('42')); // Output: '2A'

console.log('Testing hexToBin:');
console.log(gfConverter.hexToBin('2A')); // Output: '00101010'

console.log('Testing hexToOct:');
console.log(gfConverter.hexToOct('2A')); // Output: '52'

console.log('Testing hexToDec:');
console.log(gfConverter.hexToDec('2A')); // Output: '42'

You can view and run the example code for using the package at src/test.ts or via Repl.it.

Contact

If you want to get in touch regarding matters related to this project, you have two main channels: the developers' company website or email.

Contributors

The complete GF Converter project was developed by Artur Bomtempo and Letícia França. Artur contributed to the NPM package, API, and chatbot, while Letícia created the entire graphical interface of the project, which is hosted on the web.


Artur Bomtempo

Letícia França

License

Copyright (c) 2024 Artur Bomtempo Colen

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.

gf-converter-package's People

Contributors

arturcolen avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.