diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/address.js | 13 | ||||
| -rw-r--r-- | lib/index.js | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/address.js b/lib/address.js index 38c1e38c..1ccbfdc9 100644 --- a/lib/address.js +++ b/lib/address.js @@ -60,6 +60,10 @@ function Address (faker) { * @param {String} format */ this.city = function (format) { + if (!format && faker.definitions.address.city_name) { + return this.cityName(); + } + var formats = [ '{{address.cityPrefix}} {{name.firstName}}{{address.citySuffix}}', '{{address.cityPrefix}} {{name.firstName}}', @@ -93,6 +97,15 @@ function Address (faker) { } /** + * Returns a random city name + * + * @method faker.address.cityName + */ + this.cityName = function() { + return faker.random.arrayElement(faker.definitions.address.city_name); + } + + /** * Returns a random localized street name * * @method faker.address.streetName diff --git a/lib/index.js b/lib/index.js index 16def0a3..205adec5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -103,7 +103,7 @@ function Faker (opts) { var _definitions = { "name": ["first_name", "last_name", "prefix", "suffix", "gender", "title", "male_prefix", "female_prefix", "male_first_name", "female_first_name", "male_middle_name", "female_middle_name", "male_last_name", "female_last_name"], - "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "country_code_alpha_3", "state", "state_abbr", "street_prefix", "postcode", "postcode_by_state", "direction", "direction_abbr", "time_zone"], + "address": ["city_name", "city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "country_code_alpha_3", "state", "state_abbr", "street_prefix", "postcode", "postcode_by_state", "direction", "direction_abbr", "time_zone"], "company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"], "lorem": ["words"], "hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb", "phrase"], |
