web 3d图形渲染器
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.

13 lines
326 B

  1. 'use strict';
  2. const strip = require('./strip');
  3. /**
  4. * @param {string} msg
  5. * @param {number} perLine
  6. */
  7. module.exports = function (msg, perLine) {
  8. let lines = String(strip(msg) || '').split(/\r?\n/);
  9. if (!perLine) return lines.length;
  10. return lines.map(l => Math.ceil(l.length / perLine)).reduce((a, b) => a + b);
  11. };