Skip to content

Commit

Permalink
create title function
Browse files Browse the repository at this point in the history
  • Loading branch information
chukitow authored and Marak committed Jun 11, 2015
1 parent d25a3c1 commit 685b641
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports.localeFallback = "en";
exports.definitions = {};

var _definitions = {
"name": ["first_name", "last_name", "prefix", "suffix"],
"name": ["first_name", "last_name", "prefix", "suffix", "title"],
"address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "state", "state_abbr"],
"company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb"],
"lorem": ["words"],
Expand Down Expand Up @@ -70,4 +70,4 @@ Object.keys(_definitions).forEach(function(d){
}
});
});
});
});
14 changes: 11 additions & 3 deletions lib/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ var _name = {
// we must randomly pick a name from either gender array so faker.name.firstName will return the correct locale data ( and not fallback )
var rand = faker.random.number(1);
if (rand === 0) {
return faker.random.array_element(faker.locales[faker.locale].name.male_first_name)
return faker.random.array_element(faker.locales[faker.locale].name.male_first_name);
} else {
return faker.random.array_element(faker.locales[faker.locale].name.female_first_name)
return faker.random.array_element(faker.locales[faker.locale].name.female_first_name);
}
}
return faker.random.array_element(faker.definitions.name.first_name)
return faker.random.array_element(faker.definitions.name.first_name);
},

lastName: function () {
Expand Down Expand Up @@ -52,6 +52,14 @@ var _name = {
return faker.random.array_element(faker.definitions.name.suffix);
},

title: function() {
var descriptor = faker.random.array_element(faker.definitions.name.title.descriptor),
level = faker.random.array_element(faker.definitions.name.title.level),
job = faker.random.array_element(faker.definitions.name.title.job);

return descriptor + " " + level + " " + job;
}

};

module.exports = _name;

0 comments on commit 685b641

Please sign in to comment.