• Stars
    star
    189
  • Rank 204,649 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ’ณA little library to handle money amounts.

"Mo money, No problems" - walletjs

Build Status Coverage Status Code Climate

IMPORTANT: We use big.js to handle huge numbers.

Now you can handle money without headaches!

API Reference

Install

npm install --save walletjs
or
yarn add walletjs

Examples

import Wallet, { Money } from 'walletjs'

const money = Money.init(100)
const wallet = Wallet.init(money)
console.log(wallet.getAmount(money.currency))

const money2 = Money.init(100)
const newWallet = wallet.add(money2)
console.log(newWallet.getAmount(money2.currency))

convertCurrency

import Wallet, { Money } from 'walletjs'

const money = Money.init(100, { currency: 'BRL' } )
const brlWallet = Wallet.init(money)
const usdWallet = brlWallet.convertCurrency('BRL', 'USD', 3.09)

console.log(brlWallet.getAmount('BRL')) => '100.00'
console.log(brlWallet.getAmount('USD')) => '0.00'

console.log(usdWallet.getAmount('BRL')) => '0.00'
console.log(usdWallet.getAmount('USD')) => '309.00'

no problems with float errors

// on javascript
const a = 0.1
const b = 0.2
console.log(a + b) => 0.30000000000000004

// on walletjs
const money = Money.init(0.2)
money.add(0.1) => returns 0.3

More Repositories

1

strman

๐Ÿ—A Javascript string manipulation library.
JavaScript
2,012
star
2

valid.js

๐Ÿ“ A library for data validation.
JavaScript
607
star
3

react-fetches

๐Ÿ™React Fetches a new way to make requests into your REST API's.
JavaScript
249
star
4

crates

๐ŸŒŽ A tool to generate your locale files compatible with i18n.
JavaScript
52
star
5

fetches

๐Ÿฆ‘Fetches is a workaround to make requests, in an easy and scalable way.
JavaScript
16
star
6

twitty

A simple but gold Twitter Command Line Client.
JavaScript
14
star
7

ng-clipboard

AngularJS directive to copy or cut text to clipboard without using flash.
JavaScript
10
star
8

gulp-es6

Using gulp with es6
JavaScript
6
star
9

babel-plugin-transform-remove-import

This plugin removes all import calls.
JavaScript
5
star
10

showdeps

A little library to list all imports in a code.
JavaScript
5
star
11

react-cep

Componente em React para acessar api de cep
JavaScript
5
star
12

service-worker-sandbox

My Service Worker Sandbox
JavaScript
3
star
13

babel-plugin-transform-remove-export

This plugin removes all export calls.
JavaScript
2
star
14

api-twitter-example

Testes na plataforma Twitter
JavaScript
2
star
15

formating

A simple library for data format
JavaScript
2
star
16

dleitee.github.io

Meu site pessoal
CSS
1
star
17

design-patterns-features

1
star
18

gulp-with-modules

How to use gulp with modules
JavaScript
1
star
19

tic-tac-toe-server

1
star
20

dotfiles

My dotfiles
Shell
1
star
21

todo-api

JavaScript
1
star
22

gulp-basic

Basic Gulpfile
JavaScript
1
star
23

config-default

My default config
JavaScript
1
star
24

meusalgado

รrea de orรงamento do site Meu Salgado
JavaScript
1
star