For educational use
- Use the following command to install the library in your project
npm i calculator-typescript-alanch8
- Import the library into your project like this
import {Calculator} from 'calculator-typescript-alanch8';
add(a:number,b:number):number
addition of a and b variables (muest be numbers). returns a + b.
subs(a:number,b:number):number
substraction of a and b variables (muest be numbers). returns a - b.
multiply(a:number,b:number):number
multiplication of a and b variables (muest be numbers). returns a * b.
div(a:number,b:number):number
division of a and b variables (muest be numbers). returns a / b.
If the b variable is a zero (0) number the program will throw a math error.
In order to create and upload this library to Npm, we have used C-J Kihl's tutorial from Medium.
Important things to keep in mind;
- Start the project
- Configure it.
- Create a build (transpile it with tsc).
- format it and paint it with Prettier and Tlint.
- Test it with Jest in the best case.
Once the library is finished, we create a commit and upload it to github using git push in order to continue with the steps to upload it to npm.
Let's publish the lib to npm with:
npm publish
And that's all ๐. It's interstingt to know we can make diferent versions with:
npm version patch
Thanks for reading!
Aitor Lancharro "Alanch8" โ