table 3.8.2 → 3.8.3

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.
@@ -4,759 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_x1qtw309s = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/alignString.js',
9
- hash = '4739a846b3e706274c1282ad93f4da2a2e3aebc9',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/alignString.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 4,
18
- column: 19
19
- },
20
- end: {
21
- line: 8,
22
- column: 1
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 15,
28
- column: 18
29
- },
30
- end: {
31
- line: 17,
32
- column: 1
33
- }
34
- },
35
- '2': {
36
- start: {
37
- line: 16,
38
- column: 2
39
- },
40
- end: {
41
- line: 16,
42
- column: 40
43
- }
44
- },
45
- '3': {
46
- start: {
47
- line: 24,
48
- column: 19
49
- },
50
- end: {
51
- line: 26,
52
- column: 1
53
- }
54
- },
55
- '4': {
56
- start: {
57
- line: 25,
58
- column: 2
59
- },
60
- end: {
61
- line: 25,
62
- column: 40
63
- }
64
- },
65
- '5': {
66
- start: {
67
- line: 33,
68
- column: 20
69
- },
70
- end: {
71
- line: 45,
72
- column: 1
73
- }
74
- },
75
- '6': {
76
- start: {
77
- line: 36,
78
- column: 2
79
- },
80
- end: {
81
- line: 36,
82
- column: 24
83
- }
84
- },
85
- '7': {
86
- start: {
87
- line: 38,
88
- column: 2
89
- },
90
- end: {
91
- line: 44,
92
- column: 3
93
- }
94
- },
95
- '8': {
96
- start: {
97
- line: 39,
98
- column: 4
99
- },
100
- end: {
101
- line: 39,
102
- column: 73
103
- }
104
- },
105
- '9': {
106
- start: {
107
- line: 41,
108
- column: 4
109
- },
110
- end: {
111
- line: 41,
112
- column: 35
113
- }
114
- },
115
- '10': {
116
- start: {
117
- line: 43,
118
- column: 4
119
- },
120
- end: {
121
- line: 43,
122
- column: 77
123
- }
124
- },
125
- '11': {
126
- start: {
127
- line: 57,
128
- column: 2
129
- },
130
- end: {
131
- line: 59,
132
- column: 3
133
- }
134
- },
135
- '12': {
136
- start: {
137
- line: 58,
138
- column: 4
139
- },
140
- end: {
141
- line: 58,
142
- column: 65
143
- }
144
- },
145
- '13': {
146
- start: {
147
- line: 61,
148
- column: 2
149
- },
150
- end: {
151
- line: 63,
152
- column: 3
153
- }
154
- },
155
- '14': {
156
- start: {
157
- line: 62,
158
- column: 4
159
- },
160
- end: {
161
- line: 62,
162
- column: 73
163
- }
164
- },
165
- '15': {
166
- start: {
167
- line: 65,
168
- column: 23
169
- },
170
- end: {
171
- line: 65,
172
- column: 43
173
- }
174
- },
175
- '16': {
176
- start: {
177
- line: 67,
178
- column: 2
179
- },
180
- end: {
181
- line: 71,
182
- column: 3
183
- }
184
- },
185
- '17': {
186
- start: {
187
- line: 70,
188
- column: 4
189
- },
190
- end: {
191
- line: 70,
192
- column: 97
193
- }
194
- },
195
- '18': {
196
- start: {
197
- line: 73,
198
- column: 2
199
- },
200
- end: {
201
- line: 75,
202
- column: 3
203
- }
204
- },
205
- '19': {
206
- start: {
207
- line: 74,
208
- column: 4
209
- },
210
- end: {
211
- line: 74,
212
- column: 67
213
- }
214
- },
215
- '20': {
216
- start: {
217
- line: 77,
218
- column: 2
219
- },
220
- end: {
221
- line: 79,
222
- column: 3
223
- }
224
- },
225
- '21': {
226
- start: {
227
- line: 78,
228
- column: 4
229
- },
230
- end: {
231
- line: 78,
232
- column: 114
233
- }
234
- },
235
- '22': {
236
- start: {
237
- line: 81,
238
- column: 2
239
- },
240
- end: {
241
- line: 83,
242
- column: 3
243
- }
244
- },
245
- '23': {
246
- start: {
247
- line: 82,
248
- column: 4
249
- },
250
- end: {
251
- line: 82,
252
- column: 41
253
- }
254
- },
255
- '24': {
256
- start: {
257
- line: 85,
258
- column: 25
259
- },
260
- end: {
261
- line: 85,
262
- column: 54
263
- }
264
- },
265
- '25': {
266
- start: {
267
- line: 87,
268
- column: 2
269
- },
270
- end: {
271
- line: 89,
272
- column: 3
273
- }
274
- },
275
- '26': {
276
- start: {
277
- line: 88,
278
- column: 4
279
- },
280
- end: {
281
- line: 88,
282
- column: 46
283
- }
284
- },
285
- '27': {
286
- start: {
287
- line: 91,
288
- column: 2
289
- },
290
- end: {
291
- line: 93,
292
- column: 3
293
- }
294
- },
295
- '28': {
296
- start: {
297
- line: 92,
298
- column: 4
299
- },
300
- end: {
301
- line: 92,
302
- column: 47
303
- }
304
- },
305
- '29': {
306
- start: {
307
- line: 95,
308
- column: 2
309
- },
310
- end: {
311
- line: 95,
312
- column: 46
313
- }
314
- }
315
- },
316
- fnMap: {
317
- '0': {
318
- name: '(anonymous_0)',
319
- decl: {
320
- start: {
321
- line: 15,
322
- column: 18
323
- },
324
- end: {
325
- line: 15,
326
- column: 19
327
- }
328
- },
329
- loc: {
330
- start: {
331
- line: 15,
332
- column: 38
333
- },
334
- end: {
335
- line: 17,
336
- column: 1
337
- }
338
- }
339
- },
340
- '1': {
341
- name: '(anonymous_1)',
342
- decl: {
343
- start: {
344
- line: 24,
345
- column: 19
346
- },
347
- end: {
348
- line: 24,
349
- column: 20
350
- }
351
- },
352
- loc: {
353
- start: {
354
- line: 24,
355
- column: 39
356
- },
357
- end: {
358
- line: 26,
359
- column: 1
360
- }
361
- }
362
- },
363
- '2': {
364
- name: '(anonymous_2)',
365
- decl: {
366
- start: {
367
- line: 33,
368
- column: 20
369
- },
370
- end: {
371
- line: 33,
372
- column: 21
373
- }
374
- },
375
- loc: {
376
- start: {
377
- line: 33,
378
- column: 40
379
- },
380
- end: {
381
- line: 45,
382
- column: 1
383
- }
384
- }
385
- },
386
- '3': {
387
- name: '(anonymous_3)',
388
- decl: {
389
- start: {
390
- line: 56,
391
- column: 15
392
- },
393
- end: {
394
- line: 56,
395
- column: 16
396
- }
397
- },
398
- loc: {
399
- start: {
400
- line: 56,
401
- column: 55
402
- },
403
- end: {
404
- line: 96,
405
- column: 1
406
- }
407
- }
408
- }
409
- },
410
- branchMap: {
411
- '0': {
412
- loc: {
413
- start: {
414
- line: 38,
415
- column: 2
416
- },
417
- end: {
418
- line: 44,
419
- column: 3
420
- }
421
- },
422
- type: 'if',
423
- locations: [{
424
- start: {
425
- line: 38,
426
- column: 2
427
- },
428
- end: {
429
- line: 44,
430
- column: 3
431
- }
432
- }, {
433
- start: {
434
- line: 38,
435
- column: 2
436
- },
437
- end: {
438
- line: 44,
439
- column: 3
440
- }
441
- }]
442
- },
443
- '1': {
444
- loc: {
445
- start: {
446
- line: 57,
447
- column: 2
448
- },
449
- end: {
450
- line: 59,
451
- column: 3
452
- }
453
- },
454
- type: 'if',
455
- locations: [{
456
- start: {
457
- line: 57,
458
- column: 2
459
- },
460
- end: {
461
- line: 59,
462
- column: 3
463
- }
464
- }, {
465
- start: {
466
- line: 57,
467
- column: 2
468
- },
469
- end: {
470
- line: 59,
471
- column: 3
472
- }
473
- }]
474
- },
475
- '2': {
476
- loc: {
477
- start: {
478
- line: 61,
479
- column: 2
480
- },
481
- end: {
482
- line: 63,
483
- column: 3
484
- }
485
- },
486
- type: 'if',
487
- locations: [{
488
- start: {
489
- line: 61,
490
- column: 2
491
- },
492
- end: {
493
- line: 63,
494
- column: 3
495
- }
496
- }, {
497
- start: {
498
- line: 61,
499
- column: 2
500
- },
501
- end: {
502
- line: 63,
503
- column: 3
504
- }
505
- }]
506
- },
507
- '3': {
508
- loc: {
509
- start: {
510
- line: 67,
511
- column: 2
512
- },
513
- end: {
514
- line: 71,
515
- column: 3
516
- }
517
- },
518
- type: 'if',
519
- locations: [{
520
- start: {
521
- line: 67,
522
- column: 2
523
- },
524
- end: {
525
- line: 71,
526
- column: 3
527
- }
528
- }, {
529
- start: {
530
- line: 67,
531
- column: 2
532
- },
533
- end: {
534
- line: 71,
535
- column: 3
536
- }
537
- }]
538
- },
539
- '4': {
540
- loc: {
541
- start: {
542
- line: 73,
543
- column: 2
544
- },
545
- end: {
546
- line: 75,
547
- column: 3
548
- }
549
- },
550
- type: 'if',
551
- locations: [{
552
- start: {
553
- line: 73,
554
- column: 2
555
- },
556
- end: {
557
- line: 75,
558
- column: 3
559
- }
560
- }, {
561
- start: {
562
- line: 73,
563
- column: 2
564
- },
565
- end: {
566
- line: 75,
567
- column: 3
568
- }
569
- }]
570
- },
571
- '5': {
572
- loc: {
573
- start: {
574
- line: 77,
575
- column: 2
576
- },
577
- end: {
578
- line: 79,
579
- column: 3
580
- }
581
- },
582
- type: 'if',
583
- locations: [{
584
- start: {
585
- line: 77,
586
- column: 2
587
- },
588
- end: {
589
- line: 79,
590
- column: 3
591
- }
592
- }, {
593
- start: {
594
- line: 77,
595
- column: 2
596
- },
597
- end: {
598
- line: 79,
599
- column: 3
600
- }
601
- }]
602
- },
603
- '6': {
604
- loc: {
605
- start: {
606
- line: 81,
607
- column: 2
608
- },
609
- end: {
610
- line: 83,
611
- column: 3
612
- }
613
- },
614
- type: 'if',
615
- locations: [{
616
- start: {
617
- line: 81,
618
- column: 2
619
- },
620
- end: {
621
- line: 83,
622
- column: 3
623
- }
624
- }, {
625
- start: {
626
- line: 81,
627
- column: 2
628
- },
629
- end: {
630
- line: 83,
631
- column: 3
632
- }
633
- }]
634
- },
635
- '7': {
636
- loc: {
637
- start: {
638
- line: 87,
639
- column: 2
640
- },
641
- end: {
642
- line: 89,
643
- column: 3
644
- }
645
- },
646
- type: 'if',
647
- locations: [{
648
- start: {
649
- line: 87,
650
- column: 2
651
- },
652
- end: {
653
- line: 89,
654
- column: 3
655
- }
656
- }, {
657
- start: {
658
- line: 87,
659
- column: 2
660
- },
661
- end: {
662
- line: 89,
663
- column: 3
664
- }
665
- }]
666
- },
667
- '8': {
668
- loc: {
669
- start: {
670
- line: 91,
671
- column: 2
672
- },
673
- end: {
674
- line: 93,
675
- column: 3
676
- }
677
- },
678
- type: 'if',
679
- locations: [{
680
- start: {
681
- line: 91,
682
- column: 2
683
- },
684
- end: {
685
- line: 93,
686
- column: 3
687
- }
688
- }, {
689
- start: {
690
- line: 91,
691
- column: 2
692
- },
693
- end: {
694
- line: 93,
695
- column: 3
696
- }
697
- }]
698
- }
699
- },
700
- s: {
701
- '0': 0,
702
- '1': 0,
703
- '2': 0,
704
- '3': 0,
705
- '4': 0,
706
- '5': 0,
707
- '6': 0,
708
- '7': 0,
709
- '8': 0,
710
- '9': 0,
711
- '10': 0,
712
- '11': 0,
713
- '12': 0,
714
- '13': 0,
715
- '14': 0,
716
- '15': 0,
717
- '16': 0,
718
- '17': 0,
719
- '18': 0,
720
- '19': 0,
721
- '20': 0,
722
- '21': 0,
723
- '22': 0,
724
- '23': 0,
725
- '24': 0,
726
- '25': 0,
727
- '26': 0,
728
- '27': 0,
729
- '28': 0,
730
- '29': 0
731
- },
732
- f: {
733
- '0': 0,
734
- '1': 0,
735
- '2': 0,
736
- '3': 0
737
- },
738
- b: {
739
- '0': [0, 0],
740
- '1': [0, 0],
741
- '2': [0, 0],
742
- '3': [0, 0],
743
- '4': [0, 0],
744
- '5': [0, 0],
745
- '6': [0, 0],
746
- '7': [0, 0],
747
- '8': [0, 0]
748
- }
749
- },
750
- coverage = global[gcv] || (global[gcv] = {});
751
-
752
- if (coverage[path] && coverage[path].hash === hash) {
753
- return coverage[path];
754
- }
755
-
756
- coverageData.hash = hash;
757
- return coverage[path] = coverageData;
758
- }();
759
-
760
7
  var _lodash = require('lodash');
761
8
 
762
9
  var _lodash2 = _interopRequireDefault(_lodash);
@@ -767,61 +14,44 @@ var _stringWidth2 = _interopRequireDefault(_stringWidth);
767
14
 
768
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
769
16
 
770
- const alignments = (++cov_x1qtw309s.s[0], ['left', 'right', 'center']);
17
+ const alignments = ['left', 'right', 'center'];
771
18
 
772
19
  /**
773
20
  * @param {string} subject
774
21
  * @param {number} width
775
22
  * @returns {string}
776
23
  */
777
- const alignLeft = (++cov_x1qtw309s.s[1], (subject, width) => {
778
- ++cov_x1qtw309s.f[0];
779
- ++cov_x1qtw309s.s[2];
780
-
24
+ const alignLeft = (subject, width) => {
781
25
  return subject + _lodash2.default.repeat(' ', width);
782
- });
26
+ };
783
27
 
784
28
  /**
785
29
  * @param {string} subject
786
30
  * @param {number} width
787
31
  * @returns {string}
788
32
  */
789
- const alignRight = (++cov_x1qtw309s.s[3], (subject, width) => {
790
- ++cov_x1qtw309s.f[1];
791
- ++cov_x1qtw309s.s[4];
792
-
33
+ const alignRight = (subject, width) => {
793
34
  return _lodash2.default.repeat(' ', width) + subject;
794
- });
35
+ };
795
36
 
796
37
  /**
797
38
  * @param {string} subject
798
39
  * @param {number} width
799
40
  * @returns {string}
800
41
  */
801
- const alignCenter = (++cov_x1qtw309s.s[5], (subject, width) => {
802
- ++cov_x1qtw309s.f[2];
803
-
42
+ const alignCenter = (subject, width) => {
804
43
  let halfWidth;
805
44
 
806
- ++cov_x1qtw309s.s[6];
807
45
  halfWidth = width / 2;
808
46
 
809
- ++cov_x1qtw309s.s[7];
810
47
  if (halfWidth % 2 === 0) {
811
- ++cov_x1qtw309s.b[0][0];
812
- ++cov_x1qtw309s.s[8];
813
-
814
48
  return _lodash2.default.repeat(' ', halfWidth) + subject + _lodash2.default.repeat(' ', halfWidth);
815
49
  } else {
816
- ++cov_x1qtw309s.b[0][1];
817
- ++cov_x1qtw309s.s[9];
818
-
819
50
  halfWidth = _lodash2.default.floor(halfWidth);
820
51
 
821
- ++cov_x1qtw309s.s[10];
822
52
  return _lodash2.default.repeat(' ', halfWidth) + subject + _lodash2.default.repeat(' ', halfWidth + 1);
823
53
  }
824
- });
54
+ };
825
55
 
826
56
  /**
827
57
  * Pads a string to the left and/or right to position the subject
@@ -834,95 +64,44 @@ const alignCenter = (++cov_x1qtw309s.s[5], (subject, width) => {
834
64
  */
835
65
 
836
66
  exports.default = (subject, containerWidth, alignment) => {
837
- ++cov_x1qtw309s.f[3];
838
- ++cov_x1qtw309s.s[11];
839
-
840
67
  if (!_lodash2.default.isString(subject)) {
841
- ++cov_x1qtw309s.b[1][0];
842
- ++cov_x1qtw309s.s[12];
843
-
844
68
  throw new Error('Subject parameter value must be a string.');
845
- } else {
846
- ++cov_x1qtw309s.b[1][1];
847
69
  }
848
70
 
849
- ++cov_x1qtw309s.s[13];
850
71
  if (!_lodash2.default.isNumber(containerWidth)) {
851
- ++cov_x1qtw309s.b[2][0];
852
- ++cov_x1qtw309s.s[14];
853
-
854
72
  throw new Error('Container width parameter value must be a number.');
855
- } else {
856
- ++cov_x1qtw309s.b[2][1];
857
73
  }
858
74
 
859
- const subjectWidth = (++cov_x1qtw309s.s[15], (0, _stringWidth2.default)(subject));
75
+ const subjectWidth = (0, _stringWidth2.default)(subject);
860
76
 
861
- ++cov_x1qtw309s.s[16];
862
77
  if (subjectWidth > containerWidth) {
863
- ++cov_x1qtw309s.b[3][0];
864
- ++cov_x1qtw309s.s[17];
865
-
866
78
  // console.log('subjectWidth', subjectWidth, 'containerWidth', containerWidth, 'subject', subject);
867
79
 
868
80
  throw new Error('Subject parameter value width cannot be greater than the container width.');
869
- } else {
870
- ++cov_x1qtw309s.b[3][1];
871
81
  }
872
82
 
873
- ++cov_x1qtw309s.s[18];
874
83
  if (!_lodash2.default.isString(alignment)) {
875
- ++cov_x1qtw309s.b[4][0];
876
- ++cov_x1qtw309s.s[19];
877
-
878
84
  throw new Error('Alignment parameter value must be a string.');
879
- } else {
880
- ++cov_x1qtw309s.b[4][1];
881
85
  }
882
86
 
883
- ++cov_x1qtw309s.s[20];
884
87
  if (alignments.indexOf(alignment) === -1) {
885
- ++cov_x1qtw309s.b[5][0];
886
- ++cov_x1qtw309s.s[21];
887
-
888
88
  throw new Error('Alignment parameter value must be a known alignment parameter value (left, right, center).');
889
- } else {
890
- ++cov_x1qtw309s.b[5][1];
891
89
  }
892
90
 
893
- ++cov_x1qtw309s.s[22];
894
91
  if (subjectWidth === 0) {
895
- ++cov_x1qtw309s.b[6][0];
896
- ++cov_x1qtw309s.s[23];
897
-
898
92
  return _lodash2.default.repeat(' ', containerWidth);
899
- } else {
900
- ++cov_x1qtw309s.b[6][1];
901
93
  }
902
94
 
903
- const availableWidth = (++cov_x1qtw309s.s[24], containerWidth - subjectWidth);
95
+ const availableWidth = containerWidth - subjectWidth;
904
96
 
905
- ++cov_x1qtw309s.s[25];
906
97
  if (alignment === 'left') {
907
- ++cov_x1qtw309s.b[7][0];
908
- ++cov_x1qtw309s.s[26];
909
-
910
98
  return alignLeft(subject, availableWidth);
911
- } else {
912
- ++cov_x1qtw309s.b[7][1];
913
99
  }
914
100
 
915
- ++cov_x1qtw309s.s[27];
916
101
  if (alignment === 'right') {
917
- ++cov_x1qtw309s.b[8][0];
918
- ++cov_x1qtw309s.s[28];
919
-
920
102
  return alignRight(subject, availableWidth);
921
- } else {
922
- ++cov_x1qtw309s.b[8][1];
923
103
  }
924
104
 
925
- ++cov_x1qtw309s.s[29];
926
105
  return alignCenter(subject, availableWidth);
927
106
  };
928
107