legacy-context-traversal.js 888 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. var ContextTraversal = require('power-assert-context-traversal');
  3. var inherits = require('util').inherits;
  4. var slice = Array.prototype.slice;
  5. function LegacyContextTraversal (powerAssertContext) {
  6. ContextTraversal.call(this, powerAssertContext);
  7. }
  8. inherits(LegacyContextTraversal, ContextTraversal);
  9. LegacyContextTraversal.prototype.setWritable = function (writer) {
  10. this.writer = writer;
  11. };
  12. LegacyContextTraversal.prototype.on = function () {
  13. var args = slice.apply(arguments);
  14. if (args[0] === 'render') {
  15. args[0] = 'end';
  16. }
  17. ContextTraversal.prototype.on.apply(this, args);
  18. };
  19. LegacyContextTraversal.prototype.emit = function () {
  20. var args = slice.apply(arguments);
  21. if (args[0] === 'end') {
  22. args[1] = this.writer;
  23. }
  24. ContextTraversal.prototype.emit.apply(this, args);
  25. };
  26. module.exports = LegacyContextTraversal;