1.1.0 • Published 6 years ago
async-nmbr v1.1.0
async-nmbr
Very useful JavaScript Number operator overloading for asynchronous http math operations
Getting Started
npm install --save async-nmbrnpm install --save-dev @babel/core @babel/cli babel-plugin-overload babel-template- Create a file called
.babelrcin your projects root directory - Place the following content inside:
{ "plugins": ["overload"] } - Find out how you can build/compile your project, e.g.:
npx babel src -d lib
Usage
Once the initial setup is completed you'll need to actually overload the operators for the Number type.
You can do this by simply requiring this package and passing the Number object in every file that you want to use it in, like this:
require('async-nmbr')(Number);Now that the operators are overloaded, you can do awesome calculations like:
await (1 + 1); // 2
await (100 - 1); // 99
await (2 * 2); // 4
await (Math.PI / 3); // 1.0471975511965976
(Math.PI * 3).then(res => res / 3).then(pi => console.log(pi));Please note: when using this package you'll always have to await your math calculations (isn't that awesome?)