npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nirajan_/calcula-tor

v1.0.7

Published

A calculator that performs basic math operations and converts the result to Binary, Hexadecimal, and Octal values

Downloads

72

Readme

Description

Live site

This is a simple calculator npm package that provides basic arithmetic operations such as addition, subtraction, multiplication, and division. It also supports decimal numbers and includes features such as delete (DEL) and clear (AC). The results are converted into Binary, Octal, and Hexadecimal numbers.

Installation

To install the calculator app, run the following command:

$ npm install @nirajan_/calcula-tor

After installing the package, you can use the calculator app in your project by importing the necessary files and adding them to your HTML file.

Import the CSS files:

<link rel="stylesheet" href="node_modules/calculator-app/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="node_modules/calculator-app/dist/css/style.css">

Import the JavaScript file:


<script src="node_modules/calculator-app/dist/js/calculator.js"></script>

Add the calculator HTML structure to your file: #existing HTML structure

#<div class="container d-grid mt-3">
  <div class="row p-1">
    <div class="col-lg-3 col-md-3 col-sm-1 d-flex align-items-center bg-dark shadow opacity-75 text-light box mr-1">
      <h3 class="vt323-regular p-2 heading">This calculator performs basic math operations and converts the results to Binary, Hexadecimal, and Octal Numbers</h3>
    </div>
    <div class="col-lg-6 col-md-6 col-sm-7 box">
      <!-- Calculator buttons and input field -->
    </div>
    <div class="col-lg-3 col-md-3 col-sm-4 box opacity-75 d-flex flex-column justify-content-center align-content-center text-align-center text-light">
      <!-- Number system result displays -->
    </div>
  </div>
#</div>

The JavaScript code (index.js) utilizes the IDs and classes defined in the HTML to perform calculations and update the display. If you wish to modify the HTML structure or CSS styles, you can do so by editing the existing files. However, please ensure that the JavaScript code remains compatible with the updated HTML structure.

If you decide to make changes to the HTML structure, you may need to update the JavaScript code accordingly to ensure proper functionality

Documentation

The calculator app consists of the following functions:

calculate(fullExp): This function performs mathematical calculations on the given expression. It splits the expression into tokens, parses the numbers and operators, and performs the corresponding operations.

decimalToBinary(finalResult): This function converts the given decimal number to its binary representation, including the fractional part up to 6 decimal places.

decimalToHexa(finalResult): This function converts the given decimal number to its hexadecimal representation, including the fractional part up to 6 decimal places.

decimalToOctal(finalResult): This function converts the given decimal number to its octal representation, including the fractional part up to 6 decimal places.

The main logic for handling button clicks and updating the display is contained in the event listener attached to each button.

Dependencies

The calculator app relies on the following dependencies:

  • Bootstrap (CSS framework)
  • Additional CSS styles (style.css)

These dependencies are included in the dist folder of the npm package.

Contributing

Contributions to the calculator app are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the project's GitHub repository.