Skip to main content

Migrate from Version v8 to v9


Version 9 of eMath.js will release with a few changes. This guide will help you migrate your existing code from version 8 to version 9.

The following changes have been made in version 9:

  • Change from E to Decimal class from break_eternity.js
  • Change from ESource type to DecimalSource type

You should still import from "emath.js" instead of "break_eternity.js", but the Decimal class is now used instead of the E class.

Note: You can still use the E class if you prefer.

Change from ESource to DecimalSource

In version 9, the ESource type has been renamed to DecimalSource.

script.ts
import { DecimalSource } from "emath.js";

Change from E to Decimal

In version 9, the E class has been removed and replaced with the Decimal class from break_eternity.js.

script.ts
// Before (v8)
import { E } from "emath.js";

const number = E(10);
const result = E.add(number, E(5));

// After (v9)
import { Decimal } from "emath.js";

const number = new Decimal(10);
const result = Decimal.add(number, new Decimal(5));

You could still use the E function, but it is deprecated and will be removed in future versions.

Regexes

Here are some regexes that you can use to replace the E class with the Decimal class in your code:

(Tip: In VSCode you can use the Ctrl + Shift + H shortcut to open the search and replace panel for all files, then click the .* button to enable regex mode)

Search:

ESource

Replace:

DecimalSource

Search:

E\((.*?)\)

Replace:

new Decimal($1)

(you should be careful with this one, as it might replace other instances of E that are not the E class)

Search:

E

Replace:

Decimal