A Javascript runtime through v8 for android, sharing code between web and mobile.
class Underscore(private val src: String): JSObject() {
// Bind Underscore.js's contains function to Kotlin for integers
fun contains(list: ArrayList<Int>, index: Int): Boolean {
return JSObject().bind(src).function("contains", arrayListOf(list, index))
}
}
val list: ArrayList<Int> = ArrayList()
list.add(1)
list.add(2)
list.add(3)
val underscore = Underscore(src)
val contains = underscore.contains(list, 3) // true
JSCore also evaluates scripts as per the usual way.
JSContext ctx = new JSContext(); // Javascript VM context
String greeting = (String) ctx.evaluate(""
+ "var message = 'hello world!'"
+ "message.toUpperCase();");
Log.d("Greeting", greeting); // HELLO WORLD!
v8 is used as JSCore’s javascript runtime environment.
JSCore is written entirely in Kotlin.
JSCore is still at the early alpha stages of architecting and c++ support through ndk. If you ‘d like to contribute to this project feel free to pull request and provide ideas through issues.
Copyright (c) 2019, George Karalis.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.