systems.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * systems.js
  3. * Generate the system compatibility table from JSON
  4. *
  5. * Copyright (C) 2017 Alyssa Rosenzweig
  6. * ALL RIGHTS REVERSED
  7. */
  8. const hw = JSON.parse(require("fs").readFileSync("systems.json").toString());
  9. const syms = {
  10. "true": "✓",
  11. "blob": "☠",
  12. "w blob": "☠",
  13. "s blob": "☠",
  14. "removable": "~"
  15. };
  16. SYM = symbol => syms[symbol] || symbol;
  17. const FIELD_WIDTH = 9;
  18. pad = field => (field + Array(FIELD_WIDTH + 1).join(' ')).slice(0, FIELD_WIDTH);
  19. const titles = ["System", "Year", "Weight", "Price", "Chipset", "USB", "Display", "Wi-Fi", "3D", "Video", "EC", "μ-code"];
  20. const flips = Array(titles.length + 1).join(Array(FIELD_WIDTH).join("-") + " ");
  21. console.log(titles.map(pad).join(""));
  22. console.log(flips);
  23. Object.keys(hw.systems).map(sys => {
  24. const s = hw.systems[sys];
  25. const chipset = hw.chipsets[s.chipset];
  26. const fields = [
  27. sys,
  28. s.year,
  29. s.weight.toString().slice(0, 4),
  30. s.price,
  31. s.chipset,
  32. SYM(chipset.usb),
  33. SYM(chipset.display),
  34. SYM(s.wifi),
  35. SYM(chipset["3d"]),
  36. SYM(chipset.video),
  37. SYM(s.ec),
  38. SYM(chipset.microcode)
  39. ];
  40. console.log(fields.map(pad).join(""));
  41. });