perpare for more compact bit operations in JS (#16728)

This commit is contained in:
flywind
2021-01-19 07:57:16 -06:00
committed by GitHub
parent 0300203e81
commit a0fddfecd4
2 changed files with 20 additions and 7 deletions

View File

@@ -0,0 +1,12 @@
when defined(js):
type
ArrayBuffer* = ref object of JsRoot
Float64Array* = ref object of JsRoot
Uint32Array* = ref object of JsRoot
func newArrayBuffer*(n: int): ArrayBuffer {.importjs: "new ArrayBuffer(#)".}
func newFloat64Array*(buffer: ArrayBuffer): Float64Array {.importjs: "new Float64Array(#)".}
func newUint32Array*(buffer: ArrayBuffer): Uint32Array {.importjs: "new Uint32Array(#)".}
func `[]`*(arr: Uint32Array, i: int): uint32 {.importjs: "#[#]".}
func `[]=`*(arr: Float64Array, i: int, v: float) {.importjs: "#[#] = #".}