table 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -138
- package/dist/calculateCellWidthIndex.js +3 -1
- package/dist/calculateCellWidthIndex.js.flow +5 -1
- package/dist/calculateCellWidthIndex.js.map +1 -1
- package/dist/validateTableData.js +2 -4
- package/dist/validateTableData.js.flow +1 -3
- package/dist/validateTableData.js.map +1 -1
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
* [Table](#table)
|
|
11
11
|
* [Features](#table-features)
|
|
12
|
+
* [Install](#table-install)
|
|
12
13
|
* [Usage](#table-usage)
|
|
13
14
|
* [Cell Content Alignment](#table-usage-cell-content-alignment)
|
|
14
15
|
* [Column Width](#table-usage-column-width)
|
|
@@ -36,6 +37,17 @@ Produces a string that represents array data in a text table.
|
|
|
36
37
|
* Configurable column width.
|
|
37
38
|
* Text wrapping.
|
|
38
39
|
|
|
40
|
+
<a name="table-install"></a>
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install table
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
[](https://www.buymeacoffee.com/gajus)
|
|
49
|
+
[](https://www.patreon.com/gajus)
|
|
50
|
+
|
|
39
51
|
<a name="table-usage"></a>
|
|
40
52
|
## Usage
|
|
41
53
|
|
|
@@ -132,6 +144,7 @@ console.log(output);
|
|
|
132
144
|
╟────┼────┼────╢
|
|
133
145
|
║ 2A │ 2B │ 2C ║
|
|
134
146
|
╚════╧════╧════╝
|
|
147
|
+
|
|
135
148
|
```
|
|
136
149
|
|
|
137
150
|
|
|
@@ -144,30 +157,30 @@ Valid values are: "left", "right" and "center".
|
|
|
144
157
|
|
|
145
158
|
```js
|
|
146
159
|
let config,
|
|
147
|
-
|
|
148
|
-
|
|
160
|
+
data,
|
|
161
|
+
output;
|
|
149
162
|
|
|
150
163
|
data = [
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
164
|
+
['0A', '0B', '0C'],
|
|
165
|
+
['1A', '1B', '1C'],
|
|
166
|
+
['2A', '2B', '2C']
|
|
154
167
|
];
|
|
155
168
|
|
|
156
169
|
config = {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
+
columns: {
|
|
171
|
+
0: {
|
|
172
|
+
alignment: 'left',
|
|
173
|
+
minWidth: 10
|
|
174
|
+
},
|
|
175
|
+
1: {
|
|
176
|
+
alignment: 'center',
|
|
177
|
+
minWidth: 10
|
|
178
|
+
},
|
|
179
|
+
2: {
|
|
180
|
+
alignment: 'right',
|
|
181
|
+
minWidth: 10
|
|
170
182
|
}
|
|
183
|
+
}
|
|
171
184
|
};
|
|
172
185
|
|
|
173
186
|
output = table(data, config);
|
|
@@ -192,21 +205,21 @@ console.log(output);
|
|
|
192
205
|
|
|
193
206
|
```js
|
|
194
207
|
let data,
|
|
195
|
-
|
|
196
|
-
|
|
208
|
+
output,
|
|
209
|
+
options;
|
|
197
210
|
|
|
198
211
|
data = [
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
212
|
+
['0A', '0B', '0C'],
|
|
213
|
+
['1A', '1B', '1C'],
|
|
214
|
+
['2A', '2B', '2C']
|
|
202
215
|
];
|
|
203
216
|
|
|
204
217
|
options = {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
218
|
+
columns: {
|
|
219
|
+
1: {
|
|
220
|
+
width: 10
|
|
209
221
|
}
|
|
222
|
+
}
|
|
210
223
|
};
|
|
211
224
|
|
|
212
225
|
output = table(data, options);
|
|
@@ -231,36 +244,36 @@ console.log(output);
|
|
|
231
244
|
|
|
232
245
|
```js
|
|
233
246
|
let config,
|
|
234
|
-
|
|
235
|
-
|
|
247
|
+
data,
|
|
248
|
+
output;
|
|
236
249
|
|
|
237
250
|
data = [
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
251
|
+
['0A', '0B', '0C'],
|
|
252
|
+
['1A', '1B', '1C'],
|
|
253
|
+
['2A', '2B', '2C']
|
|
241
254
|
];
|
|
242
255
|
|
|
243
256
|
config = {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
257
|
+
border: {
|
|
258
|
+
topBody: `─`,
|
|
259
|
+
topJoin: `┬`,
|
|
260
|
+
topLeft: `┌`,
|
|
261
|
+
topRight: `┐`,
|
|
262
|
+
|
|
263
|
+
bottomBody: `─`,
|
|
264
|
+
bottomJoin: `┴`,
|
|
265
|
+
bottomLeft: `└`,
|
|
266
|
+
bottomRight: `┘`,
|
|
267
|
+
|
|
268
|
+
bodyLeft: `│`,
|
|
269
|
+
bodyRight: `│`,
|
|
270
|
+
bodyJoin: `│`,
|
|
271
|
+
|
|
272
|
+
joinBody: `─`,
|
|
273
|
+
joinLeft: `├`,
|
|
274
|
+
joinRight: `┤`,
|
|
275
|
+
joinJoin: `┼`
|
|
276
|
+
}
|
|
264
277
|
};
|
|
265
278
|
|
|
266
279
|
output = table(data, config);
|
|
@@ -285,27 +298,27 @@ console.log(output);
|
|
|
285
298
|
|
|
286
299
|
```js
|
|
287
300
|
let data,
|
|
288
|
-
|
|
289
|
-
|
|
301
|
+
output,
|
|
302
|
+
options;
|
|
290
303
|
|
|
291
304
|
data = [
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
305
|
+
['0A', '0B', '0C'],
|
|
306
|
+
['1A', '1B', '1C'],
|
|
307
|
+
['2A', '2B', '2C'],
|
|
308
|
+
['3A', '3B', '3C'],
|
|
309
|
+
['4A', '4B', '4C']
|
|
297
310
|
];
|
|
298
311
|
|
|
299
312
|
options = {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
313
|
+
/**
|
|
314
|
+
* @typedef {function} drawHorizontalLine
|
|
315
|
+
* @param {number} index
|
|
316
|
+
* @param {number} size
|
|
317
|
+
* @return {boolean}
|
|
318
|
+
*/
|
|
319
|
+
drawHorizontalLine: (index, size) => {
|
|
320
|
+
return index === 0 || index === 1 || index === size - 1 || index === size;
|
|
321
|
+
}
|
|
309
322
|
};
|
|
310
323
|
|
|
311
324
|
output = table(data, options);
|
|
@@ -334,25 +347,25 @@ console.log(output);
|
|
|
334
347
|
|
|
335
348
|
```js
|
|
336
349
|
let config,
|
|
337
|
-
|
|
338
|
-
|
|
350
|
+
data,
|
|
351
|
+
output;
|
|
339
352
|
|
|
340
353
|
data = [
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
354
|
+
['0A', 'AABBCC', '0C'],
|
|
355
|
+
['1A', '1B', '1C'],
|
|
356
|
+
['2A', '2B', '2C']
|
|
344
357
|
];
|
|
345
358
|
|
|
346
359
|
config = {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
360
|
+
columns: {
|
|
361
|
+
0: {
|
|
362
|
+
paddingLeft: 3
|
|
363
|
+
},
|
|
364
|
+
1: {
|
|
365
|
+
width: 2,
|
|
366
|
+
paddingRight: 3
|
|
355
367
|
}
|
|
368
|
+
}
|
|
356
369
|
};
|
|
357
370
|
|
|
358
371
|
output = table(data, config);
|
|
@@ -379,21 +392,21 @@ You can load one of the predefined border templates using `getBorderCharacters`
|
|
|
379
392
|
|
|
380
393
|
```js
|
|
381
394
|
import {
|
|
382
|
-
|
|
383
|
-
|
|
395
|
+
table,
|
|
396
|
+
getBorderCharacters
|
|
384
397
|
} from 'table';
|
|
385
398
|
|
|
386
399
|
let config,
|
|
387
|
-
|
|
400
|
+
data;
|
|
388
401
|
|
|
389
402
|
data = [
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
403
|
+
['0A', '0B', '0C'],
|
|
404
|
+
['1A', '1B', '1C'],
|
|
405
|
+
['2A', '2B', '2C']
|
|
393
406
|
];
|
|
394
407
|
|
|
395
408
|
config = {
|
|
396
|
-
|
|
409
|
+
border: getBorderCharacters(`name of the template`)
|
|
397
410
|
};
|
|
398
411
|
|
|
399
412
|
table(data, config);
|
|
@@ -481,23 +494,23 @@ console.log(output);
|
|
|
481
494
|
|
|
482
495
|
```js
|
|
483
496
|
import {
|
|
484
|
-
|
|
497
|
+
createStream
|
|
485
498
|
} from 'table';
|
|
486
499
|
|
|
487
500
|
let config,
|
|
488
|
-
|
|
501
|
+
stream;
|
|
489
502
|
|
|
490
503
|
config = {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
504
|
+
columnDefault: {
|
|
505
|
+
width: 50
|
|
506
|
+
},
|
|
507
|
+
columnCount: 1
|
|
495
508
|
};
|
|
496
509
|
|
|
497
510
|
stream = createStream(config);
|
|
498
511
|
|
|
499
512
|
setInterval(() => {
|
|
500
|
-
|
|
513
|
+
stream.write([new Date()]);
|
|
501
514
|
}, 500);
|
|
502
515
|
```
|
|
503
516
|
|
|
@@ -505,38 +518,38 @@ setInterval(() => {
|
|
|
505
518
|
|
|
506
519
|
`table` package uses ANSI escape codes to overwrite the output of the last line when a new row is printed.
|
|
507
520
|
|
|
508
|
-
The underlying implementation is explained in this [Stack Overflow answer](http://stackoverflow.com/a/32938658/368691).
|
|
521
|
+
The underlying implementation is explained in this [Stack Overflow answer](http://stackoverflow.com/a/32938658/368691).
|
|
509
522
|
|
|
510
523
|
Streaming supports all of the configuration properties and functionality of a static table (such as auto text wrapping, alignment and padding), e.g.
|
|
511
524
|
|
|
512
525
|
```js
|
|
513
526
|
import {
|
|
514
|
-
|
|
527
|
+
createStream
|
|
515
528
|
} from 'table';
|
|
516
529
|
|
|
517
530
|
import _ from 'lodash';
|
|
518
531
|
|
|
519
532
|
let config,
|
|
520
|
-
|
|
521
|
-
|
|
533
|
+
stream,
|
|
534
|
+
i;
|
|
522
535
|
|
|
523
536
|
config = {
|
|
524
|
-
|
|
525
|
-
|
|
537
|
+
columnDefault: {
|
|
538
|
+
width: 50
|
|
539
|
+
},
|
|
540
|
+
columnCount: 3,
|
|
541
|
+
columns: {
|
|
542
|
+
0: {
|
|
543
|
+
width: 10,
|
|
544
|
+
alignment: 'right'
|
|
545
|
+
},
|
|
546
|
+
1: {
|
|
547
|
+
alignment: 'center',
|
|
526
548
|
},
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
0: {
|
|
530
|
-
width: 10,
|
|
531
|
-
alignment: 'right'
|
|
532
|
-
},
|
|
533
|
-
1: {
|
|
534
|
-
alignment: 'center',
|
|
535
|
-
},
|
|
536
|
-
2: {
|
|
537
|
-
width: 10
|
|
538
|
-
}
|
|
549
|
+
2: {
|
|
550
|
+
width: 10
|
|
539
551
|
}
|
|
552
|
+
}
|
|
540
553
|
};
|
|
541
554
|
|
|
542
555
|
stream = createStream(config);
|
|
@@ -544,15 +557,16 @@ stream = createStream(config);
|
|
|
544
557
|
i = 0;
|
|
545
558
|
|
|
546
559
|
setInterval(() => {
|
|
547
|
-
|
|
560
|
+
let random;
|
|
548
561
|
|
|
549
|
-
|
|
562
|
+
random = _.sample('abcdefghijklmnopqrstuvwxyz', _.random(1, 30)).join('');
|
|
550
563
|
|
|
551
|
-
|
|
564
|
+
stream.write([i++, new Date(), random]);
|
|
552
565
|
}, 500);
|
|
553
566
|
```
|
|
554
567
|
|
|
555
568
|

|
|
569
|
+
|
|
556
570
|
<a name="table-usage-text-truncation"></a>
|
|
557
571
|
### Text Truncation
|
|
558
572
|
|
|
@@ -562,20 +576,20 @@ To handle a content that overflows the container width, `table` package implemen
|
|
|
562
576
|
|
|
563
577
|
```js
|
|
564
578
|
let config,
|
|
565
|
-
|
|
566
|
-
|
|
579
|
+
data,
|
|
580
|
+
output;
|
|
567
581
|
|
|
568
582
|
data = [
|
|
569
|
-
|
|
583
|
+
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
|
570
584
|
];
|
|
571
585
|
|
|
572
586
|
config = {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
587
|
+
columns: {
|
|
588
|
+
0: {
|
|
589
|
+
width: 20,
|
|
590
|
+
truncate: 100
|
|
578
591
|
}
|
|
592
|
+
}
|
|
579
593
|
};
|
|
580
594
|
|
|
581
595
|
output = table(data, config);
|
|
@@ -600,19 +614,19 @@ console.log(output);
|
|
|
600
614
|
|
|
601
615
|
```js
|
|
602
616
|
let config,
|
|
603
|
-
|
|
604
|
-
|
|
617
|
+
data,
|
|
618
|
+
output;
|
|
605
619
|
|
|
606
620
|
data = [
|
|
607
621
|
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
|
608
622
|
];
|
|
609
623
|
|
|
610
624
|
config = {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
625
|
+
columns: {
|
|
626
|
+
0: {
|
|
627
|
+
width: 20
|
|
615
628
|
}
|
|
629
|
+
}
|
|
616
630
|
};
|
|
617
631
|
|
|
618
632
|
output = table(data, config);
|
|
@@ -637,20 +651,20 @@ When `wrapWord` is `true` the text is broken at the nearest space or one of the
|
|
|
637
651
|
|
|
638
652
|
```js
|
|
639
653
|
let config,
|
|
640
|
-
|
|
641
|
-
|
|
654
|
+
data,
|
|
655
|
+
output;
|
|
642
656
|
|
|
643
657
|
data = [
|
|
644
|
-
|
|
658
|
+
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
|
645
659
|
];
|
|
646
660
|
|
|
647
661
|
config = {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
}
|
|
662
|
+
columns: {
|
|
663
|
+
0: {
|
|
664
|
+
width: 20,
|
|
665
|
+
wrapWord: true
|
|
653
666
|
}
|
|
667
|
+
}
|
|
654
668
|
};
|
|
655
669
|
|
|
656
670
|
output = table(data, config);
|
|
@@ -671,5 +685,6 @@ console.log(output);
|
|
|
671
685
|
║ tempus nulla sit ║
|
|
672
686
|
║ amet viverra. ║
|
|
673
687
|
╚══════════════════════╝
|
|
688
|
+
|
|
674
689
|
```
|
|
675
690
|
|
|
@@ -17,7 +17,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
17
|
*/
|
|
18
18
|
const calculateCellWidthIndex = cells => {
|
|
19
19
|
return cells.map(value => {
|
|
20
|
-
return (
|
|
20
|
+
return Math.max(...value.split('\n').map(line => {
|
|
21
|
+
return (0, _stringWidth.default)(line);
|
|
22
|
+
}));
|
|
21
23
|
});
|
|
22
24
|
};
|
|
23
25
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/calculateCellWidthIndex.js"],"names":["cells","map","value"],"mappings":";;;;;;;AAAA;;;;AAEA;;;;;;gCAMgBA,K,IAAU;AACxB,SAAOA,KAAK,CAACC,GAAN,CAAWC,KAAD,IAAW;AAC1B,
|
|
1
|
+
{"version":3,"sources":["../src/calculateCellWidthIndex.js"],"names":["cells","map","value","Math","max","split","line"],"mappings":";;;;;;;AAAA;;;;AAEA;;;;;;gCAMgBA,K,IAAU;AACxB,SAAOA,KAAK,CAACC,GAAN,CAAWC,KAAD,IAAW;AAC1B,WAAOC,IAAI,CAACC,GAAL,CACL,GAAGF,KAAK,CAACG,KAAN,CAAY,IAAZ,EAAkBJ,GAAlB,CAAuBK,IAAD,IAAU;AACjC,aAAO,0BAAYA,IAAZ,CAAP;AACD,KAFE,CADE,CAAP;AAKD,GANM,CAAP;AAOD,C","sourcesContent":["import stringWidth from 'string-width';\n\n/**\n * Calculates width of each cell contents.\n *\n * @param {string[]} cells\n * @returns {number[]}\n */\nexport default (cells) => {\n return cells.map((value) => {\n return Math.max(\n ...value.split('\\n').map((line) => {\n return stringWidth(line);\n })\n );\n });\n};\n"],"file":"calculateCellWidthIndex.js"}
|
|
@@ -45,9 +45,7 @@ const validateTableData = rows => {
|
|
|
45
45
|
|
|
46
46
|
if (cells.length !== columnNumber) {
|
|
47
47
|
throw new Error('Table must have a consistent number of cells.');
|
|
48
|
-
}
|
|
49
|
-
// @see https://github.com/gajus/table/issues/9
|
|
50
|
-
|
|
48
|
+
}
|
|
51
49
|
|
|
52
50
|
var _iteratorNormalCompletion2 = true;
|
|
53
51
|
var _didIteratorError2 = false;
|
|
@@ -58,7 +56,7 @@ const validateTableData = rows => {
|
|
|
58
56
|
const cell = _step2.value;
|
|
59
57
|
|
|
60
58
|
// eslint-disable-next-line no-control-regex
|
|
61
|
-
if (/[\u0001-\u001A]/.test(cell)) {
|
|
59
|
+
if (/[\u0001-\u0006\u0008-\u0009\u000B-\u001A]/.test(cell)) {
|
|
62
60
|
throw new Error('Table data must not contain control characters.');
|
|
63
61
|
}
|
|
64
62
|
}
|
|
@@ -34,11 +34,9 @@ export default (rows) => {
|
|
|
34
34
|
throw new Error('Table must have a consistent number of cells.');
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// @todo Make an exception for newline characters.
|
|
38
|
-
// @see https://github.com/gajus/table/issues/9
|
|
39
37
|
for (const cell of cells) {
|
|
40
38
|
// eslint-disable-next-line no-control-regex
|
|
41
|
-
if (/[\u0001-\u001A]/.test(cell)) {
|
|
39
|
+
if (/[\u0001-\u0006\u0008-\u0009\u000B-\u001A]/.test(cell)) {
|
|
42
40
|
throw new Error('Table data must not contain control characters.');
|
|
43
41
|
}
|
|
44
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/validateTableData.js"],"names":["rows","Array","isArray","TypeError","length","Error","columnNumber","cells","cell","test"],"mappings":";;;;;;;AAAA;;;;AAIA;;;;AAIA;;;;0BAIgBA,I,IAAS;AACvB,MAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,IAAd,CAAL,EAA0B;AACxB,UAAM,IAAIG,SAAJ,CAAc,8BAAd,CAAN;AACD;;AAED,MAAIH,IAAI,CAACI,MAAL,KAAgB,CAApB,EAAuB;AACrB,UAAM,IAAIC,KAAJ,CAAU,qCAAV,CAAN;AACD;;AAED,MAAIL,IAAI,CAAC,CAAD,CAAJ,CAAQI,MAAR,KAAmB,CAAvB,EAA0B;AACxB,UAAM,IAAIC,KAAJ,CAAU,wCAAV,CAAN;AACD;;AAED,QAAMC,YAAY,GAAGN,IAAI,CAAC,CAAD,CAAJ,CAAQI,MAA7B;AAbuB;AAAA;AAAA;;AAAA;AAevB,yBAAoBJ,IAApB,8HAA0B;AAAA,YAAfO,KAAe;;AACxB,UAAI,CAACN,KAAK,CAACC,OAAN,CAAcK,KAAd,CAAL,EAA2B;AACzB,cAAM,IAAIJ,SAAJ,CAAc,kCAAd,CAAN;AACD;;AAED,UAAII,KAAK,CAACH,MAAN,KAAiBE,YAArB,EAAmC;AACjC,cAAM,IAAID,KAAJ,CAAU,+CAAV,CAAN;AACD
|
|
1
|
+
{"version":3,"sources":["../src/validateTableData.js"],"names":["rows","Array","isArray","TypeError","length","Error","columnNumber","cells","cell","test"],"mappings":";;;;;;;AAAA;;;;AAIA;;;;AAIA;;;;0BAIgBA,I,IAAS;AACvB,MAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,IAAd,CAAL,EAA0B;AACxB,UAAM,IAAIG,SAAJ,CAAc,8BAAd,CAAN;AACD;;AAED,MAAIH,IAAI,CAACI,MAAL,KAAgB,CAApB,EAAuB;AACrB,UAAM,IAAIC,KAAJ,CAAU,qCAAV,CAAN;AACD;;AAED,MAAIL,IAAI,CAAC,CAAD,CAAJ,CAAQI,MAAR,KAAmB,CAAvB,EAA0B;AACxB,UAAM,IAAIC,KAAJ,CAAU,wCAAV,CAAN;AACD;;AAED,QAAMC,YAAY,GAAGN,IAAI,CAAC,CAAD,CAAJ,CAAQI,MAA7B;AAbuB;AAAA;AAAA;;AAAA;AAevB,yBAAoBJ,IAApB,8HAA0B;AAAA,YAAfO,KAAe;;AACxB,UAAI,CAACN,KAAK,CAACC,OAAN,CAAcK,KAAd,CAAL,EAA2B;AACzB,cAAM,IAAIJ,SAAJ,CAAc,kCAAd,CAAN;AACD;;AAED,UAAII,KAAK,CAACH,MAAN,KAAiBE,YAArB,EAAmC;AACjC,cAAM,IAAID,KAAJ,CAAU,+CAAV,CAAN;AACD;;AAPuB;AAAA;AAAA;;AAAA;AASxB,8BAAmBE,KAAnB,mIAA0B;AAAA,gBAAfC,IAAe;;AACxB;AACA,cAAI,4CAA4CC,IAA5C,CAAiDD,IAAjD,CAAJ,EAA4D;AAC1D,kBAAM,IAAIH,KAAJ,CAAU,iDAAV,CAAN;AACD;AACF;AAduB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAezB;AA9BsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BxB,C","sourcesContent":["/**\n * @typedef {string} cell\n */\n\n/**\n * @typedef {cell[]} validateData~column\n */\n\n/**\n * @param {column[]} rows\n * @returns {undefined}\n */\nexport default (rows) => {\n if (!Array.isArray(rows)) {\n throw new TypeError('Table data must be an array.');\n }\n\n if (rows.length === 0) {\n throw new Error('Table must define at least one row.');\n }\n\n if (rows[0].length === 0) {\n throw new Error('Table must define at least one column.');\n }\n\n const columnNumber = rows[0].length;\n\n for (const cells of rows) {\n if (!Array.isArray(cells)) {\n throw new TypeError('Table row data must be an array.');\n }\n\n if (cells.length !== columnNumber) {\n throw new Error('Table must have a consistent number of cells.');\n }\n\n for (const cell of cells) {\n // eslint-disable-next-line no-control-regex\n if (/[\\u0001-\\u0006\\u0008-\\u0009\\u000B-\\u001A]/.test(cell)) {\n throw new Error('Table data must not contain control characters.');\n }\n }\n }\n};\n"],"file":"validateTableData.js"}
|
package/package.json
CHANGED
|
@@ -5,36 +5,36 @@
|
|
|
5
5
|
"url": "http://gajus.com"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"ajv": "^6.
|
|
8
|
+
"ajv": "^6.9.1",
|
|
9
9
|
"lodash": "^4.17.11",
|
|
10
|
-
"slice-ansi": "2.
|
|
11
|
-
"string-width": "^
|
|
10
|
+
"slice-ansi": "^2.1.0",
|
|
11
|
+
"string-width": "^3.0.0"
|
|
12
12
|
},
|
|
13
13
|
"description": "Formats data into a string table.",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@babel/cli": "^7.
|
|
16
|
-
"@babel/core": "^7.
|
|
17
|
-
"@babel/node": "^7.
|
|
18
|
-
"@babel/plugin-transform-flow-strip-types": "^7.
|
|
19
|
-
"@babel/preset-env": "^7.1
|
|
15
|
+
"@babel/cli": "^7.2.3",
|
|
16
|
+
"@babel/core": "^7.2.2",
|
|
17
|
+
"@babel/node": "^7.2.2",
|
|
18
|
+
"@babel/plugin-transform-flow-strip-types": "^7.2.3",
|
|
19
|
+
"@babel/preset-env": "^7.3.1",
|
|
20
20
|
"@babel/register": "^7.0.0",
|
|
21
21
|
"ajv-cli": "^3.0.0",
|
|
22
|
-
"ajv-keywords": "^3.
|
|
22
|
+
"ajv-keywords": "^3.4.0",
|
|
23
23
|
"babel-plugin-istanbul": "^5.1.0",
|
|
24
24
|
"babel-plugin-transform-export-default-name": "^2.0.4",
|
|
25
25
|
"chai": "^4.2.0",
|
|
26
|
-
"chalk": "^2.4.
|
|
26
|
+
"chalk": "^2.4.2",
|
|
27
27
|
"coveralls": "^3.0.2",
|
|
28
|
-
"eslint": "^5.
|
|
29
|
-
"eslint-config-canonical": "^
|
|
30
|
-
"flow-bin": "^0.
|
|
28
|
+
"eslint": "^5.13.0",
|
|
29
|
+
"eslint-config-canonical": "^16.1.0",
|
|
30
|
+
"flow-bin": "^0.92.1",
|
|
31
31
|
"flow-copy-source": "^2.0.2",
|
|
32
|
-
"gitdown": "^2.5.
|
|
33
|
-
"husky": "^1.
|
|
32
|
+
"gitdown": "^2.5.7",
|
|
33
|
+
"husky": "^1.3.1",
|
|
34
34
|
"mocha": "^5.2.0",
|
|
35
|
-
"nyc": "^13.
|
|
36
|
-
"semantic-release": "^15.
|
|
37
|
-
"sinon": "^7.
|
|
35
|
+
"nyc": "^13.2.0",
|
|
36
|
+
"semantic-release": "^15.13.3",
|
|
37
|
+
"sinon": "^7.2.3"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=6.0.0"
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"lint": "npm run build && eslint ./src ./test && flow",
|
|
80
80
|
"test": "mocha --require @babel/register"
|
|
81
81
|
},
|
|
82
|
-
"version": "5.
|
|
82
|
+
"version": "5.3.0"
|
|
83
83
|
}
|