npm.io
1.0.0 • Published 4 years ago

@catcoderboii/maths

Licence
ISC
Version
1.0.0
Deps
0
Size
43 kB
Vulns
0
Weekly
0

@catcoderboii/maths.js

Installation

$ npm install catcoderboii/maths.js

How to import the class

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

//rest of the code...
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 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 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.

/**
 * @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)
/**
 * @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

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.