I am doing a test where I grab an odds value and store it as a fraction. Then I want to compare the value to a particular format depending on the option selected from the drop down.
I am trying to use these to set up the fraction and determine the odds format:
https://mathjs.org/docs/datatypes/fractions.html
How do I resolve that type error above.
Screenshot:
If you want to use just fraction you can use:
const { fraction } = require("mathjs");
//In your test
fraction(oddsValue);
If you want to use others as well, you can do:
import { create, all } from "mathjs"
const math = create(all, {})
//In your test
math.fraction(oddsValue)
The mathjs has no default export, so you import everything (*) and then name it in your import
import * as math from 'mathjs'
This is the main entry point for the mathjs package.
// configuration
export { config } from './configReadonly.js'
// functions and constants
export * from './pureFunctionsAny.generated.js'
export * from './impureFunctionsAny.generated.js'
export * from './typeChecks.js'
// error classes
export { IndexError } from '../error/IndexError.js'
export { DimensionError } from '../error/DimensionError.js'
export { ArgumentsError } from '../error/ArgumentsError.js'
// dependency groups
export * from './dependenciesAny.generated.js'
// factory functions
export * from '../factoriesAny.js'
// core
export { create } from '../core/create.js'
export { factory } from '../utils/factory.js'
If it had a default export, there would be
export default {
function1,
function2,
function3,
...
}
and then you can import it without using * as math.