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

@omnicar/sam-format

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@omnicar/sam-format

Library for formatting different kinds of data according to type and locale

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-86.67%
Maintainers
1
Weekly downloads
 
Created
Source

SAM-format

Library for formatting data according to locale and options given.

Installation (for development)

yarn or npm i (examples below are using yarn)

Installation on clients

yarn add omnicar/sam-format#0.0.1

Where #0.0.1 indicates the Github release tag.

Usage

First call initFormats.

const options = {
  countryCode: TIsoCountry,
  currencyCode: TCurrency,
  language: IsoLocale
}

initFormats(options)

Example: initFormats({ countryCode: 'DK', currencyCode: 'DKK', language: 'da-DK' })

Formatters

There are 4 formatters:

formatMileage(value, [opts])

showDecimals (true | false) show decimals in formatted number

symbolDisplayType (APPEND | PREPEND | NONE) where to put symbol related to number type

formatCurrency(value, [opts])

showDecimals (true | false) show decimals in formatted number

symbolDisplayType (APPEND | PREPEND | NONE) where to put symbol related to number type

formatNumber(value, [showDecimals])

showDecimals (true | false) show decimals in formatted number

formatDate(value, [opts])

showTime (true | false) append time in formatted date

rawFormat (string) pass date format string to format with

example: formatDate(new Date(2018-01-23), {rawFormat: 'YYYYMMDD'}) // '20189123'

Tests

To run jest tests either run:

yarn test

or to run tests in watch mode run:

yarn test-watch

Compile application (tsc):

yarn tsc

FAQs

Package last updated on 14 Jun 2024

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