aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJay Liu <[email protected]>2013-11-05 17:58:00 -0800
committerJay Liu <[email protected]>2013-11-05 17:58:00 -0800
commite7aaa93c306fe9c7f0b662ff68f0a36426605283 (patch)
treef373350960a664327e0991926083b6dfc430578f /scripts
parentb17d651e90aaef0416fb632844b46dfcdb6c46f2 (diff)
parentd40511ab3a92157b364bcd15362fff0769ebe6c6 (diff)
downloadfaker-e7aaa93c306fe9c7f0b662ff68f0a36426605283.tar.xz
faker-e7aaa93c306fe9c7f0b662ff68f0a36426605283.zip
Merge pull request #1 from richardbutler/master
Split male and female names to two groups; add random gender
Diffstat (limited to 'scripts')
-rw-r--r--scripts/import.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/import.js b/scripts/import.js
new file mode 100644
index 00000000..546915c2
--- /dev/null
+++ b/scripts/import.js
@@ -0,0 +1,23 @@
+var fs = require( "fs" );
+
+function importNames( inputFile, outputFile ) {
+ var input = fs.readFileSync( __dirname + "/" + inputFile ),
+ names = String( input ).split( "\n" ),
+ output;
+
+ names = names
+ .map( function( name ) {
+ name = name.trim();
+ name = name.charAt( 0 ).toUpperCase() + name.substr( 1 ).toLowerCase();
+ return name;
+ }).filter( function( name ) {
+ return name !== "";
+ });
+
+ output = "module.exports = [\n '" + names.join( "',\n '" ) + "'\n];\n";
+
+ fs.writeFileSync( __dirname + "/" + outputFile, output );
+}
+
+importNames( "../data/male-names.txt", "../lib/male_names.js" );
+importNames( "../data/female-names.txt", "../lib/female_names.js" ); \ No newline at end of file