aboutsummaryrefslogtreecommitdiff
path: root/scripts/import.js
diff options
context:
space:
mode:
authorRichard Butler <[email protected]>2013-06-27 14:10:58 +0100
committerRichard Butler <[email protected]>2013-06-27 14:10:58 +0100
commitf2f37f8ef531798f30d8010b6a30a0bbc68875f4 (patch)
tree3474af3e5eb94621f6c0def0759da0ad8b55b04c /scripts/import.js
parent1bd1d73d29222c4e2f52d63a4282345b63a324df (diff)
downloadfaker-f2f37f8ef531798f30d8010b6a30a0bbc68875f4.tar.xz
faker-f2f37f8ef531798f30d8010b6a30a0bbc68875f4.zip
Split male and female names into two groups
Diffstat (limited to 'scripts/import.js')
-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..e2a3ba11
--- /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 = [ '" + names.join( "', '" ) + "' ];";
+
+ 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