Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

make_warning.js 710B

1234567891011121314151617181920212223
  1. var util = require("util")
  2. var messages = require("./warning_messages.json")
  3. module.exports = function() {
  4. var args = Array.prototype.slice.call(arguments, 0)
  5. var warningName = args.shift()
  6. if (warningName == "typo") {
  7. return makeTypoWarning.apply(null,args)
  8. }
  9. else {
  10. var msgTemplate = messages[warningName] ? messages[warningName] : warningName + ": '%s'"
  11. args.unshift(msgTemplate)
  12. return util.format.apply(null, args)
  13. }
  14. }
  15. function makeTypoWarning (providedName, probableName, field) {
  16. if (field) {
  17. providedName = field + "['" + providedName + "']"
  18. probableName = field + "['" + probableName + "']"
  19. }
  20. return util.format(messages.typo, providedName, probableName)
  21. }