feat: add number negate and roll up number functions into one module
This commit is contained in:
parent
f5e2e09aa2
commit
a22add9434
2
number/all.mjs
Normal file
2
number/all.mjs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export {add} from './add.mjs'
|
||||||
|
export {negate} from './negate.mjs'
|
3
number/negate.mjs
Normal file
3
number/negate.mjs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export const negate = {
|
||||||
|
number: [[], n => -n]
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
/* Core of pocomath: generates the default instance */
|
/* Core of pocomath: generates the default instance */
|
||||||
import PocomathInstance from './PocomathInstance.mjs'
|
import PocomathInstance from './PocomathInstance.mjs'
|
||||||
import * as numberAdd from './number/add.mjs'
|
import * as numbers from './number/all.mjs'
|
||||||
|
|
||||||
const math = new PocomathInstance('math')
|
const math = new PocomathInstance('math')
|
||||||
math.install(numberAdd)
|
math.install(numbers)
|
||||||
|
|
||||||
export default math
|
export default math
|
||||||
|
@ -7,4 +7,8 @@ describe('The default full pocomath instance "math"', () => {
|
|||||||
assert.strictEqual(math.add(1.5, 2.5, 3.5), 7.5)
|
assert.strictEqual(math.add(1.5, 2.5, 3.5), 7.5)
|
||||||
assert.strictEqual(math.add(Infinity), Infinity)
|
assert.strictEqual(math.add(Infinity), Infinity)
|
||||||
})
|
})
|
||||||
|
it('can negate numbers', () => {
|
||||||
|
assert.strictEqual(math.negate(-1), 1)
|
||||||
|
assert.strictEqual(math.add(10, math.negate(3)), 7)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user