.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / node_modules / table / dist / wrapString.js
1 'use strict';
2
3 Object.defineProperty(exports, "__esModule", {
4   value: true
5 });
6
7 var _sliceAnsi = require('slice-ansi');
8
9 var _sliceAnsi2 = _interopRequireDefault(_sliceAnsi);
10
11 var _stringWidth = require('string-width');
12
13 var _stringWidth2 = _interopRequireDefault(_stringWidth);
14
15 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17 /**
18  * Creates an array of strings split into groups the length of size.
19  * This function works with strings that contain ASCII characters.
20  *
21  * wrapText is different from would-be "chunk" implementation
22  * in that whitespace characters that occur on a chunk size limit are trimmed.
23  *
24  * @param {string} subject
25  * @param {number} size
26  * @returns {Array}
27  */
28 exports.default = (subject, size) => {
29   let subjectSlice;
30
31   subjectSlice = subject;
32
33   const chunks = [];
34
35   do {
36     chunks.push((0, _sliceAnsi2.default)(subjectSlice, 0, size));
37
38     subjectSlice = (0, _sliceAnsi2.default)(subjectSlice, size).trim();
39   } while ((0, _stringWidth2.default)(subjectSlice));
40
41   return chunks;
42 };