a zip code crypto-currency system good for red ONLY

ContextDependency.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const Dependency = require("../Dependency");
  7. const CriticalDependencyWarning = require("./CriticalDependencyWarning");
  8. class ContextDependency extends Dependency {
  9. constructor(request, recursive, regExp) {
  10. super();
  11. this.request = request;
  12. this.userRequest = request;
  13. this.recursive = recursive;
  14. this.regExp = regExp;
  15. this.async = false;
  16. this.hadGlobalOrStickyRegExp = false;
  17. if(this.regExp.global || this.regExp.sticky) {
  18. this.regExp = null;
  19. this.hadGlobalOrStickyRegExp = true;
  20. }
  21. }
  22. isEqualResource(other) {
  23. if(!(other instanceof ContextDependency))
  24. return false;
  25. return this.request === other.request &&
  26. this.recursive === other.recursive &&
  27. this.regExp === other.regExp &&
  28. this.async === other.async;
  29. }
  30. getWarnings() {
  31. let warnings = super.getWarnings() || [];
  32. if(this.critical) {
  33. warnings.push(new CriticalDependencyWarning(this.critical));
  34. }
  35. if(this.hadGlobalOrStickyRegExp) {
  36. warnings.push(new CriticalDependencyWarning("Contexts can't use RegExps with the 'g' or 'y' flags."));
  37. }
  38. return warnings;
  39. }
  40. }
  41. module.exports = ContextDependency;