Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

clear.js 489B

12345678910111213141516171819202122
  1. 'use strict';
  2. const strip = require('./strip');
  3. const { erase, cursor } = require('sisteransi');
  4. const width = str => [...strip(str)].length;
  5. /**
  6. * @param {string} prompt
  7. * @param {number} perLine
  8. */
  9. module.exports = function(prompt, perLine) {
  10. if (!perLine) return erase.line + cursor.to(0);
  11. let rows = 0;
  12. const lines = prompt.split(/\r?\n/);
  13. for (let line of lines) {
  14. rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
  15. }
  16. return erase.lines(rows);
  17. };