refactor hash in JS backend (#16863)
This commit is contained in:
parent
b8e8eaae66
commit
111092e8aa
2 changed files with 39 additions and 29 deletions
|
|
@ -1,12 +1,20 @@
|
|||
when defined(js):
|
||||
import std/jsbigints
|
||||
|
||||
type
|
||||
ArrayBuffer* = ref object of JsRoot
|
||||
Float64Array* = ref object of JsRoot
|
||||
Uint32Array* = ref object of JsRoot
|
||||
BigUint64Array* = 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 newBigUint64Array*(buffer: ArrayBuffer): BigUint64Array {.importjs: "new BigUint64Array(#)".}
|
||||
|
||||
func `[]`*(arr: Uint32Array, i: int): uint32 {.importjs: "#[#]".}
|
||||
func `[]`*(arr: BigUint64Array, i: int): JsBigInt {.importjs: "#[#]".}
|
||||
func `[]=`*(arr: Float64Array, i: int, v: float) {.importjs: "#[#] = #".}
|
||||
|
||||
proc hasJsBigInt*(): bool =
|
||||
asm """`result` = typeof BigInt != 'undefined'"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue