1 | import { factory } from '../../utils/factory.js';
|
2 | import { addNumber } from '../../plain/number/index.js';
|
3 | var name = 'addScalar';
|
4 | var dependencies = ['typed'];
|
5 | export var createAddScalar = factory(name, dependencies, (_ref) => {
|
6 | var {
|
7 | typed
|
8 | } = _ref;
|
9 |
|
10 | |
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | return typed(name, {
|
23 | 'number, number': addNumber,
|
24 | 'Complex, Complex': function ComplexComplex(x, y) {
|
25 | return x.add(y);
|
26 | },
|
27 | 'BigNumber, BigNumber': function BigNumberBigNumber(x, y) {
|
28 | return x.plus(y);
|
29 | },
|
30 | 'Fraction, Fraction': function FractionFraction(x, y) {
|
31 | return x.add(y);
|
32 | },
|
33 | 'Unit, Unit': function UnitUnit(x, y) {
|
34 | if (x.value === null || x.value === undefined) throw new Error('Parameter x contains a unit with undefined value');
|
35 | if (y.value === null || y.value === undefined) throw new Error('Parameter y contains a unit with undefined value');
|
36 | if (!x.equalBase(y)) throw new Error('Units do not match');
|
37 | var res = x.clone();
|
38 | res.value = this(res.value, y.value);
|
39 | res.fixPrefix = false;
|
40 | return res;
|
41 | }
|
42 | });
|
43 | }); |
\ | No newline at end of file |