index.js 897 B

12345678910111213141516171819202122232425262728293031323334
  1. var mdnProperties = require('mdn-data/css/properties.json');
  2. var mdnSyntaxes = require('mdn-data/css/syntaxes.json');
  3. var patch = require('./patch.json');
  4. function buildDictionary(dict, patchDict) {
  5. var result = {};
  6. // copy all syntaxes for an original dict
  7. for (var key in dict) {
  8. result[key] = dict[key].syntax;
  9. }
  10. // apply a patch
  11. for (var key in patchDict) {
  12. if (key in dict) {
  13. if (patchDict[key].syntax) {
  14. result[key] = patchDict[key].syntax;
  15. } else {
  16. delete result[key];
  17. }
  18. } else {
  19. if (patchDict[key].syntax) {
  20. result[key] = patchDict[key].syntax;
  21. }
  22. }
  23. }
  24. return result;
  25. }
  26. module.exports = {
  27. properties: buildDictionary(mdnProperties, patch.properties),
  28. types: buildDictionary(mdnSyntaxes, patch.syntaxes)
  29. };