signal-desktop/ts/util/normalizeNumber.ts

18 lines
443 B
TypeScript
Raw Normal View History

2021-07-02 19:21:24 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export function normalizeNumber(value: number | Long): number;
export function normalizeNumber(value?: number | Long): number | undefined;
export function normalizeNumber(value?: number | Long): number | undefined {
if (value === undefined) {
return undefined;
}
if (typeof value === 'number') {
return value;
}
return value.toNumber();
}