Skip to content

Commit

Permalink
Typed arrays. New Uint8Array static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky committed Jan 5, 2025
1 parent a1f1037 commit c398c3a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
15 changes: 15 additions & 0 deletions kotlin-js/src/jsMain/kotlin/js/typedarrays/Alphabet.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Automatically generated - do not modify!

package js.typedarrays

import seskar.js.JsValue

sealed external interface Alphabet {
companion object {
@JsValue("base64")
val base64: Alphabet

@JsValue("base64url")
val base64url: Alphabet
}
}
18 changes: 18 additions & 0 deletions kotlin-js/src/jsMain/kotlin/js/typedarrays/LastChunkHandling.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Automatically generated - do not modify!

package js.typedarrays

import seskar.js.JsValue

sealed external interface LastChunkHandling {
companion object {
@JsValue("loose")
val loose: LastChunkHandling

@JsValue("strict")
val strict: LastChunkHandling

@JsValue("stop-before-partial")
val stopBeforePartial: LastChunkHandling
}
}
18 changes: 17 additions & 1 deletion kotlin-js/src/jsMain/kotlin/js/typedarrays/Uint8Array.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import js.array.ReadonlyArray
import js.buffer.ArrayBuffer
import js.buffer.ArrayBufferLike
import js.iterable.JsIterable
import js.objects.JsPlainObject

open external class Uint8Array<B : ArrayBufferLike>(
override val buffer: B,
Expand All @@ -27,5 +28,20 @@ open external class Uint8Array<B : ArrayBufferLike>(
inline fun toUByteArray(): UByteArray =
toByteArray().asUByteArray()

companion object : TypedArrayCompanion<Uint8Array<ArrayBuffer>, Byte>
companion object : TypedArrayCompanion<Uint8Array<ArrayBuffer>, Byte> {
fun fromBase64(
string: String,
options: FromBase64Options = definedExternally,
)

@JsPlainObject
interface FromBase64Options {
val alphabet: Alphabet?
val lastChunkHandling: LastChunkHandling?
}

fun fromHex(
string: String,
)
}
}

0 comments on commit c398c3a

Please sign in to comment.