2022-03-25 07:49:03 +00:00
|
|
|
/* Core of picomath: generates an instance */
|
|
|
|
import poortf from './poortf.js'
|
|
|
|
|
|
|
|
export default function picomathInstance (instName) {
|
2022-03-25 08:54:20 +00:00
|
|
|
/* Since we have to do it all the time, when we call a picomath instance
|
|
|
|
* as a function, it takes a name and 0 or more implementations add adds
|
|
|
|
* them to its poortf property named name, returning that property value.
|
|
|
|
*/
|
2022-03-25 07:49:03 +00:00
|
|
|
function fn (name, imps) {
|
|
|
|
if (name in fn) {
|
|
|
|
fn[name].addImps(imps)
|
|
|
|
} else {
|
|
|
|
fn[name] = poortf(name, imps)
|
|
|
|
}
|
|
|
|
return fn[name]
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.defineProperty(fn, 'name', {value: instName})
|
|
|
|
|
|
|
|
return fn
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|