a zip code crypto-currency system good for red ONLY

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env node
  2. var request = require('request')
  3. , fs = require('fs')
  4. , uvheadloc = 'https://raw.github.com/joyent/libuv/master/include/uv.h'
  5. , defreg = /^\s*XX\(\s*([\-\d]+),\s*([A-Z]+),\s*"([^"]*)"\s*\)\s*\\?$/
  6. request(uvheadloc, function (err, response) {
  7. if (err)
  8. throw err
  9. var data, out
  10. data = response.body
  11. .split('\n')
  12. .map(function (line) { return line.match(defreg) })
  13. .filter(function (match) { return match })
  14. .map(function (match) { return {
  15. errno: parseInt(match[1], 10)
  16. , code: match[2]
  17. , description: match[3]
  18. }})
  19. out = 'var all = module.exports.all = ' + JSON.stringify(data, 0, 1) + '\n\n'
  20. out += '\nmodule.exports.errno = {\n '
  21. + data.map(function (e, i) {
  22. return '\'' + e.errno + '\': all[' + i + ']'
  23. }).join('\n , ')
  24. + '\n}\n\n'
  25. out += '\nmodule.exports.code = {\n '
  26. + data.map(function (e, i) {
  27. return '\'' + e.code + '\': all[' + i + ']'
  28. }).join('\n , ')
  29. + '\n}\n\n'
  30. out += '\nmodule.exports.custom = require("./custom")(module.exports)\n'
  31. fs.writeFile('errno.js', out)
  32. })