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

|
|
570
|
+
|
|
556
571
|
<a name="table-usage-text-truncation"></a>
|
|
557
572
|
### Text Truncation
|
|
558
573
|
|
|
@@ -562,20 +577,20 @@ To handle a content that overflows the container width, `table` package implemen
|
|
|
562
577
|
|
|
563
578
|
```js
|
|
564
579
|
let config,
|
|
565
|
-
|
|
566
|
-
|
|
580
|
+
data,
|
|
581
|
+
output;
|
|
567
582
|
|
|
568
583
|
data = [
|
|
569
|
-
|
|
584
|
+
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
|
570
585
|
];
|
|
571
586
|
|
|
572
587
|
config = {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
588
|
+
columns: {
|
|
589
|
+
0: {
|
|
590
|
+
width: 20,
|
|
591
|
+
truncate: 100
|
|
578
592
|
}
|
|
593
|
+
}
|
|
579
594
|
};
|
|
580
595
|
|
|
581
596
|
output = table(data, config);
|
|
@@ -600,19 +615,19 @@ console.log(output);
|
|
|
600
615
|
|
|
601
616
|
```js
|
|
602
617
|
let config,
|
|
603
|
-
|
|
604
|
-
|
|
618
|
+
data,
|
|
619
|
+
output;
|
|
605
620
|
|
|
606
621
|
data = [
|
|
607
622
|
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
|
608
623
|
];
|
|
609
624
|
|
|
610
625
|
config = {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
626
|
+
columns: {
|
|
627
|
+
0: {
|
|
628
|
+
width: 20
|
|
615
629
|
}
|
|
630
|
+
}
|
|
616
631
|
};
|
|
617
632
|
|
|
618
633
|
output = table(data, config);
|
|
@@ -637,20 +652,20 @@ When `wrapWord` is `true` the text is broken at the nearest space or one of the
|
|
|
637
652
|
|
|
638
653
|
```js
|
|
639
654
|
let config,
|
|
640
|
-
|
|
641
|
-
|
|
655
|
+
data,
|
|
656
|
+
output;
|
|
642
657
|
|
|
643
658
|
data = [
|
|
644
|
-
|
|
659
|
+
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
|
645
660
|
];
|
|
646
661
|
|
|
647
662
|
config = {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
}
|
|
663
|
+
columns: {
|
|
664
|
+
0: {
|
|
665
|
+
width: 20,
|
|
666
|
+
wrapWord: true
|
|
653
667
|
}
|
|
668
|
+
}
|
|
654
669
|
};
|
|
655
670
|
|
|
656
671
|
output = table(data, config);
|
|
@@ -671,5 +686,6 @@ console.log(output);
|
|
|
671
686
|
║ tempus nulla sit ║
|
|
672
687
|
║ amet viverra. ║
|
|
673
688
|
╚══════════════════════╝
|
|
689
|
+
|
|
674
690
|
```
|
|
675
691
|
|
|
@@ -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"}
|
|
@@ -56,7 +56,7 @@ const validateTableData = rows => {
|
|
|
56
56
|
const cell = _step2.value;
|
|
57
57
|
|
|
58
58
|
// eslint-disable-next-line no-control-regex
|
|
59
|
-
if (/[\u0001-\u0009\u000B-\u001A]/.test(cell)) {
|
|
59
|
+
if (/[\u0001-\u0006\u0008-\u0009\u000B-\u001A]/.test(cell)) {
|
|
60
60
|
throw new Error('Table data must not contain control characters.');
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -36,7 +36,7 @@ export default (rows) => {
|
|
|
36
36
|
|
|
37
37
|
for (const cell of cells) {
|
|
38
38
|
// eslint-disable-next-line no-control-regex
|
|
39
|
-
if (/[\u0001-\u0009\u000B-\u001A]/.test(cell)) {
|
|
39
|
+
if (/[\u0001-\u0006\u0008-\u0009\u000B-\u001A]/.test(cell)) {
|
|
40
40
|
throw new Error('Table data must not contain control characters.');
|
|
41
41
|
}
|
|
42
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;;AAPuB;AAAA;AAAA;;AAAA;AASxB,8BAAmBE,KAAnB,mIAA0B;AAAA,gBAAfC,IAAe;;AACxB;AACA,cAAI
|
|
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.2"
|
|
83
83
|
}
|