1 orig_file = 'wordlist.txt'
2 compressed_file = 'wordlist_compressed.js'
3 caps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
6 fs.readFile orig_file, 'utf8', (err, data) ->
8 console.log "Error reading #{orig_file}: #{err}"
11 fs.writeFile compressed_file, (compress data.split '\n'), (err) ->
13 console.log "Error writing to #{compressed_file}: #{err}"
17 out = 'parse_word_list(['
22 while match and next.substr(0, match) isnt prev.substr(0, match)
24 # now match is the number of prefix characters this word has in common with the previous
25 chunk += caps[prev.length - match]
26 if chunk.length > 2000
27 out += "'" + chunk.substr(1) + "',"
29 chunk += next.substr match
31 return out + "'" + chunk.substr(1) + "']);"