Ohm-Management - Projektarbeit B-ME
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.

wrapString.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _sliceAnsi = _interopRequireDefault(require("slice-ansi"));
  7. var _stringWidth = _interopRequireDefault(require("string-width"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * Creates an array of strings split into groups the length of size.
  11. * This function works with strings that contain ASCII characters.
  12. *
  13. * wrapText is different from would-be "chunk" implementation
  14. * in that whitespace characters that occur on a chunk size limit are trimmed.
  15. *
  16. * @param {string} subject
  17. * @param {number} size
  18. * @returns {Array}
  19. */
  20. const wrapString = (subject, size) => {
  21. let subjectSlice;
  22. subjectSlice = subject;
  23. const chunks = [];
  24. do {
  25. chunks.push((0, _sliceAnsi.default)(subjectSlice, 0, size));
  26. subjectSlice = (0, _sliceAnsi.default)(subjectSlice, size).trim();
  27. } while ((0, _stringWidth.default)(subjectSlice));
  28. return chunks;
  29. };
  30. var _default = wrapString;
  31. exports.default = _default;
  32. //# sourceMappingURL=wrapString.js.map