Files
common/packages/util/src/format/getSeparator.ts
T
Aleš Ferlan 913bf65dab feat: allow setting of thousand/decimal separators (#1722)
* feat: allow setting of thousand/decimal separators

* fix: add file header and fix lint errors

* fix: move getSeparator to format
2023-02-07 14:56:27 +02:00

16 lines
453 B
TypeScript

// Copyright 2017-2023 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
/**
* Get the decimal and thousand separator of a locale
* @param locale
* @returns {decimal: string, thousand: string}
*/
export function getSeparator (locale?: string):
{ thousand: string, decimal: string } {
return {
decimal: (0.1).toLocaleString(locale).substring(1, 2),
thousand: (1000).toLocaleString(locale).substring(1, 2)
};
}