diff options
| author | Josef Salyer <[email protected]> | 2012-11-04 15:25:15 -0500 |
|---|---|---|
| committer | Josef Salyer <[email protected]> | 2012-11-04 15:25:15 -0500 |
| commit | bf4c6205ab8942a2f5a71dcb3eadd018e6aa0a1f (patch) | |
| tree | ef2249461546487b44d63bc98d1466c8836fc6ea | |
| parent | aad57053e5f271bd4ae74eb394e666b205cb375c (diff) | |
| download | faker-bf4c6205ab8942a2f5a71dcb3eadd018e6aa0a1f.tar.xz faker-bf4c6205ab8942a2f5a71dcb3eadd018e6aa0a1f.zip | |
added amount in
| -rw-r--r-- | Faker.js | 15 | ||||
| -rw-r--r-- | tests/node_min_test.js | 8 |
2 files changed, 23 insertions, 0 deletions
@@ -267,6 +267,8 @@ Faker.Finance = {}; Faker.Finance.account = function(length){ + if(!length) length = 8; + var template = ''; for(var i=0; i<length; i++) @@ -310,6 +312,19 @@ Faker.Finance.mask = function(length, parens, elipsis){ } +//min and max take in minimum and maximum amounts, dec is the decimal place you want rounded to, symbol is $, €, £, etc +Faker.Finance.amount = function(min, max, dec, symbol){ + + if(!min) min = 1 + if(!max) max = 1000 + if(!dec) dec = 2 + if(!symbol) symbol = '' //default to nothing + + + return symbol + Math.round((Math.random() * (max - min) + min)*Math.pow(10,dec))/Math.pow(10,dec); + +} + Faker.Helpers = {}; Faker.Helpers.randomNumber = function (range) { diff --git a/tests/node_min_test.js b/tests/node_min_test.js index 6fc051a5..47e5f030 100644 --- a/tests/node_min_test.js +++ b/tests/node_min_test.js @@ -6,5 +6,13 @@ var card = Faker.Helpers.createCard(); util.puts(JSON.stringify(card)); +util.log(Faker.Finance.account(9)) + +util.log(Faker.Finance.name()) + +util.log(Faker.Finance.mask(4,true,true)) + +util.log(Faker.Finance.amount(1,100,2,'£')) + |
