Add license information.
[ustaxlib.git] / src / core / Math.ts
1 // Copyright 2020 Blue Static <https://www.bluestatic.org>
2 // This program is free software licensed under the GNU General Public License,
3 // version 3.0. The full text of the license can be found in LICENSE.txt.
4 // SPDX-License-Identifier: GPL-3.0-only
5
6 export const clampToZero = (value: number): number => value < 0 ? 0 : value;
7
8 export const undefinedToZero = (value?: number): number => value === undefined ? 0 : value;
9
10 export const reduceBySum = (list: number[]) => list.reduce((acc, curr) => acc + curr, 0);