source: node_modules/es-toolkit/dist/compat/math/add.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 563 bytes
RevLine 
[a762898]1import { toNumber } from '../util/toNumber.mjs';
2import { toString } from '../util/toString.mjs';
3
4function add(value, other) {
5 if (value === undefined && other === undefined) {
6 return 0;
7 }
8 if (value === undefined || other === undefined) {
9 return value ?? other;
10 }
11 if (typeof value === 'string' || typeof other === 'string') {
12 value = toString(value);
13 other = toString(other);
14 }
15 else {
16 value = toNumber(value);
17 other = toNumber(other);
18 }
19 return value + other;
20}
21
22export { add };
Note: See TracBrowser for help on using the repository browser.