0.2.3 • Published 12 months ago

@sobhanshms4106/calculator v0.2.3

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

Calculator Module

A simple calculator module with Jalali date logging that performs basic arithmetic operations and logs the results with the current Jalali (Shamsi) date.

Features

  • Sum: Adds two numbers.
  • Subtract: Subtracts the first number from the second.
  • Multiply: Multiplies two numbers.
  • Divide: Divides the first number by the second (handles division by zero with an error).
  • Modulo: Computes the remainder of the division of two numbers.
  • Power: Raises the first number to the power of the second.

Each operation logs the result along with the current date in the Jalali calendar and returns the result.

Here's how you can use the calculator module in your project:

const mathWithDate = require('@sobhanshms4106/calculator');

// Perform operations and get results
const a = mathWithDate.sumWithDate(3, 4); // return 7
// Sum of 3 & 4 equals 7! In 1403/05/10

const b = mathWithDate.subtractWithDate(3, 4); // return -1
// Subtract of 3 & 4 equals -1! In 1403/05/10

const c = mathWithDate.multiplyWithDate(3, 4); // return 12
// Multiply of 3 & 4 equals 12! In 1403/05/10

const d = mathWithDate.divideWithDate(3, 4); // return 0.75
// Divide of 3 & 4 equals 0.75! In 1403/05/10

const d = mathWithDate.divideWithDate(3, 0); // will throw error
//

const f = mathWithDate.moduloWithDate(3, 4); // return 3
// Modulo of 3 & 4 equals 3! In 1403/05/10

const g = mathWithDate.powWithDate(3, 4); // return 81
// Power of 3 & 4 equals 81! In 1403/05/10

Test

To run tests

npm install
nmp test (or node test.js)
0.2.3

12 months ago

0.2.2

12 months ago

0.2.1

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago