Skip to content
This repository has been archived by the owner on Oct 25, 2020. It is now read-only.
/ ock-helpers Public archive

A collection of helpers to boost the development speed and code share

Notifications You must be signed in to change notification settings

ockpay/ock-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ock Helpers

A collection of helpers to boost the development speed and code share

Installation

Use npm or yarn

yarn add bla
npm install bla

Usage

import foobar

foobar.pluralize('word') # returns 'words'
foobar.pluralize('goose') # returns 'geese'
foobar.singularize('phenomena') # returns 'phenomenon'

Features

Currency

To parse/format money using the pt-br/BRL currency

addCurrency

Add a R$ BRL currency if necessary

  • Adds R$ prefix
const withPrefix = addCurrency('20.0')
// return will be: R$ 20.0

parseCurrencyToABNT

Format a number (float) to a BRL currency according to ABNT

  • Convert dots to commas
  • Adds R$ prefix
  • Adds 0 at end if necessary
const abntFormat = parseCurrencyToABNT('20.0')
// return will be: R$ 20,00

parseCurrencyToFloat

Converts a string on BRL currency format to float

  • Convert commas to dots
  • Removes R$ prefix
  • Removes the 0 at end if exists
const floatCurrency = parseCurrencyToFloat('R$ 20,00')
// return will be: 20.0

License

MIT

About

A collection of helpers to boost the development speed and code share

Resources

Stars

Watchers

Forks

Packages

No packages published