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

index.js 553B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. const restoreCursor = require('restore-cursor');
  3. let hidden = false;
  4. exports.show = stream => {
  5. const s = stream || process.stderr;
  6. if (!s.isTTY) {
  7. return;
  8. }
  9. hidden = false;
  10. s.write('\u001b[?25h');
  11. };
  12. exports.hide = stream => {
  13. const s = stream || process.stderr;
  14. if (!s.isTTY) {
  15. return;
  16. }
  17. restoreCursor();
  18. hidden = true;
  19. s.write('\u001b[?25l');
  20. };
  21. exports.toggle = (force, stream) => {
  22. if (force !== undefined) {
  23. hidden = force;
  24. }
  25. if (hidden) {
  26. exports.show(stream);
  27. } else {
  28. exports.hide(stream);
  29. }
  30. };