picomath/complex/extendByComplex.js

24 lines
636 B
JavaScript
Raw Normal View History

import { isTF } from '../poortf.js'
import createComplex from './complex.js'
/* Add all the complex methods for the number methods that are
* already in the instance: */
export default async function extend(pmath) {
for (const item in pmath) {
if (isTF(pmath[item])) {
// might be a number method, try importing
const modulePath = `./${item}.js`
try {
const { default: create } = await import(modulePath)
create(pmath)
} catch (err) {
// Guess it wasn't a number method; no worries
}
}
}
createComplex(pmath)
}