nodejs-interop / net.plan99.nodejs.kotlin / NodeJSAPI / cast

cast

fun <reified T> Value.cast(): T

Converts the Value to a JVM type T in the following way:

  1. If the type is an interface not annotated with @FunctionalInterface then a special proxy is returned that knows how to map JavaBean style property methods on that interface to JavaScript properties.
  2. Otherwise, the Value.as method is used with a TypeLiteral so generics are preserved and the best possible translation occurs.