JS backend: using native implementations in kotlin_lib.js for String.startsWith, String.endsWith and String.contains.
This commit is contained in:
@@ -25,21 +25,14 @@ public inline fun String.endsWith(ch: Char): Boolean {
|
|||||||
return if (s > 0) charAt(s - 1) == ch else false
|
return if (s > 0) charAt(s - 1) == ch else false
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline fun String.startsWith(text: String): Boolean {
|
native
|
||||||
val size = text.length
|
fun String.startsWith(s:String):Boolean = noImpl
|
||||||
return if (size <= this.length) {
|
|
||||||
substring(0, size) == text
|
|
||||||
} else false
|
|
||||||
}
|
|
||||||
|
|
||||||
public inline fun String.endsWith(text: String): Boolean {
|
native
|
||||||
val matchSize = text.length
|
fun String.endsWith(s:String):Boolean = noImpl
|
||||||
val thisSize = this.length
|
|
||||||
return if (matchSize <= thisSize) {
|
|
||||||
substring(thisSize - matchSize, thisSize) == text
|
|
||||||
} else false
|
|
||||||
}
|
|
||||||
|
|
||||||
|
native
|
||||||
|
fun String.contains(s:String):Boolean = noImpl
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a copy of this string capitalised if it is not empty or already starting with an uppper case letter, otherwise returns this
|
* Returns a copy of this string capitalised if it is not empty or already starting with an uppper case letter, otherwise returns this
|
||||||
|
|||||||
Reference in New Issue
Block a user