Skip to content

Commit

Permalink
Add comments w/ if/then
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev authored Apr 3, 2024
1 parent 5ffed6d commit 9ad34f9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions docs/_assets/js/api-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@
onmessage = function({ data: { docs, search } }) {
const regexForTerm = (query) => {
const escaped = query.replace(/([\.\*\+\?\|\(\)\[\]\\])/g, '\\$1');
return query.toLowerCase() !== query
? new RegExp(escaped.replace(/([A-Z])/g, "[a-z]*$1"))
: new RegExp(escaped, "i");
if (query.toLowerCase() != query) {
// Regexp that matches CamelCase subbits: "BiSe" is
// "[a-z]*Bi[a-z]*Se" and matches "BitSet", "ABitSet", ...
return new RegExp(escaped.replace(/([A-Z])/g,"[a-z]*$1"));
}
// if query is all lower case make a normal case insensitive search
return new RegExp(escaped, "i");
};

const searchRegex = regexForTerm(search);
Expand Down Expand Up @@ -68,4 +72,4 @@ onmessage = function({ data: { docs, search } }) {
.filter(filterPackages)
.forEach(messageParentIfMatches(pack));
});
};
};

0 comments on commit 9ad34f9

Please sign in to comment.