Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/javascript) ](https://repo1.maven.org/maven2/dev/icerock/moko/javascript) ![kotlin-version](https://img.shields.io/badge/kotlin-1.4.32-orange)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/javascript) ](https://repo1.maven.org/maven2/dev/icerock/moko/javascript/) ![kotlin-version](https://img.shields.io/badge/kotlin-1.4.32-orange)

# Mobile Kotlin javascript
This is a Kotlin MultiPlatform library that allows you to run JavaScript code from common Kotlin code
Expand Down Expand Up @@ -46,10 +46,15 @@ dependencies {
## Usage
```kotlin
val javaScriptEngine = JavaScriptEngine()
val result: JsType = javaScriptEngine.evaluate(
context = emptyMap(),
script = """ "Hello" + "World" """.trimIndent()
)
val result: JsType = try {
javaScriptEngine.evaluate(
context = emptyMap(),
script = """ "Hello" + "World" """.trimIndent()
)
} catch (ex: JavaScriptEvaluationException) {
// Handle script evaluation error
JsType.Null
}
if (result is JsType.Str) {
println(result.value)
}
Expand Down Expand Up @@ -83,4 +88,4 @@ More detailed guide for contributers see in [contributing guide](CONTRIBUTING.md
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.
limitations under the License.