node and browser bindings for gleam
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add buig int

Peter c1d01c9d 4c54dad2

+62 -1
+27
src/big_int_ffi.mjs
··· 1 + export function add(a, b) { 2 + return a + b; 3 + } 4 + 5 + export function multiply(a, b) { 6 + return a * b; 7 + } 8 + 9 + export function subtract(a, b) { 10 + return a - b; 11 + } 12 + 13 + export function modulo(a, b) { 14 + return a % b; 15 + } 16 + 17 + export function power(a, b) { 18 + return a ** b; 19 + } 20 + 21 + export function divide(a, b) { 22 + return a / b; 23 + } 24 + 25 + export function from(a) { 26 + return BigInt(a); 27 + }
+28 -1
src/plinth/javascript/big_int.gleam
··· 1 1 pub type BigInt 2 2 3 - @external(javascript, "process", "hrtime") 3 + /// `+` operation 4 + @external(javascript, "../../big_int_ffi.mjs", "add") 5 + pub fn add(a: BigInt, b: BigInt) -> BigInt 6 + 7 + /// `*` operation 8 + @external(javascript, "../../big_int_ffi.mjs", "multiply") 9 + pub fn multiply(a: BigInt, b: BigInt) -> BigInt 10 + 11 + /// `-` operation 12 + @external(javascript, "../../big_int_ffi.mjs", "subtract") 4 13 pub fn subtract(a: BigInt, b: BigInt) -> BigInt 14 + 15 + /// `%` operation 16 + @external(javascript, "../../big_int_ffi.mjs", "modulo") 17 + pub fn modulo(a: BigInt, b: BigInt) -> BigInt 18 + 19 + /// `**` operation 20 + @external(javascript, "../../big_int_ffi.mjs", "power") 21 + pub fn power(a: BigInt, b: BigInt) -> BigInt 22 + 23 + /// `/` operation 24 + @external(javascript, "../../big_int_ffi.mjs", "divide") 25 + pub fn divide(a: BigInt, b: BigInt) -> BigInt 26 + 27 + @external(javascript, "../../big_int_ffi.mjs", "from") 28 + pub fn from_int(a: Int) -> BigInt 29 + 30 + @external(javascript, "../../big_int_ffi.mjs", "from") 31 + pub fn from_string(a: String) -> BigInt
+7
test/javascript/big_int_test.gleam
··· 1 + import plinth/javascript/big_int 2 + import gleeunit/should 3 + 4 + pub fn add_test() { 5 + big_int.from_int(1) 6 + |> should.equal(big_int.from_string("1")) 7 + }