
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
@algorithm.ts/calculate
Advanced tools
A tiny calculator for number arithmetics such as '+-*/()'
A tiny calculator for number arithmetics such as +-*/()
.
npm
npm install --save @algorithm.ts/calculate
yarn
yarn add @algorithm.ts/calculate
deno
import calculate from 'https://raw.githubusercontent.com/guanghechen/algorithm.ts/main/packages/calculate/src/index.ts'
// Perform integer arithmetics.
import calculate from 'algorithm.ts/calculate'
// or
import { calculate } from 'algorithm.ts/calculate'
// Perform decimal arithmetics.
import { decimalCalculate } from 'algorithm.ts/calculate'
// Perform bigint arithmetics.
import { bigintCalculate } from 'algorithm.ts/calculate'
integer arithmetics
import calculate from '@algorithm.ts/calculate'
calculate('3/2') // => 1
calculate('-2+1') // => -1
calculate('-2*3 + 2*5*3/6') // => -1
calculate('(1+(4+5+2)-3)+(6+8)') // => 23
decimal arithmetics
import { decimalCalculate as calculate } from '@algorithm.ts/calculate'
calculate('3/2') // => 1.5
calculate('-2+1') // => -1
calculate('-2*3 + 2*5*3/6') // => -1
calculate('(1+(4+5+2)-3)+(6+8)') // => 23
bigint arithmetics
import { bigintCalculate as calculate } from '@algorithm.ts/calculate'
calculate('22222222222222222222222222222 * 3333333333333333333323232')
// => 74074074074074074073849599999259259259259259259261504n
Illegal inputs
import calculate from '@algorithm.ts/calculate'
calculate('-2++1') // => SyntaxError
calculate('-2*/23') // => SyntaxError
calculate('1+(4+5+2))') // => SyntaxError
calculate('1+(4+5+2') // => SyntaxError
A solution of https://leetcode.com/problems/basic-calculator/
export { calculate } from '@algorithm.ts/calculate'
A solution of https://leetcode.com/problems/basic-calculator-ii/
export { calculate } from '@algorithm.ts/calculate'
FAQs
A tiny calculator for number arithmetics such as '+-*/()'
The npm package @algorithm.ts/calculate receives a total of 33 weekly downloads. As such, @algorithm.ts/calculate popularity was classified as not popular.
We found that @algorithm.ts/calculate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.