mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
7 lines
213 B
TypeScript
7 lines
213 B
TypeScript
/**
|
|
* Similar to the modulo operator, but always returns a positive number (even when the input is negative).
|
|
*/
|
|
export function remainder(n: number, d: number): number {
|
|
return ((n % d) + Math.abs(d)) % d;
|
|
}
|