New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

text-calculator

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

text-calculator

Text calculator built with web speech API in mind but is able to translate text and calculate it. Was built for calculating 'math-speak'.

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
6
50%
Maintainers
1
Weekly downloads
 
Created
Source

text-calculator

Text calculator built with web speech API in mind but is able to translate text and calculate it. Was built for calculating 'math-speak'.

Version

1.1.0

Installation

$ npm i --save text-calculator

Usage

Pass in a text query with basic math formulas. Note: It does not handle parenthesis as people do not say usually say "open parenthesis five plus six close parenthesis times 4" to mean "(5 + 6) * 4".

var textCalculator = require('text-calculator');

// takes in a text string and returns calculation result as a number or 'error' text if it does not understand the mathQuery given

textCalculator.calculate(mathQuery, (result) => {
    console.log(result); // 
});
  
// Examples math query input and output:
'fifty-one plus five'  --> 56
'fifty-one + 5' --> 56
'million and 45' --> 1000045
'million one hundred' --> 1000100
'sdfdsfhjkdf' --> 'error'
'parenthesis million parenthesis one hundred' --> 'error'
'5 exponent 2' --> 25
'5 to the power of 2' --> 25
'6 ^ 5' --> 7776
'5 mod 2' --> 1
'5 divided by 2' --> 2.5
'four divide four' --> 1
'square root of 4' --> 2
'million plus one tenth' --> 1000000.1
'half' --> 0.5
'6 take away 3' --> 3
'6 minus 3' --> 3
'5 cubed' --> 125
'6 squared' --> 36
and many more...


License

MIT

FAQs

Package last updated on 28 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts