addons/isl/src/stackEdit/revMath.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318/** Simple math utilities for branded numbers */
b69ab319
b69ab3110/** `+` but preserves the return type. */
b69ab3111export function next<T extends number>(rev: T, offset = 1): T {
b69ab3112 return (rev + offset) as T;
b69ab3113}
b69ab3114
b69ab3115/** `-` but preserves the return type. */
b69ab3116export function prev<T extends number>(rev: T, offset = 1): T {
b69ab3117 return (rev - offset) as T;
b69ab3118}
b69ab3119
b69ab3120/** `Math.max` but preserves the return type. */
b69ab3121export function max<T extends number>(...values: Array<T | number>): T {
b69ab3122 return Math.max(...values) as T;
b69ab3123}