diff --git a/nulid.nimble b/nulid.nimble index be56715..88fadad 100644 --- a/nulid.nimble +++ b/nulid.nimble @@ -1,7 +1,7 @@ # Package -version = "0.1.1" -author = "Mythical Forest Collective" +version = "0.2.0" +author = "Yu Vitaqua fer Chronos" description = "An implementation of ULID!" license = "CC0" srcDir = "src" diff --git a/src/nulid.nim b/src/nulid.nim index 3d94649..cfdddf6 100644 --- a/src/nulid.nim +++ b/src/nulid.nim @@ -9,6 +9,8 @@ import pkg/[ nint128 ] +import pkg/nint128/vendor/stew/endians2 + const HighUint80 = u128("1208925819614629174706176") type @@ -20,13 +22,17 @@ type lastTime: int64 = 0 random: UInt128 = u128(0) +func swapBytes(x: Int128): Int128 = + result.lo = swapBytes(cast[uint64](x.hi)) + result.hi = cast[int64](swapBytes(x.lo)) + +proc toArray*[T](oa: openArray[T], size: static Slice[int]): array[size.len, T] = + result[0..