jsStrndup function

String jsStrndup(
  1. JSContext ctx,
  2. String str,
  3. int n
)

Implementation

String jsStrndup(JSContext ctx, String str, int n) {
  final ret = js_strndup(ctx.ref, str.toNativeUtf8(), n);
  return String.fromCharCodes(
    Uint16List.view(
      ret.cast<Uint16>().asTypedList(str.length).buffer,
      0,
      str.length,
    ),
  );
}