The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Convert `lib/string` to TypeScript (#69424)
Fraser3cbf8919a7ac
diff --git a/frontend/src/metabase/lib/string.js b/frontend/src/metabase/lib/string.tssimilarity index 66%rename from frontend/src/metabase/lib/string.jsrename to frontend/src/metabase/lib/string.tsindex 5dd7aced30f..23e68bc7cff 100644--- a/frontend/src/metabase/lib/string.js+++ b/frontend/src/metabase/lib/string.ts@@ -1,23 +1,15 @@import _ from "underscore";// Creates a regex that will find an order dependent, case insensitive substring. All whitespace will be rendered as ".*" in the regex, to create a fuzzy search.-export function createMultiwordSearchRegex(input) {+export function createMultiwordSearchRegex(input: string) {if (input) {return new RegExp(_.map(input.split(/\s+/), regexpEscape).join(".*?"), "i");}}// prefix special characters with "\" for creating a regex-export function regexpEscape(s) {+export function regexpEscape(s: string) {const regexpSpecialChars = /[\^\$\\\.\*\+\?\(\)\[\]\{\}\|]/g;// "$&" in the replacement string is replaced with the matched stringreturn s.replace(regexpSpecialChars, "\\$&");}--export function caseInsensitiveSearch(haystack, needle) {- return (- !needle ||- (haystack != null &&- haystack.toLowerCase().indexOf(needle.toLowerCase()) >= 0)- );-}