josdejong / josdejong/mathjs

Removing user-defined units

Open
#2,081 8 comments 1 reaction 0 assignees View on GitHub
feature help wanted
Dominant language
JavaScript
Stars
15.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Is there a way to remove user-defined units? I create units for currency conversion using:

```javascript
math.createUnit('USD', {aliases: ['usd']})

var rates = currencyRates //Rates in json format
Object.keys(rates).map((currency) => {
math.createUnit(rates[currency].code, {
definition: math.unit(rates[currency].inverseRate + 'USD'),
aliases: [rates[currency].code.toLowerCase()]
}, {
override: true
})
})
```

But if I no longer want to use currencies, is there a way to remove them without creating a new mathjs instance (in my case without refreshing browser window)? If not, may I suggest introducing a math.removeUnit() method?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.