@perses-dev/core 0.38.0 → 0.40.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.
Files changed (127) hide show
  1. package/dist/cjs/constants/dashboard-defaults.js +6 -2
  2. package/dist/cjs/constants/dialog.js +3 -1
  3. package/dist/cjs/constants/index.js +11 -9
  4. package/dist/cjs/index.js +12 -10
  5. package/dist/cjs/model/calculations.js +61 -51
  6. package/dist/cjs/model/index.js +28 -26
  7. package/dist/cjs/model/legend.js +39 -19
  8. package/dist/cjs/model/resource.js +9 -0
  9. package/dist/cjs/model/time-series-queries.js +3 -1
  10. package/dist/cjs/model/time.js +147 -64
  11. package/dist/cjs/model/units/bytes.js +37 -25
  12. package/dist/cjs/model/units/constants.js +3 -1
  13. package/dist/cjs/model/units/decimal.js +22 -16
  14. package/dist/cjs/model/units/index.js +13 -11
  15. package/dist/cjs/model/units/percent.js +26 -19
  16. package/dist/cjs/model/units/time.js +99 -38
  17. package/dist/cjs/model/units/types.js +3 -1
  18. package/dist/cjs/model/units/units.js +67 -43
  19. package/dist/cjs/model/units/utils.js +13 -7
  20. package/dist/cjs/model/variables.js +16 -3
  21. package/dist/cjs/utils/event.js +3 -1
  22. package/dist/cjs/utils/fetch.js +12 -4
  23. package/dist/cjs/utils/index.js +17 -14
  24. package/dist/cjs/utils/is-empty-object.js +3 -1
  25. package/dist/cjs/utils/mathjs.js +3 -1
  26. package/dist/cjs/utils/memo.js +10 -6
  27. package/dist/cjs/utils/panel-refs.js +9 -3
  28. package/dist/cjs/utils/text.js +39 -14
  29. package/dist/cjs/utils/time-series-data.js +21 -11
  30. package/dist/cjs/utils/types.js +16 -0
  31. package/dist/constants/dashboard-defaults.js.map +1 -1
  32. package/dist/constants/dialog.js.map +1 -1
  33. package/dist/constants/index.js.map +1 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/model/calculations.d.ts +9 -9
  36. package/dist/model/calculations.d.ts.map +1 -1
  37. package/dist/model/calculations.js +46 -46
  38. package/dist/model/calculations.js.map +1 -1
  39. package/dist/model/datasource.d.ts +20 -4
  40. package/dist/model/datasource.d.ts.map +1 -1
  41. package/dist/model/datasource.js.map +1 -1
  42. package/dist/model/display.d.ts +1 -1
  43. package/dist/model/display.d.ts.map +1 -1
  44. package/dist/model/display.js.map +1 -1
  45. package/dist/model/index.js.map +1 -1
  46. package/dist/model/legend.d.ts +6 -6
  47. package/dist/model/legend.js +9 -9
  48. package/dist/model/legend.js.map +1 -1
  49. package/dist/model/panels.d.ts +5 -2
  50. package/dist/model/panels.d.ts.map +1 -1
  51. package/dist/model/panels.js.map +1 -1
  52. package/dist/model/query.d.ts +13 -2
  53. package/dist/model/query.d.ts.map +1 -1
  54. package/dist/model/query.js.map +1 -1
  55. package/dist/model/resource.d.ts +3 -2
  56. package/dist/model/resource.d.ts.map +1 -1
  57. package/dist/model/resource.js +3 -1
  58. package/dist/model/resource.js.map +1 -1
  59. package/dist/model/thresholds.d.ts +2 -2
  60. package/dist/model/thresholds.d.ts.map +1 -1
  61. package/dist/model/thresholds.js.map +1 -1
  62. package/dist/model/time-series-data.d.ts +6 -0
  63. package/dist/model/time-series-data.d.ts.map +1 -1
  64. package/dist/model/time-series-data.js.map +1 -1
  65. package/dist/model/time-series-queries.js.map +1 -1
  66. package/dist/model/time.d.ts +3 -0
  67. package/dist/model/time.d.ts.map +1 -1
  68. package/dist/model/time.js +115 -55
  69. package/dist/model/time.js.map +1 -1
  70. package/dist/model/units/bytes.d.ts +8 -8
  71. package/dist/model/units/bytes.d.ts.map +1 -1
  72. package/dist/model/units/bytes.js +27 -21
  73. package/dist/model/units/bytes.js.map +1 -1
  74. package/dist/model/units/constants.js.map +1 -1
  75. package/dist/model/units/decimal.d.ts +8 -8
  76. package/dist/model/units/decimal.d.ts.map +1 -1
  77. package/dist/model/units/decimal.js +14 -14
  78. package/dist/model/units/decimal.js.map +1 -1
  79. package/dist/model/units/index.js.map +1 -1
  80. package/dist/model/units/percent.d.ts +7 -7
  81. package/dist/model/units/percent.d.ts.map +1 -1
  82. package/dist/model/units/percent.js +17 -16
  83. package/dist/model/units/percent.js.map +1 -1
  84. package/dist/model/units/time.d.ts +15 -15
  85. package/dist/model/units/time.d.ts.map +1 -1
  86. package/dist/model/units/time.js +87 -34
  87. package/dist/model/units/time.js.map +1 -1
  88. package/dist/model/units/types.d.ts +14 -5
  89. package/dist/model/units/types.d.ts.map +1 -1
  90. package/dist/model/units/types.js.map +1 -1
  91. package/dist/model/units/units.d.ts +37 -30
  92. package/dist/model/units/units.d.ts.map +1 -1
  93. package/dist/model/units/units.js +41 -35
  94. package/dist/model/units/units.js.map +1 -1
  95. package/dist/model/units/utils.d.ts +2 -2
  96. package/dist/model/units/utils.d.ts.map +1 -1
  97. package/dist/model/units/utils.js +4 -4
  98. package/dist/model/units/utils.js.map +1 -1
  99. package/dist/model/variables.d.ts +25 -7
  100. package/dist/model/variables.d.ts.map +1 -1
  101. package/dist/model/variables.js +3 -0
  102. package/dist/model/variables.js.map +1 -1
  103. package/dist/test/setup-tests.js.map +1 -1
  104. package/dist/utils/event.js.map +1 -1
  105. package/dist/utils/fetch.js.map +1 -1
  106. package/dist/utils/index.d.ts +2 -1
  107. package/dist/utils/index.d.ts.map +1 -1
  108. package/dist/utils/index.js +2 -1
  109. package/dist/utils/index.js.map +1 -1
  110. package/dist/utils/is-empty-object.js.map +1 -1
  111. package/dist/utils/mathjs.js.map +1 -1
  112. package/dist/utils/memo.js +2 -2
  113. package/dist/utils/memo.js.map +1 -1
  114. package/dist/utils/panel-refs.js.map +1 -1
  115. package/dist/utils/text.d.ts +15 -3
  116. package/dist/utils/text.d.ts.map +1 -1
  117. package/dist/utils/text.js +29 -10
  118. package/dist/utils/text.js.map +1 -1
  119. package/dist/utils/time-series-data.d.ts +1 -1
  120. package/dist/utils/time-series-data.d.ts.map +1 -1
  121. package/dist/utils/time-series-data.js +7 -7
  122. package/dist/utils/time-series-data.js.map +1 -1
  123. package/dist/utils/types.d.ts +2 -0
  124. package/dist/utils/types.d.ts.map +1 -0
  125. package/dist/utils/types.js +15 -0
  126. package/dist/utils/types.js.map +1 -0
  127. package/package.json +5 -4
@@ -21,8 +21,12 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- DEFAULT_DASHBOARD_DURATION: ()=>DEFAULT_DASHBOARD_DURATION,
25
- DEFAULT_REFRESH_INTERVAL: ()=>DEFAULT_REFRESH_INTERVAL
24
+ DEFAULT_DASHBOARD_DURATION: function() {
25
+ return DEFAULT_DASHBOARD_DURATION;
26
+ },
27
+ DEFAULT_REFRESH_INTERVAL: function() {
28
+ return DEFAULT_REFRESH_INTERVAL;
29
+ }
26
30
  });
27
31
  const DEFAULT_DASHBOARD_DURATION = '1h';
28
32
  const DEFAULT_REFRESH_INTERVAL = '0s';
@@ -16,6 +16,8 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "SAVE_DEFAULTS_DIALOG_TEXT", {
18
18
  enumerable: true,
19
- get: ()=>SAVE_DEFAULTS_DIALOG_TEXT
19
+ get: function() {
20
+ return SAVE_DEFAULTS_DIALOG_TEXT;
21
+ }
20
22
  });
21
23
  const SAVE_DEFAULTS_DIALOG_TEXT = 'You have made changes to the time range or the variables values. Would you like to save these as defaults?';
@@ -14,16 +14,18 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./dashboard-defaults"), exports);
18
- _exportStar(require("./dialog"), exports);
19
- function _exportStar(from, to) {
17
+ _export_star(require("./dashboard-defaults"), exports);
18
+ _export_star(require("./dialog"), exports);
19
+ function _export_star(from, to) {
20
20
  Object.keys(from).forEach(function(k) {
21
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
21
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
22
+ Object.defineProperty(to, k, {
23
+ enumerable: true,
24
+ get: function() {
25
+ return from[k];
26
+ }
27
+ });
28
+ }
27
29
  });
28
30
  return from;
29
31
  }
package/dist/cjs/index.js CHANGED
@@ -14,17 +14,19 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./constants"), exports);
18
- _exportStar(require("./model"), exports);
19
- _exportStar(require("./utils"), exports);
20
- function _exportStar(from, to) {
17
+ _export_star(require("./constants"), exports);
18
+ _export_star(require("./model"), exports);
19
+ _export_star(require("./utils"), exports);
20
+ function _export_star(from, to) {
21
21
  Object.keys(from).forEach(function(k) {
22
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
23
- enumerable: true,
24
- get: function() {
25
- return from[k];
26
- }
27
- });
22
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
23
+ Object.defineProperty(to, k, {
24
+ enumerable: true,
25
+ get: function() {
26
+ return from[k];
27
+ }
28
+ });
29
+ }
28
30
  });
29
31
  return from;
30
32
  }
@@ -21,57 +21,67 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- CalculationsMap: ()=>CalculationsMap,
25
- CALCULATIONS_CONFIG: ()=>CALCULATIONS_CONFIG,
26
- DEFAULT_CALCULATION: ()=>DEFAULT_CALCULATION,
27
- getCalculations: ()=>getCalculations,
28
- getCalculation: ()=>getCalculation
24
+ DEFAULT_CALCULATION: function() {
25
+ return DEFAULT_CALCULATION;
26
+ },
27
+ CalculationsMap: function() {
28
+ return CalculationsMap;
29
+ },
30
+ CALCULATIONS_CONFIG: function() {
31
+ return CALCULATIONS_CONFIG;
32
+ },
33
+ getCalculations: function() {
34
+ return getCalculations;
35
+ },
36
+ getCalculation: function() {
37
+ return getCalculation;
38
+ }
29
39
  });
40
+ const DEFAULT_CALCULATION = 'last-number';
30
41
  const CalculationsMap = {
31
- First: first,
32
- Last: last,
33
- FirstNumber: firstNumber,
34
- LastNumber: lastNumber,
35
- Mean: mean,
36
- Sum: sum,
37
- Min: min,
38
- Max: max
42
+ first: first,
43
+ last: last,
44
+ 'first-number': firstNumber,
45
+ 'last-number': lastNumber,
46
+ mean: mean,
47
+ sum: sum,
48
+ min: min,
49
+ max: max
39
50
  };
40
51
  const CALCULATIONS_CONFIG = {
41
- First: {
52
+ first: {
42
53
  label: 'First',
43
54
  description: 'First value'
44
55
  },
45
- Last: {
56
+ last: {
46
57
  label: 'Last',
47
58
  description: 'Last value'
48
59
  },
49
- FirstNumber: {
60
+ 'first-number': {
50
61
  label: 'First *',
51
62
  description: 'First numeric value'
52
63
  },
53
- LastNumber: {
64
+ 'last-number': {
54
65
  label: 'Last *',
55
66
  description: 'Last numeric value'
56
67
  },
57
- Mean: {
68
+ mean: {
58
69
  label: 'Avg',
59
70
  description: 'Average value excluding nulls'
60
71
  },
61
- Sum: {
72
+ sum: {
62
73
  label: 'Sum',
63
74
  description: 'The sum of all values'
64
75
  },
65
- Min: {
76
+ min: {
66
77
  label: 'Min',
67
78
  description: 'Minimum value'
68
79
  },
69
- Max: {
80
+ max: {
70
81
  label: 'Max',
71
82
  description: 'Maximum value'
72
83
  }
73
84
  };
74
- const DEFAULT_CALCULATION = 'Sum';
75
85
  function getCalculations(values, includeCalculations) {
76
86
  const calculations = includeCalculations.reduce((initResult, calculation)=>{
77
87
  initResult[calculation] = undefined;
@@ -85,55 +95,55 @@ function getCalculations(values, includeCalculations) {
85
95
  // in a single iteration of the data to minimize the performance impact of
86
96
  // generating multiple calculations for large timeseries values. This is
87
97
  // less optimized for certain single calculations when done in isolation (e.g.
88
- // `Last`), but will be more performant in the more expensive cases where
98
+ // `last`), but will be more performant in the more expensive cases where
89
99
  // multiple values are being used (e.g. table legend).
90
100
  values.forEach((tuple, i)=>{
91
101
  const value = tuple[1];
92
- if (i === 0 && 'First' in calculations) {
93
- calculations.First = value;
102
+ if (i === 0 && 'first' in calculations) {
103
+ calculations.first = value;
94
104
  }
95
- if (i === values.length - 1 && 'Last' in calculations) {
96
- calculations.Last = value;
105
+ if (i === values.length - 1 && 'last' in calculations) {
106
+ calculations.last = value;
97
107
  }
98
108
  // Handling specific to non-null values.
99
109
  if (typeof value === 'number') {
100
110
  nonNullCount += 1;
101
111
  sum += value;
102
- if ('FirstNumber' in calculations && calculations.FirstNumber === undefined) {
112
+ if ('first-number' in calculations && calculations['first-number'] === undefined) {
103
113
  // Save the first number we see.
104
- calculations.FirstNumber = value;
114
+ calculations['first-number'] = value;
105
115
  }
106
- if ('LastNumber' in calculations) {
116
+ if ('last-number' in calculations) {
107
117
  // Keep setting the numbers we see, which will eventually be set to the
108
118
  // last number when finished iterating.
109
- calculations.LastNumber = value;
119
+ calculations['last-number'] = value;
110
120
  }
111
- if ('Min' in calculations) {
112
- if (typeof calculations.Min !== 'number') {
121
+ if ('min' in calculations) {
122
+ if (typeof calculations.min !== 'number') {
113
123
  // Init the first time we see a number
114
- calculations.Min = value;
124
+ calculations.min = value;
115
125
  } else {
116
126
  // Use lowest value once initialized
117
- calculations.Min = Math.min(calculations.Min, value);
127
+ calculations.min = Math.min(calculations.min, value);
118
128
  }
119
129
  }
120
- if ('Max' in calculations) {
121
- if (typeof calculations.Max !== 'number') {
130
+ if ('max' in calculations) {
131
+ if (typeof calculations.max !== 'number') {
122
132
  // Init the first time we see a number
123
- calculations.Max = value;
133
+ calculations.max = value;
124
134
  } else {
125
135
  // Use highest value once initialized
126
- calculations.Max = Math.max(calculations.Max, value);
136
+ calculations.max = Math.max(calculations.max, value);
127
137
  }
128
138
  }
129
139
  }
130
140
  });
131
141
  // Set calculations that require iterating over all values.
132
- if (nonNullCount > 0 && 'Sum' in calculations) {
133
- calculations.Sum = sum;
142
+ if (nonNullCount > 0 && 'sum' in calculations) {
143
+ calculations.sum = sum;
134
144
  }
135
- if (nonNullCount > 0 && 'Mean' in calculations) {
136
- calculations.Mean = sum / nonNullCount;
145
+ if (nonNullCount > 0 && 'mean' in calculations) {
146
+ calculations.mean = sum / nonNullCount;
137
147
  }
138
148
  return calculations;
139
149
  }
@@ -143,26 +153,26 @@ function getCalculation(values, calculation) {
143
153
  ])[calculation];
144
154
  }
145
155
  function first(values) {
146
- return getCalculation(values, 'First');
156
+ return getCalculation(values, 'first');
147
157
  }
148
158
  function last(values) {
149
- return getCalculation(values, 'Last');
159
+ return getCalculation(values, 'last');
150
160
  }
151
161
  function firstNumber(values) {
152
- return getCalculation(values, 'FirstNumber');
162
+ return getCalculation(values, 'first-number');
153
163
  }
154
164
  function lastNumber(values) {
155
- return getCalculation(values, 'LastNumber');
165
+ return getCalculation(values, 'last-number');
156
166
  }
157
167
  function mean(values) {
158
- return getCalculation(values, 'Mean');
168
+ return getCalculation(values, 'mean');
159
169
  }
160
170
  function sum(values) {
161
- return getCalculation(values, 'Sum');
171
+ return getCalculation(values, 'sum');
162
172
  }
163
173
  function min(values) {
164
- return getCalculation(values, 'Min');
174
+ return getCalculation(values, 'min');
165
175
  }
166
176
  function max(values) {
167
- return getCalculation(values, 'Max');
177
+ return getCalculation(values, 'max');
168
178
  }
@@ -14,33 +14,35 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./calculations"), exports);
18
- _exportStar(require("./dashboard"), exports);
19
- _exportStar(require("./datasource"), exports);
20
- _exportStar(require("./definitions"), exports);
21
- _exportStar(require("./display"), exports);
22
- _exportStar(require("./http"), exports);
23
- _exportStar(require("./layout"), exports);
24
- _exportStar(require("./legend"), exports);
25
- _exportStar(require("./notice"), exports);
26
- _exportStar(require("./panels"), exports);
27
- _exportStar(require("./project"), exports);
28
- _exportStar(require("./query"), exports);
29
- _exportStar(require("./resource"), exports);
30
- _exportStar(require("./thresholds"), exports);
31
- _exportStar(require("./time"), exports);
32
- _exportStar(require("./time-series-data"), exports);
33
- _exportStar(require("./time-series-queries"), exports);
34
- _exportStar(require("./units"), exports);
35
- _exportStar(require("./variables"), exports);
36
- function _exportStar(from, to) {
17
+ _export_star(require("./calculations"), exports);
18
+ _export_star(require("./dashboard"), exports);
19
+ _export_star(require("./datasource"), exports);
20
+ _export_star(require("./definitions"), exports);
21
+ _export_star(require("./display"), exports);
22
+ _export_star(require("./http"), exports);
23
+ _export_star(require("./layout"), exports);
24
+ _export_star(require("./legend"), exports);
25
+ _export_star(require("./notice"), exports);
26
+ _export_star(require("./panels"), exports);
27
+ _export_star(require("./project"), exports);
28
+ _export_star(require("./query"), exports);
29
+ _export_star(require("./resource"), exports);
30
+ _export_star(require("./thresholds"), exports);
31
+ _export_star(require("./time"), exports);
32
+ _export_star(require("./time-series-data"), exports);
33
+ _export_star(require("./time-series-queries"), exports);
34
+ _export_star(require("./units"), exports);
35
+ _export_star(require("./variables"), exports);
36
+ function _export_star(from, to) {
37
37
  Object.keys(from).forEach(function(k) {
38
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
39
- enumerable: true,
40
- get: function() {
41
- return from[k];
42
- }
43
- });
38
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
39
+ Object.defineProperty(to, k, {
40
+ enumerable: true,
41
+ get: function() {
42
+ return from[k];
43
+ }
44
+ });
45
+ }
44
46
  });
45
47
  return from;
46
48
  }
@@ -25,28 +25,48 @@ function _export(target, all) {
25
25
  });
26
26
  }
27
27
  _export(exports, {
28
- legendPositions: ()=>legendPositions,
29
- legendModes: ()=>legendModes,
30
- legendSizes: ()=>legendSizes,
31
- isValidLegendPosition: ()=>isValidLegendPosition,
32
- isValidLegendMode: ()=>isValidLegendMode,
33
- isValidLegendSize: ()=>isValidLegendSize,
34
- DEFAULT_LEGEND: ()=>DEFAULT_LEGEND,
35
- getLegendPosition: ()=>getLegendPosition,
36
- getLegendMode: ()=>getLegendMode,
37
- getLegendSize: ()=>getLegendSize
28
+ legendPositions: function() {
29
+ return legendPositions;
30
+ },
31
+ legendModes: function() {
32
+ return legendModes;
33
+ },
34
+ legendSizes: function() {
35
+ return legendSizes;
36
+ },
37
+ isValidLegendPosition: function() {
38
+ return isValidLegendPosition;
39
+ },
40
+ isValidLegendMode: function() {
41
+ return isValidLegendMode;
42
+ },
43
+ isValidLegendSize: function() {
44
+ return isValidLegendSize;
45
+ },
46
+ DEFAULT_LEGEND: function() {
47
+ return DEFAULT_LEGEND;
48
+ },
49
+ getLegendPosition: function() {
50
+ return getLegendPosition;
51
+ },
52
+ getLegendMode: function() {
53
+ return getLegendMode;
54
+ },
55
+ getLegendSize: function() {
56
+ return getLegendSize;
57
+ }
38
58
  });
39
59
  const legendPositions = [
40
- 'Bottom',
41
- 'Right'
60
+ 'bottom',
61
+ 'right'
42
62
  ];
43
63
  const legendModes = [
44
- 'List',
45
- 'Table'
64
+ 'list',
65
+ 'table'
46
66
  ];
47
67
  const legendSizes = [
48
- 'Small',
49
- 'Medium'
68
+ 'small',
69
+ 'medium'
50
70
  ];
51
71
  function isValidLegendPosition(position) {
52
72
  return legendPositions.includes(position);
@@ -58,9 +78,9 @@ function isValidLegendSize(size) {
58
78
  return legendSizes.includes(size);
59
79
  }
60
80
  const DEFAULT_LEGEND = {
61
- position: 'Bottom',
62
- mode: 'List',
63
- size: 'Medium'
81
+ position: 'bottom',
82
+ mode: 'list',
83
+ size: 'medium'
64
84
  };
65
85
  function getLegendPosition(position) {
66
86
  if (position === undefined) {
@@ -14,3 +14,12 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ Object.defineProperty(exports, "getMetadataProject", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return getMetadataProject;
21
+ }
22
+ });
23
+ function getMetadataProject(metadata) {
24
+ return 'project' in metadata ? metadata.project : undefined;
25
+ }
@@ -16,7 +16,9 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "isTimeSeriesValueTuple", {
18
18
  enumerable: true,
19
- get: ()=>isTimeSeriesValueTuple
19
+ get: function() {
20
+ return isTimeSeriesValueTuple;
21
+ }
20
22
  });
21
23
  function isTimeSeriesValueTuple(data) {
22
24
  if (data.length !== 2) return false;