0.1.9 • Published 2 years ago

@tipser/markets v0.1.9

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Markets utils for Tipser

Changelog

How to use ?

Install the package

First - install via npm

npm install @tipser/markets

or via yarn

yarn add @tipser/markets

Import it in your source code

import { getMarketName } from '@tipser/markets'; 

Example of usage

Formatting currency

import { getLocaleByMarket, getCurrencyByMarket  } from '@tipser/markets';

const someMarket = 'se';
const currentLocale = getLocaleByMarket(someMarket);
const currentCurrency = getCurrencyByMarket(someMarket)
const myNicePrice = (123.4567).toLocaleString(currentLocale, { style: 'currency', currency: currentCurrency })
console.log(myNicePrice);
// prints: "123,46 kr"

Validating incoming market

import { isMarketName } from '@tipser/markets'; 

console.log(isMarketName('se'));
// prints: true

console.log(isMarketName('it'));
// prints: false

Flags images

Import flag file for any marketName from @tipser/markets/dist/assets/flags/{marketName}.svg.

e.g.

import deFlagPath from '@tipser/markets/dist/assets/flags/de.svg'

//(...) somewhere in e.g. React component
return <img src={deFlagPath} alt="german flag"/>

👆 deFlagPath should be a path to a static assets in project's build folder.

This is default behaviour in e.g. Creat React App 3.x. It happens because its webpack is configured to hit most of the files from node_modules via file-loader)

0.1.9

2 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago