|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
691 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const toNumber = require('../util/toNumber.js');
|
|---|
| 6 | const toString = require('../util/toString.js');
|
|---|
| 7 |
|
|---|
| 8 | function add(value, other) {
|
|---|
| 9 | if (value === undefined && other === undefined) {
|
|---|
| 10 | return 0;
|
|---|
| 11 | }
|
|---|
| 12 | if (value === undefined || other === undefined) {
|
|---|
| 13 | return value ?? other;
|
|---|
| 14 | }
|
|---|
| 15 | if (typeof value === 'string' || typeof other === 'string') {
|
|---|
| 16 | value = toString.toString(value);
|
|---|
| 17 | other = toString.toString(other);
|
|---|
| 18 | }
|
|---|
| 19 | else {
|
|---|
| 20 | value = toNumber.toNumber(value);
|
|---|
| 21 | other = toNumber.toNumber(other);
|
|---|
| 22 | }
|
|---|
| 23 | return value + other;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | exports.add = add;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.