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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use strict";
  2. function dedent(strings) {
  3. var raw = void 0;
  4. if (typeof strings === "string") {
  5. // dedent can be used as a plain function
  6. raw = [strings];
  7. } else {
  8. raw = strings.raw;
  9. }
  10. // first, perform interpolation
  11. var result = "";
  12. for (var i = 0; i < raw.length; i++) {
  13. result += raw[i].
  14. // join lines when there is a suppressed newline
  15. replace(/\\\n[ \t]*/g, "").
  16. // handle escaped backticks
  17. replace(/\\`/g, "`");
  18. if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
  19. result += arguments.length <= i + 1 ? undefined : arguments[i + 1];
  20. }
  21. }
  22. // now strip indentation
  23. var lines = result.split("\n");
  24. var mindent = null;
  25. lines.forEach(function (l) {
  26. var m = l.match(/^(\s+)\S+/);
  27. if (m) {
  28. var indent = m[1].length;
  29. if (!mindent) {
  30. // this is the first indented line
  31. mindent = indent;
  32. } else {
  33. mindent = Math.min(mindent, indent);
  34. }
  35. }
  36. });
  37. if (mindent !== null) {
  38. result = lines.map(function (l) {
  39. return l[0] === " " ? l.slice(mindent) : l;
  40. }).join("\n");
  41. }
  42. // dedent eats leading and trailing whitespace too
  43. result = result.trim();
  44. // handle escaped newlines at the end to ensure they don't get stripped too
  45. return result.replace(/\\n/g, "\n");
  46. }
  47. if (typeof module !== "undefined") {
  48. module.exports = dedent;
  49. }