Rational numbers code bricks for JavaScript.
let [ a , b ] = add( 1 , 10 , 1 , 5 ) ;
a / b === 3 / 10 ;
Can be managed through jspm,
duo,
component,
bower,
ender,
jam,
spm,
and npm.
Install
jspm
jspm install github:aureooms/js-rational
# or
jspm install npm:aureooms-js-rational
duo
No install step needed for duo!
component
component install aureooms/js-rational
bower
bower install aureooms-js-rational
ender
ender add aureooms-js-rational
jam
jam install aureooms-js-rational
spm
spm install aureooms-js-rational --save
npm
npm install aureooms-js-rational --save
Require
jspm
let rational = require( "github:aureooms/js-rational" ) ;
import rational from 'aureooms-js-rational' ;
duo
let rational = require( "aureooms/js-rational" ) ;
component, ender, spm, npm
let rational = require( "aureooms-js-rational" ) ;
bower
The script tag exposes the global variable rational
.
<script src="bower_components/aureooms-js-rational/js/dist/rational.min.js"></script>
Alternatively, you can use any tool mentioned here.
jam
require( [ "aureooms-js-rational" ] , function ( rational ) { ... } ) ;
Use
let number = require( 'aureooms-js-number' ) ;
let add = rational._add( number.mul , number.add ) ;
let sub = rational._sub( number.mul , number.sub ) ;
let mul = rational._mul( number.mul ) ;
let div = rational._div( number.mul ) ;