Skip to content

Commit 6c79e02

Browse files
committedMay 19, 2015
update usage docs
1 parent bf9d28c commit 6c79e02

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed
 

‎README.md

+42-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,42 @@ $ npm install --save moneyjs
1717
var Money = require('moneyjs');
1818

1919
//instantiate a new money
20-
var price = new Money(12,Money.USD,new Date())
21-
...
22-
//continue with money usage see API guide
20+
var purchasePrice = new Money(12,Money.USD,new Date())
21+
var margin = new Money(156,Money.TZS,new Date());
22+
23+
//compute selling price
24+
//by adding purchase price and margin
25+
purchasePrice.plus(margin, function(error,sellingPrice){
26+
...
27+
});
28+
29+
var profit = Money.THOUSAND;
30+
var tax = Money.FIFTY;
31+
//compute net profit by subtract tax from profit
32+
profit.minus(tax,function(error,netProfit){
33+
...
34+
});
35+
36+
//check if net profit is zero
37+
nextProfit.isZero();
38+
39+
//check if net profit is negative
40+
netProfit.isNegative();
41+
42+
var expectedProfit = Money.HUNDRED;
43+
44+
//check if net profit is greater than
45+
//expected profit
46+
netProfit.isGreaterThan(expectedProfit);
47+
48+
//check if net profit is less than
49+
//expected profit
50+
netProfit.isLessThan(expectedProfit);
51+
52+
//check if net profit is equal to
53+
//expected profit
54+
netProfit.isEqualTo(expectedProfit);
55+
2356
...
2457
```
2558

@@ -49,7 +82,12 @@ Used to get `exchange rates` when `exchange` money instance from one currency to
4982

5083
Example of implementation
5184
```js
52-
var rates = {USD:1,TZS:1900,KES:90};
85+
var rates = {
86+
USD: 1,
87+
TZS: 1900,
88+
KES: 90
89+
};
90+
5391
function getExchangeRates(date,done){
5492
//fetch exchange rates
5593
//from API or anywhere else

‎index.js

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//dependencies
44
var path = require('path');
55

6-
76
/**
87
* @description export money type
98
* @type {Money}

0 commit comments

Comments
 (0)
Please sign in to comment.