a zip code crypto-currency system good for red ONLY

index.js 761B

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. var KEYWORDS = require('./keywords');
  3. module.exports = defineKeywords;
  4. /**
  5. * Defines one or several keywords in ajv instance
  6. * @param {Ajv} ajv validator instance
  7. * @param {String|Array<String>|undefined} keyword keyword(s) to define
  8. * @return {Ajv} ajv instance (for chaining)
  9. */
  10. function defineKeywords(ajv, keyword) {
  11. if (Array.isArray(keyword)) {
  12. for (var i=0; i<keyword.length; i++)
  13. get(keyword[i])(ajv);
  14. return ajv;
  15. }
  16. if (keyword) {
  17. get(keyword)(ajv);
  18. return ajv;
  19. }
  20. for (keyword in KEYWORDS) get(keyword)(ajv);
  21. return ajv;
  22. }
  23. defineKeywords.get = get;
  24. function get(keyword) {
  25. var defFunc = KEYWORDS[keyword];
  26. if (!defFunc) throw new Error('Unknown keyword ' + keyword);
  27. return defFunc;
  28. }