Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decimal-separator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decimal-separator

Find the decimal and group separators used in any given locale.

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

decimal-separator

Version Size Downloads

Find the decimal and group separators used in any given locale.

Highlights

  • Supports TypeScript!
  • Supports Node and browser
  • Includes full JSX documentation
  • Very lightweight!

Installation

NodeJS

npm install decimal-separator --save

Browser

Import the script:

<script src="https://joker876.github.io/decimal-separator/decimal-separator.min.js">

Usage

NodeJS

import * from 'decimal-separator';
// or
import { /* function names here */ } from 'decimal-separator';

Browser

DecimalSep.decimalSep();
// or
const { decimalSep, groupSep, ... } = DecimalSep;

Exported functions

decimalSep

function decimalSep(): string;
function decimalSep(locale: string): string;

Get the decimal separator for the given locale.

  • locale - The locale to get the decimal separator from. Optional. If not given, uses the current user's locale.

Returns a string containing the decimal separator.

groupSep

function groupSep(): string;
function groupSep(locale: string): string;

Get the group separator for the given locale.

  • locale - The locale to get the group separator from. Optional. If not given, uses the current user's locale.

Returns a string containing the group separator.

formatUsing

function formatUsing(num: number, decimal: string): string;
function formatUsing(num: number, decimal: string, group: string): string;

Formats a number using the given decimal and group separators.

  • num - The number to format.
  • decimal - The decimal separator to use.
  • group - The group separator to use. Optional, defaults to ".".

Returns a string containing the number, formatted using the given separators.

formatWithLocale

function formatWithLocale(num: number): string;
function formatWithLocale(num: number, locale: string): string;

Formats a number using the given locale.

  • num - The number to format.
  • locale - The locale to use to format the number. Optional. If not given, uses the current user's locale.

Returns the number formatted using the given locale.

Changelog

1.1.0

  • Added JSX documentation.
  • Added this README.

1.0.0

Initial release.

Keywords

FAQs

Package last updated on 28 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc