From f2f37f8ef531798f30d8010b6a30a0bbc68875f4 Mon Sep 17 00:00:00 2001 From: Richard Butler Date: Thu, 27 Jun 2013 14:10:58 +0100 Subject: Split male and female names into two groups --- scripts/import.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/import.js (limited to 'scripts') 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 -- cgit v1.2.3 From d40511ab3a92157b364bcd15362fff0769ebe6c6 Mon Sep 17 00:00:00 2001 From: Richard Butler Date: Thu, 27 Jun 2013 14:50:36 +0100 Subject: Pretty print names files --- scripts/import.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/import.js b/scripts/import.js index e2a3ba11..546915c2 100644 --- a/scripts/import.js +++ b/scripts/import.js @@ -14,7 +14,7 @@ function importNames( inputFile, outputFile ) { return name !== ""; }); - output = "module.exports = [ '" + names.join( "', '" ) + "' ];"; + output = "module.exports = [\n '" + names.join( "',\n '" ) + "'\n];\n"; fs.writeFileSync( __dirname + "/" + outputFile, output ); } -- cgit v1.2.3