@abasb75/fraction
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

add to your node js project :

npm install @abasb75/fraction --save

usage example :

import {compute , parse , renderTree} from '@abasb75/fraction';

const computeTest = compute('2+4');
console.log(computeTest);
//result : 6

const computeTest2 = compute('(2+4)/3',()=>{});
console.log(computeTest2);
//result : 2

const computeTest3 = compute('2/5*6/7',()=>{
    // this function execute when error occurred
    console.log('error')
});
console.log(computeTest3);
//result : 0.34285714285714286

const parseTest = parse('2+4',()=>{});
console.log(parseTest);
/*
result :
{
  type: 'plus',
  a: { type: 'number', value: '2' },
  b: { type: 'number', value: '4' }
}
*/


const renderTreeTest = renderTree('2+4',()=>{});
console.log(renderTreeTest);
/*
result :
+
├─ 2
└─ 4
}
*/

const parseInValid = parse('(3+',()=>{
    console.log('an error occurred')
})
//result : an error occurred

Package Sidebar

Install

npm i @abasb75/fraction

Weekly Downloads

0

Version

0.0.2

License

ISC

Unpacked Size

4.15 kB

Total Files

12

Last publish

Collaborators

  • abasb75