@codecademy/brand 0.13.50-alpha.42683e7695.0 → 0.13.50-alpha.492f686f23.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.
|
@@ -173,6 +173,9 @@ function worker() {
|
|
|
173
173
|
|
|
174
174
|
// if the title starts with the query
|
|
175
175
|
if (t.lower.startsWith(q.query)) {
|
|
176
|
+
bonus += 200;
|
|
177
|
+
} else if (t.lower.startsWith(q.query.slice(0, 3))) {
|
|
178
|
+
// or at least the first 3 chars
|
|
176
179
|
bonus += 100;
|
|
177
180
|
}
|
|
178
181
|
|
|
@@ -180,7 +183,12 @@ function worker() {
|
|
|
180
183
|
if (t.lower === q.query) {
|
|
181
184
|
bonus += 100;
|
|
182
185
|
}
|
|
183
|
-
|
|
186
|
+
|
|
187
|
+
// if there are some matching chars and the title is within 3 chars length of the query
|
|
188
|
+
if (fromChars > 1 && Math.abs(t.lower.length - q.query.length) <= 3) {
|
|
189
|
+
bonus += 100;
|
|
190
|
+
}
|
|
191
|
+
return fromChars + (fromChars > 1 ? fromPopularity : 0) + bonus;
|
|
184
192
|
}
|
|
185
193
|
|
|
186
194
|
// returns { value: string, highlight: boolean }[]
|
|
@@ -213,7 +221,7 @@ function worker() {
|
|
|
213
221
|
* Prefill the array for each char in the title.
|
|
214
222
|
* For each char, we keep an array of the consecutive matches the char is a part of.
|
|
215
223
|
*/
|
|
216
|
-
const
|
|
224
|
+
const cmcsForTitleChars = Array(t.lower.length).fill(0).map(() => []);
|
|
217
225
|
|
|
218
226
|
/*
|
|
219
227
|
* Overlay the query onto the title to see which chars match.
|
|
@@ -269,7 +277,7 @@ function worker() {
|
|
|
269
277
|
cmc.value += q.query[i - shift];
|
|
270
278
|
|
|
271
279
|
// include this cmc for this char
|
|
272
|
-
|
|
280
|
+
cmcsForTitleChars[i].push(cmc);
|
|
273
281
|
} else if (cmc) {
|
|
274
282
|
// set to null so that the next match starts a new cmc
|
|
275
283
|
cmc = null;
|
|
@@ -285,7 +293,7 @@ function worker() {
|
|
|
285
293
|
// "authentication" or other words ending in "ion"
|
|
286
294
|
const minMatchLength = Math.ceil(avgQueryWordLength ** 0.65);
|
|
287
295
|
const charScores = [];
|
|
288
|
-
for (const cmcs of
|
|
296
|
+
for (const cmcs of cmcsForTitleChars) {
|
|
289
297
|
let score = 0;
|
|
290
298
|
for (const cmc of cmcs) {
|
|
291
299
|
// if the string of consecutive matching chars meets the minMatchLength
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/brand",
|
|
3
3
|
"description": "Brand component library for Codecademy",
|
|
4
|
-
"version": "0.13.50-alpha.
|
|
4
|
+
"version": "0.13.50-alpha.492f686f23.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@emotion/is-prop-valid": "1.2.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"dist/**/[A-Z]**/[A-Z]*.js",
|
|
48
48
|
"dist/**/[A-Z]**/index.js"
|
|
49
49
|
],
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "d2a330c5425c9eb7e15d24400d142b71da340cba"
|
|
51
51
|
}
|