@atlaskit/tokens 1.49.1 → 1.51.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 (115) hide show
  1. package/CHANGELOG.md +1593 -1594
  2. package/README.md +14 -8
  3. package/codemods/css-to-design-tokens/lib/colors.tsx +47 -49
  4. package/codemods/css-to-design-tokens/lib/declaration.tsx +26 -26
  5. package/codemods/css-to-design-tokens/lib/legacy-colors.tsx +326 -326
  6. package/codemods/css-to-design-tokens/lib/meta.tsx +116 -122
  7. package/codemods/css-to-design-tokens/lib/tokens.tsx +28 -35
  8. package/codemods/css-to-design-tokens/lib/value.tsx +70 -72
  9. package/codemods/css-to-design-tokens/transform.tsx +68 -72
  10. package/codemods/hypermod.config.tsx +5 -5
  11. package/codemods/remove-fallbacks-color/transform.tsx +16 -18
  12. package/codemods/theme-to-design-tokens/transform.tsx +505 -588
  13. package/codemods/theme-to-design-tokens/utils/ast-meta.tsx +139 -147
  14. package/codemods/theme-to-design-tokens/utils/ast.tsx +23 -34
  15. package/codemods/theme-to-design-tokens/utils/color.tsx +25 -26
  16. package/codemods/theme-to-design-tokens/utils/css-utils.tsx +27 -30
  17. package/codemods/theme-to-design-tokens/utils/fuzzy-search.tsx +272 -290
  18. package/codemods/theme-to-design-tokens/utils/legacy-colors.tsx +224 -224
  19. package/codemods/theme-to-design-tokens/utils/named-colors.tsx +148 -148
  20. package/codemods/theme-to-design-tokens/utils/string-utils.tsx +10 -16
  21. package/codemods/utils/tokens.tsx +371 -371
  22. package/dist/cjs/artifacts/atlassian-dark-token-value-for-contrast-check.js +1 -1
  23. package/dist/cjs/artifacts/atlassian-light-token-value-for-contrast-check.js +1 -1
  24. package/dist/cjs/artifacts/generated-pairs.js +1 -1
  25. package/dist/cjs/artifacts/theme-import-map.js +1 -1
  26. package/dist/cjs/artifacts/themes/atlassian-typography-minor3.js +2 -2
  27. package/dist/cjs/artifacts/token-default-values.js +1 -1
  28. package/dist/cjs/artifacts/token-names.js +1 -1
  29. package/dist/cjs/artifacts/tokens-raw/atlassian-typography-minor3.js +3 -3
  30. package/dist/es2019/artifacts/atlassian-dark-token-value-for-contrast-check.js +1 -1
  31. package/dist/es2019/artifacts/atlassian-light-token-value-for-contrast-check.js +1 -1
  32. package/dist/es2019/artifacts/generated-pairs.js +1 -1
  33. package/dist/es2019/artifacts/theme-import-map.js +1 -1
  34. package/dist/es2019/artifacts/themes/atlassian-typography-minor3.js +2 -2
  35. package/dist/es2019/artifacts/token-default-values.js +1 -1
  36. package/dist/es2019/artifacts/token-names.js +1 -1
  37. package/dist/es2019/artifacts/tokens-raw/atlassian-typography-minor3.js +3 -3
  38. package/dist/esm/artifacts/atlassian-dark-token-value-for-contrast-check.js +1 -1
  39. package/dist/esm/artifacts/atlassian-light-token-value-for-contrast-check.js +1 -1
  40. package/dist/esm/artifacts/generated-pairs.js +1 -1
  41. package/dist/esm/artifacts/theme-import-map.js +1 -1
  42. package/dist/esm/artifacts/themes/atlassian-typography-minor3.js +2 -2
  43. package/dist/esm/artifacts/token-default-values.js +1 -1
  44. package/dist/esm/artifacts/token-names.js +1 -1
  45. package/dist/esm/artifacts/tokens-raw/atlassian-typography-minor3.js +3 -3
  46. package/dist/types/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +1 -1
  47. package/dist/types/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +1 -1
  48. package/dist/types/artifacts/generated-pairs.d.ts +1 -1
  49. package/dist/types/artifacts/theme-import-map.d.ts +2 -2
  50. package/dist/types/artifacts/themes/atlassian-typography-minor3.d.ts +2 -2
  51. package/dist/types/artifacts/token-default-values.d.ts +1 -1
  52. package/dist/types/artifacts/token-names.d.ts +1 -1
  53. package/dist/types/artifacts/tokens-raw/atlassian-typography-minor3.d.ts +1 -1
  54. package/dist/types/artifacts/types-internal.d.ts +1 -1
  55. package/dist/types/artifacts/types.d.ts +1 -1
  56. package/dist/types/babel-plugin/plugin.d.ts +1 -1
  57. package/dist/types/custom-theme.d.ts +2 -2
  58. package/dist/types/enable-global-theme.d.ts +2 -2
  59. package/dist/types/entry-points/css-type-schema.codegen.d.ts +1 -1
  60. package/dist/types/entry-points/token-ids.d.ts +1 -1
  61. package/dist/types/get-global-theme.d.ts +1 -1
  62. package/dist/types/get-ssr-auto-script.d.ts +1 -1
  63. package/dist/types/get-theme-html-attrs.d.ts +1 -1
  64. package/dist/types/get-theme-styles.d.ts +1 -1
  65. package/dist/types/get-token.d.ts +1 -1
  66. package/dist/types/index.d.ts +1 -1
  67. package/dist/types/load-custom-theme-styles.d.ts +1 -1
  68. package/dist/types/set-global-theme.d.ts +2 -2
  69. package/dist/types/theme-state-transformer.d.ts +1 -1
  70. package/dist/types/utils/color-detection.d.ts +1 -1
  71. package/dist/types/utils/color-mode-listeners.d.ts +1 -1
  72. package/dist/types/utils/configure-page.d.ts +1 -1
  73. package/dist/types/utils/contrast-mode-listeners.d.ts +1 -1
  74. package/dist/types/utils/custom-theme-loading-utils.d.ts +1 -1
  75. package/dist/types/utils/custom-theme-token-contrast-check.d.ts +1 -1
  76. package/dist/types/utils/generate-custom-color-ramp.d.ts +2 -2
  77. package/dist/types/utils/get-increased-contrast-theme.d.ts +1 -1
  78. package/dist/types/utils/get-theme-preferences.d.ts +1 -1
  79. package/dist/types/utils/theme-loading.d.ts +1 -1
  80. package/dist/types-ts4.5/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +1 -1
  81. package/dist/types-ts4.5/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +1 -1
  82. package/dist/types-ts4.5/artifacts/generated-pairs.d.ts +1 -1
  83. package/dist/types-ts4.5/artifacts/theme-import-map.d.ts +2 -2
  84. package/dist/types-ts4.5/artifacts/themes/atlassian-typography-minor3.d.ts +2 -2
  85. package/dist/types-ts4.5/artifacts/token-default-values.d.ts +1 -1
  86. package/dist/types-ts4.5/artifacts/token-names.d.ts +1 -1
  87. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-typography-minor3.d.ts +1 -1
  88. package/dist/types-ts4.5/artifacts/types-internal.d.ts +1 -1
  89. package/dist/types-ts4.5/artifacts/types.d.ts +1 -1
  90. package/dist/types-ts4.5/babel-plugin/plugin.d.ts +1 -1
  91. package/dist/types-ts4.5/custom-theme.d.ts +2 -2
  92. package/dist/types-ts4.5/enable-global-theme.d.ts +2 -2
  93. package/dist/types-ts4.5/entry-points/css-type-schema.codegen.d.ts +1 -1
  94. package/dist/types-ts4.5/entry-points/token-ids.d.ts +1 -1
  95. package/dist/types-ts4.5/get-global-theme.d.ts +1 -1
  96. package/dist/types-ts4.5/get-ssr-auto-script.d.ts +1 -1
  97. package/dist/types-ts4.5/get-theme-html-attrs.d.ts +1 -1
  98. package/dist/types-ts4.5/get-theme-styles.d.ts +1 -1
  99. package/dist/types-ts4.5/get-token.d.ts +1 -1
  100. package/dist/types-ts4.5/index.d.ts +1 -1
  101. package/dist/types-ts4.5/load-custom-theme-styles.d.ts +1 -1
  102. package/dist/types-ts4.5/set-global-theme.d.ts +2 -2
  103. package/dist/types-ts4.5/theme-state-transformer.d.ts +1 -1
  104. package/dist/types-ts4.5/utils/color-detection.d.ts +1 -1
  105. package/dist/types-ts4.5/utils/color-mode-listeners.d.ts +1 -1
  106. package/dist/types-ts4.5/utils/configure-page.d.ts +1 -1
  107. package/dist/types-ts4.5/utils/contrast-mode-listeners.d.ts +1 -1
  108. package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +1 -1
  109. package/dist/types-ts4.5/utils/custom-theme-token-contrast-check.d.ts +1 -1
  110. package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +2 -2
  111. package/dist/types-ts4.5/utils/get-increased-contrast-theme.d.ts +1 -1
  112. package/dist/types-ts4.5/utils/get-theme-preferences.d.ts +1 -1
  113. package/dist/types-ts4.5/utils/theme-loading.d.ts +1 -1
  114. package/package.json +138 -140
  115. package/report.api.md +2071 -2090
@@ -4,323 +4,305 @@
4
4
  * Fuzzy search ripped from the internet.
5
5
  */
6
6
  const FuzzySet = function (
7
- arr: string[] = [],
8
- useLevenshtein?: boolean,
9
- gramSizeLower: number = 2,
10
- gramSizeUpper: number = 3,
7
+ arr: string[] = [],
8
+ useLevenshtein?: boolean,
9
+ gramSizeLower: number = 2,
10
+ gramSizeUpper: number = 3,
11
11
  ) {
12
- var fuzzyset: any = {
13
- gramSizeLower: gramSizeLower,
14
- gramSizeUpper: gramSizeUpper,
15
- useLevenshtein: typeof useLevenshtein !== 'boolean' ? true : useLevenshtein,
16
- exactSet: {},
17
- matchDict: {},
18
- items: {},
19
- };
12
+ var fuzzyset: any = {
13
+ gramSizeLower: gramSizeLower,
14
+ gramSizeUpper: gramSizeUpper,
15
+ useLevenshtein: typeof useLevenshtein !== 'boolean' ? true : useLevenshtein,
16
+ exactSet: {},
17
+ matchDict: {},
18
+ items: {},
19
+ };
20
20
 
21
- var levenshtein = function (str1: string, str2: string) {
22
- var current: number[] = [];
23
- var prev: number;
24
- var value: number;
21
+ var levenshtein = function (str1: string, str2: string) {
22
+ var current: number[] = [];
23
+ var prev: number;
24
+ var value: number;
25
25
 
26
- for (var i = 0; i <= str2.length; i++) {
27
- for (var j = 0; j <= str1.length; j++) {
28
- if (i && j) {
29
- if (str1.charAt(j - 1) === str2.charAt(i - 1)) {
30
- // @ts-expect-error
31
- value = prev;
32
- } else {
33
- // @ts-expect-error
34
- value = Math.min(current[j], current[j - 1], prev) + 1;
35
- }
36
- } else {
37
- value = i + j;
38
- }
26
+ for (var i = 0; i <= str2.length; i++) {
27
+ for (var j = 0; j <= str1.length; j++) {
28
+ if (i && j) {
29
+ if (str1.charAt(j - 1) === str2.charAt(i - 1)) {
30
+ // @ts-expect-error
31
+ value = prev;
32
+ } else {
33
+ // @ts-expect-error
34
+ value = Math.min(current[j], current[j - 1], prev) + 1;
35
+ }
36
+ } else {
37
+ value = i + j;
38
+ }
39
39
 
40
- prev = current[j];
41
- current[j] = value;
42
- }
43
- }
40
+ prev = current[j];
41
+ current[j] = value;
42
+ }
43
+ }
44
44
 
45
- return current.pop() as number;
46
- };
45
+ return current.pop() as number;
46
+ };
47
47
 
48
- // return an edit distance from 0 to 1
49
- var _distance = function (str1: string, str2: string) {
50
- if (str1 === null && str2 === null) {
51
- throw new Error('Trying to compare two null values');
52
- }
53
- if (str1 === null || str2 === null) {
54
- return 0;
55
- }
56
- str1 = String(str1);
57
- str2 = String(str2);
48
+ // return an edit distance from 0 to 1
49
+ var _distance = function (str1: string, str2: string) {
50
+ if (str1 === null && str2 === null) {
51
+ throw new Error('Trying to compare two null values');
52
+ }
53
+ if (str1 === null || str2 === null) {
54
+ return 0;
55
+ }
56
+ str1 = String(str1);
57
+ str2 = String(str2);
58
58
 
59
- var distance = levenshtein(str1, str2);
60
- if (str1.length > str2.length) {
61
- return 1 - distance / str1.length;
62
- } else {
63
- return 1 - distance / str2.length;
64
- }
65
- };
66
- var _nonWordRe = /[^a-zA-Z0-9\u00C0-\u00FF, ]+/g;
59
+ var distance = levenshtein(str1, str2);
60
+ if (str1.length > str2.length) {
61
+ return 1 - distance / str1.length;
62
+ } else {
63
+ return 1 - distance / str2.length;
64
+ }
65
+ };
66
+ var _nonWordRe = /[^a-zA-Z0-9\u00C0-\u00FF, ]+/g;
67
67
 
68
- var _iterateGrams = function (value: any, gramSize: any) {
69
- gramSize = gramSize || 2;
70
- var simplified = '-' + value.toLowerCase().replace(_nonWordRe, '') + '-',
71
- lenDiff = gramSize - simplified.length,
72
- results = [];
73
- if (lenDiff > 0) {
74
- for (var i = 0; i < lenDiff; ++i) {
75
- simplified += '-';
76
- }
77
- }
78
- for (var i = 0; i < simplified.length - gramSize + 1; ++i) {
79
- results.push(simplified.slice(i, i + gramSize));
80
- }
81
- return results;
82
- };
68
+ var _iterateGrams = function (value: any, gramSize: any) {
69
+ gramSize = gramSize || 2;
70
+ var simplified = '-' + value.toLowerCase().replace(_nonWordRe, '') + '-',
71
+ lenDiff = gramSize - simplified.length,
72
+ results = [];
73
+ if (lenDiff > 0) {
74
+ for (var i = 0; i < lenDiff; ++i) {
75
+ simplified += '-';
76
+ }
77
+ }
78
+ for (var i = 0; i < simplified.length - gramSize + 1; ++i) {
79
+ results.push(simplified.slice(i, i + gramSize));
80
+ }
81
+ return results;
82
+ };
83
83
 
84
- var _gramCounter = function (value: string, gramSize: number) {
85
- // return an object where key=gram, value=number of occurrences
86
- gramSize = gramSize || 2;
87
- var result = {},
88
- grams = _iterateGrams(value, gramSize),
89
- i = 0;
90
- for (i; i < grams.length; ++i) {
91
- if (grams[i] in result) {
92
- // @ts-expect-error
93
- result[grams[i]] += 1;
94
- } else {
95
- // @ts-expect-error
96
- result[grams[i]] = 1;
97
- }
98
- }
99
- return result;
100
- };
84
+ var _gramCounter = function (value: string, gramSize: number) {
85
+ // return an object where key=gram, value=number of occurrences
86
+ gramSize = gramSize || 2;
87
+ var result = {},
88
+ grams = _iterateGrams(value, gramSize),
89
+ i = 0;
90
+ for (i; i < grams.length; ++i) {
91
+ if (grams[i] in result) {
92
+ // @ts-expect-error
93
+ result[grams[i]] += 1;
94
+ } else {
95
+ // @ts-expect-error
96
+ result[grams[i]] = 1;
97
+ }
98
+ }
99
+ return result;
100
+ };
101
101
 
102
- // the main functions
103
- fuzzyset.get = function (
104
- value: string,
105
- defaultValue: string,
106
- minMatchScore: number,
107
- ) {
108
- // check for value in set, returning defaultValue or null if none found
109
- if (minMatchScore === undefined) {
110
- minMatchScore = 0.33;
111
- }
112
- var result = this._get(value, minMatchScore);
113
- if (!result && typeof defaultValue !== 'undefined') {
114
- return defaultValue;
115
- }
116
- return result;
117
- };
102
+ // the main functions
103
+ fuzzyset.get = function (value: string, defaultValue: string, minMatchScore: number) {
104
+ // check for value in set, returning defaultValue or null if none found
105
+ if (minMatchScore === undefined) {
106
+ minMatchScore = 0.33;
107
+ }
108
+ var result = this._get(value, minMatchScore);
109
+ if (!result && typeof defaultValue !== 'undefined') {
110
+ return defaultValue;
111
+ }
112
+ return result;
113
+ };
118
114
 
119
- fuzzyset._get = function (value: string, minMatchScore: number) {
120
- var results = [];
121
- // start with high gram size and if there are no results, go to lower gram sizes
122
- for (
123
- var gramSize = this.gramSizeUpper;
124
- gramSize >= this.gramSizeLower;
125
- --gramSize
126
- ) {
127
- results = this.__get(value, gramSize, minMatchScore);
128
- if (results && results.length > 0) {
129
- return results;
130
- }
131
- }
132
- return null;
133
- };
115
+ fuzzyset._get = function (value: string, minMatchScore: number) {
116
+ var results = [];
117
+ // start with high gram size and if there are no results, go to lower gram sizes
118
+ for (var gramSize = this.gramSizeUpper; gramSize >= this.gramSizeLower; --gramSize) {
119
+ results = this.__get(value, gramSize, minMatchScore);
120
+ if (results && results.length > 0) {
121
+ return results;
122
+ }
123
+ }
124
+ return null;
125
+ };
134
126
 
135
- fuzzyset.__get = function (
136
- value: string,
137
- gramSize: number,
138
- minMatchScore: number,
139
- ) {
140
- var normalizedValue = this._normalizeStr(value),
141
- matches = {},
142
- gramCounts = _gramCounter(normalizedValue, gramSize),
143
- items = this.items[gramSize],
144
- sumOfSquareGramCounts = 0,
145
- gram,
146
- gramCount,
147
- i,
148
- index,
149
- otherGramCount;
127
+ fuzzyset.__get = function (value: string, gramSize: number, minMatchScore: number) {
128
+ var normalizedValue = this._normalizeStr(value),
129
+ matches = {},
130
+ gramCounts = _gramCounter(normalizedValue, gramSize),
131
+ items = this.items[gramSize],
132
+ sumOfSquareGramCounts = 0,
133
+ gram,
134
+ gramCount,
135
+ i,
136
+ index,
137
+ otherGramCount;
150
138
 
151
- for (gram in gramCounts) {
152
- // @ts-expect-error
153
- gramCount = gramCounts[gram];
154
- sumOfSquareGramCounts += Math.pow(gramCount, 2);
155
- if (gram in this.matchDict) {
156
- for (i = 0; i < this.matchDict[gram].length; ++i) {
157
- index = this.matchDict[gram][i][0];
158
- otherGramCount = this.matchDict[gram][i][1];
159
- if (index in matches) {
160
- // @ts-expect-error
161
- matches[index] += gramCount * otherGramCount;
162
- } else {
163
- // @ts-expect-error
164
- matches[index] = gramCount * otherGramCount;
165
- }
166
- }
167
- }
168
- }
139
+ for (gram in gramCounts) {
140
+ // @ts-expect-error
141
+ gramCount = gramCounts[gram];
142
+ sumOfSquareGramCounts += Math.pow(gramCount, 2);
143
+ if (gram in this.matchDict) {
144
+ for (i = 0; i < this.matchDict[gram].length; ++i) {
145
+ index = this.matchDict[gram][i][0];
146
+ otherGramCount = this.matchDict[gram][i][1];
147
+ if (index in matches) {
148
+ // @ts-expect-error
149
+ matches[index] += gramCount * otherGramCount;
150
+ } else {
151
+ // @ts-expect-error
152
+ matches[index] = gramCount * otherGramCount;
153
+ }
154
+ }
155
+ }
156
+ }
169
157
 
170
- function isEmptyObject(obj: any) {
171
- for (var prop in obj) {
172
- if (obj.hasOwnProperty(prop)) {
173
- return false;
174
- }
175
- }
176
- return true;
177
- }
158
+ function isEmptyObject(obj: any) {
159
+ for (var prop in obj) {
160
+ if (obj.hasOwnProperty(prop)) {
161
+ return false;
162
+ }
163
+ }
164
+ return true;
165
+ }
178
166
 
179
- if (isEmptyObject(matches)) {
180
- return null;
181
- }
167
+ if (isEmptyObject(matches)) {
168
+ return null;
169
+ }
182
170
 
183
- var vectorNormal = Math.sqrt(sumOfSquareGramCounts),
184
- results: string[] = [],
185
- matchScore;
186
- // build a results list of [score, str]
187
- for (var matchIndex in matches) {
188
- // @ts-expect-error
189
- matchScore = matches[matchIndex];
190
- // @ts-expect-error
191
- results.push([
192
- matchScore / (vectorNormal * items[matchIndex][0]),
193
- items[matchIndex][1],
194
- ]);
195
- }
196
- var sortDescending = function (a: any, b: any) {
197
- if (a[0] < b[0]) {
198
- return 1;
199
- } else if (a[0] > b[0]) {
200
- return -1;
201
- } else {
202
- return 0;
203
- }
204
- };
205
- results.sort(sortDescending);
206
- if (this.useLevenshtein) {
207
- var newResults: string[] = [],
208
- endIndex = Math.min(50, results.length);
209
- // truncate somewhat arbitrarily to 50
210
- // @ts-expect-error
211
- for (var i = 0; i < endIndex; ++i) {
212
- // @ts-expect-error
213
- newResults.push([
214
- _distance(results[i][1], normalizedValue),
215
- results[i][1],
216
- ]);
217
- }
218
- results = newResults;
219
- results.sort(sortDescending);
220
- }
221
- newResults = [];
222
- results.forEach(
223
- function (scoreWordPair: any) {
224
- if (scoreWordPair[0] >= minMatchScore) {
225
- // @ts-expect-error
226
- newResults.push([scoreWordPair[0], this.exactSet[scoreWordPair[1]]]);
227
- }
228
- }.bind(this),
229
- );
230
- return newResults;
231
- };
171
+ var vectorNormal = Math.sqrt(sumOfSquareGramCounts),
172
+ results: string[] = [],
173
+ matchScore;
174
+ // build a results list of [score, str]
175
+ for (var matchIndex in matches) {
176
+ // @ts-expect-error
177
+ matchScore = matches[matchIndex];
178
+ // @ts-expect-error
179
+ results.push([matchScore / (vectorNormal * items[matchIndex][0]), items[matchIndex][1]]);
180
+ }
181
+ var sortDescending = function (a: any, b: any) {
182
+ if (a[0] < b[0]) {
183
+ return 1;
184
+ } else if (a[0] > b[0]) {
185
+ return -1;
186
+ } else {
187
+ return 0;
188
+ }
189
+ };
190
+ results.sort(sortDescending);
191
+ if (this.useLevenshtein) {
192
+ var newResults: string[] = [],
193
+ endIndex = Math.min(50, results.length);
194
+ // truncate somewhat arbitrarily to 50
195
+ // @ts-expect-error
196
+ for (var i = 0; i < endIndex; ++i) {
197
+ // @ts-expect-error
198
+ newResults.push([_distance(results[i][1], normalizedValue), results[i][1]]);
199
+ }
200
+ results = newResults;
201
+ results.sort(sortDescending);
202
+ }
203
+ newResults = [];
204
+ results.forEach(
205
+ function (scoreWordPair: any) {
206
+ if (scoreWordPair[0] >= minMatchScore) {
207
+ // @ts-expect-error
208
+ newResults.push([scoreWordPair[0], this.exactSet[scoreWordPair[1]]]);
209
+ }
210
+ }.bind(this),
211
+ );
212
+ return newResults;
213
+ };
232
214
 
233
- fuzzyset.add = function (value: any) {
234
- var normalizedValue = this._normalizeStr(value);
235
- if (normalizedValue in this.exactSet) {
236
- return false;
237
- }
215
+ fuzzyset.add = function (value: any) {
216
+ var normalizedValue = this._normalizeStr(value);
217
+ if (normalizedValue in this.exactSet) {
218
+ return false;
219
+ }
238
220
 
239
- var i = this.gramSizeLower;
240
- for (i; i < this.gramSizeUpper + 1; ++i) {
241
- this._add(value, i);
242
- }
243
- };
221
+ var i = this.gramSizeLower;
222
+ for (i; i < this.gramSizeUpper + 1; ++i) {
223
+ this._add(value, i);
224
+ }
225
+ };
244
226
 
245
- fuzzyset._add = function (value: string, gramSize: number) {
246
- var normalizedValue = this._normalizeStr(value),
247
- items = this.items[gramSize] || [],
248
- index = items.length;
227
+ fuzzyset._add = function (value: string, gramSize: number) {
228
+ var normalizedValue = this._normalizeStr(value),
229
+ items = this.items[gramSize] || [],
230
+ index = items.length;
249
231
 
250
- items.push(0);
251
- var gramCounts = _gramCounter(normalizedValue, gramSize);
252
- var sumOfSquareGramCounts = 0;
253
- var gram: string;
254
- var gramCount: number;
232
+ items.push(0);
233
+ var gramCounts = _gramCounter(normalizedValue, gramSize);
234
+ var sumOfSquareGramCounts = 0;
235
+ var gram: string;
236
+ var gramCount: number;
255
237
 
256
- for (gram in gramCounts) {
257
- // @ts-expect-error
258
- gramCount = gramCounts[gram];
259
- sumOfSquareGramCounts += Math.pow(gramCount, 2);
260
- if (gram in this.matchDict) {
261
- this.matchDict[gram].push([index, gramCount]);
262
- } else {
263
- this.matchDict[gram] = [[index, gramCount]];
264
- }
265
- }
266
- var vectorNormal = Math.sqrt(sumOfSquareGramCounts);
267
- items[index] = [vectorNormal, normalizedValue];
268
- this.items[gramSize] = items;
269
- this.exactSet[normalizedValue] = value;
270
- };
238
+ for (gram in gramCounts) {
239
+ // @ts-expect-error
240
+ gramCount = gramCounts[gram];
241
+ sumOfSquareGramCounts += Math.pow(gramCount, 2);
242
+ if (gram in this.matchDict) {
243
+ this.matchDict[gram].push([index, gramCount]);
244
+ } else {
245
+ this.matchDict[gram] = [[index, gramCount]];
246
+ }
247
+ }
248
+ var vectorNormal = Math.sqrt(sumOfSquareGramCounts);
249
+ items[index] = [vectorNormal, normalizedValue];
250
+ this.items[gramSize] = items;
251
+ this.exactSet[normalizedValue] = value;
252
+ };
271
253
 
272
- fuzzyset._normalizeStr = function (str: string) {
273
- if (Object.prototype.toString.call(str) !== '[object String]') {
274
- throw new Error('Must use a string as argument to FuzzySet functions');
275
- }
276
- return str.toLowerCase();
277
- };
254
+ fuzzyset._normalizeStr = function (str: string) {
255
+ if (Object.prototype.toString.call(str) !== '[object String]') {
256
+ throw new Error('Must use a string as argument to FuzzySet functions');
257
+ }
258
+ return str.toLowerCase();
259
+ };
278
260
 
279
- // return length of items in set
280
- fuzzyset.length = function () {
281
- var count = 0,
282
- prop;
283
- for (prop in this.exactSet) {
284
- if (this.exactSet.hasOwnProperty(prop)) {
285
- count += 1;
286
- }
287
- }
288
- return count;
289
- };
261
+ // return length of items in set
262
+ fuzzyset.length = function () {
263
+ var count = 0,
264
+ prop;
265
+ for (prop in this.exactSet) {
266
+ if (this.exactSet.hasOwnProperty(prop)) {
267
+ count += 1;
268
+ }
269
+ }
270
+ return count;
271
+ };
290
272
 
291
- // return is set is empty
292
- fuzzyset.isEmpty = function () {
293
- for (var prop in this.exactSet) {
294
- if (this.exactSet.hasOwnProperty(prop)) {
295
- return false;
296
- }
297
- }
298
- return true;
299
- };
273
+ // return is set is empty
274
+ fuzzyset.isEmpty = function () {
275
+ for (var prop in this.exactSet) {
276
+ if (this.exactSet.hasOwnProperty(prop)) {
277
+ return false;
278
+ }
279
+ }
280
+ return true;
281
+ };
300
282
 
301
- // return list of values loaded into set
302
- fuzzyset.values = function () {
303
- var values = [],
304
- prop;
305
- for (prop in this.exactSet) {
306
- if (this.exactSet.hasOwnProperty(prop)) {
307
- values.push(this.exactSet[prop]);
308
- }
309
- }
310
- return values;
311
- };
283
+ // return list of values loaded into set
284
+ fuzzyset.values = function () {
285
+ var values = [],
286
+ prop;
287
+ for (prop in this.exactSet) {
288
+ if (this.exactSet.hasOwnProperty(prop)) {
289
+ values.push(this.exactSet[prop]);
290
+ }
291
+ }
292
+ return values;
293
+ };
312
294
 
313
- // initialization
314
- var i = fuzzyset.gramSizeLower;
315
- for (i; i < fuzzyset.gramSizeUpper + 1; ++i) {
316
- fuzzyset.items[i] = [];
317
- }
318
- // add all the items to the set
319
- for (i = 0; i < arr.length; ++i) {
320
- fuzzyset.add(arr[i]);
321
- }
295
+ // initialization
296
+ var i = fuzzyset.gramSizeLower;
297
+ for (i; i < fuzzyset.gramSizeUpper + 1; ++i) {
298
+ fuzzyset.items[i] = [];
299
+ }
300
+ // add all the items to the set
301
+ for (i = 0; i < arr.length; ++i) {
302
+ fuzzyset.add(arr[i]);
303
+ }
322
304
 
323
- return fuzzyset;
305
+ return fuzzyset;
324
306
  };
325
307
 
326
308
  export default FuzzySet;