1.0.0 • Published 3 years ago

@catcoderboii/maths v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

@catcoderboii/maths.js

Installation

$ npm install catcoderboii/maths.js

How to import the class

  • Using Nodejs require syntax

const Math = require("@catcoderboii/maths.js");
const math = new Math();

//rest of the code...
  • Using ES6 import syntax

import Math from '@catcoderboii/maths.js';
const math = new Math();

//rest of the code...

We also have the individual functions to import, lets see how

  • Using Nodejs require syntax

// using add in this example 
const { add } = require('@catcoderboii/maths.js');

//now use the add function as normal
add(1,2,3)

//rest of code...
  • Using ES6 import syntax

//Using add as an example
import { add } from '@catcoderboii/maths.js';

//Using the add function as normal
add(1,2,3)

//rest of code...

List of functions

  • add
  • division
  • multiply
  • sign
  • subtract

What each function does

I am using only ES6 imports though they work with Nodejs require

All of these work with the class method too! It's just Math#Function instead of just Function.

  • Add Function

/**
 * @param {number[]} numbers
 * @emmits number
*/
//importing the functions (add namely)
import {add} from '@catcoderboii/maths.js';

//Using the function with the numbers 1,2, and 3.
add(1,2,3)
  • Subtraction

/**
 * @param {number[]} numbers
 * @emmits number
*/
//Importing the function (namely subtract)
import {subtract} from '@catcoderboii/maths.js';

//Using the function with numbers 1,2,3 (does it like 1-2-3)
subtract(1,2,3)

Others are same and i'll make docs about them later

  • Sign

    This one is different
/** 
 * Sign is different from all others. this returns true if positive, false if negative, and undefined if anything else.
 * 
 * @param {Number} number
 * @param {Object} config
 * Options for this command are "sign" which can have a value of "positive" or "negative".
 * 
*/
//Importing the function  (namely sign)
import {sign} from "catcoderboii/maths.js";

//using the function with the config
sign(10, {sign: "positive"})
//returns true

//If there is no config, it will return the sign (in development)

Other quirks

  • you can import the "signAbs" interface, just head over to the index.ts (of the module) and un-comment line 44.