Deprecate JS String match, matches and concat functions

This commit is contained in:
Abduqodiri Qurbonzoda
2021-09-01 11:17:00 +03:00
committed by Space
parent 3fefed5131
commit 921af8e98c
4 changed files with 19 additions and 1 deletions
@@ -228,9 +228,13 @@ public actual inline fun String.substring(startIndex: Int): String = asDynamic()
@kotlin.internal.InlineOnly
public actual inline fun String.substring(startIndex: Int, endIndex: Int): String = asDynamic().substring(startIndex, endIndex)
@Deprecated("Use String.plus() instead", ReplaceWith("this + str"))
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun String.concat(str: String): String = asDynamic().concat(str)
@Deprecated("Use Regex.findAll() instead or invoke matches() on String dynamically: this.asDynamic().match(regex)")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun String.match(regex: String): Array<String>? = asDynamic().match(regex)
@@ -46,8 +46,10 @@ public actual fun String.endsWith(suffix: String, ignoreCase: Boolean = false):
return regionMatches(length - suffix.length, suffix, 0, suffix.length, ignoreCase)
}
@Deprecated("Use Regex.matches() instead", ReplaceWith("regex.toRegex().matches(this)"))
@DeprecatedSinceKotlin(warningSince = "1.6")
public fun String.matches(regex: String): Boolean {
@Suppress("DEPRECATION")
val result = this.match(regex)
return result != null && result.size != 0
}