mirror of
https://github.com/Yu-Vitaqua-fer-Chronos/NULID.git
synced 2025-07-27 07:30:51 +00:00
Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
|
59d884d18f | ||
|
62bb09c7f0 | ||
|
952412e5f5 | ||
|
a5d234e0c2 |
4
.github/workflows/docs.yml
vendored
4
.github/workflows/docs.yml
vendored
|
@ -47,10 +47,10 @@ jobs:
|
||||||
uses: actions/configure-pages@v3
|
uses: actions/configure-pages@v3
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-pages-artifact@v1
|
uses: actions/upload-pages-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ env.deploy-dir }}
|
path: ${{ env.deploy-dir }}
|
||||||
|
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v1
|
uses: actions/deploy-pages@v4
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "1.3.0"
|
version = "1.3.1"
|
||||||
author = "Yu Vitaqua fer Chronos"
|
author = "Yu Vitaqua fer Chronos"
|
||||||
description = "An implementation of ULID!"
|
description = "An implementation of ULID!"
|
||||||
license = "CC0"
|
license = "CC0"
|
||||||
|
@ -11,4 +11,4 @@ srcDir = "src"
|
||||||
|
|
||||||
requires "nim >= 2.0.0"
|
requires "nim >= 2.0.0"
|
||||||
requires "nint128 >= 0.3.2"
|
requires "nint128 >= 0.3.2"
|
||||||
requires "crockfordb32 >= 1.1.0"
|
requires "crockfordb32 >= 2.0.0"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
{.define: crockfordb32NintSupport.}
|
||||||
|
|
||||||
import std/[
|
import std/[
|
||||||
times,
|
times,
|
||||||
json
|
json
|
||||||
|
@ -58,7 +60,7 @@ type
|
||||||
ULIDGenerator* = ref object
|
ULIDGenerator* = ref object
|
||||||
## A `ULID` generator object, contains details needed to follow the spec.
|
## A `ULID` generator object, contains details needed to follow the spec.
|
||||||
## A generator was made to be compliant with the ULID spec and also to be
|
## A generator was made to be compliant with the ULID spec and also to be
|
||||||
## threadsafe not use globals that could change.
|
## threadsafe.
|
||||||
when NoLocks:
|
when NoLocks:
|
||||||
lastTime: int64 # Timestamp of last ULID, 48 bits
|
lastTime: int64 # Timestamp of last ULID, 48 bits
|
||||||
when not defined(js):
|
when not defined(js):
|
||||||
|
@ -328,9 +330,12 @@ func `$`*(ulid: ULID): string =
|
||||||
result = JsBigInt.encode(ulid.toInt128(), 26)
|
result = JsBigInt.encode(ulid.toInt128(), 26)
|
||||||
|
|
||||||
# std/json support
|
# std/json support
|
||||||
proc `%`*(u: ULID): JsonNode = newJString($u)
|
proc `%`*(u: ULID): JsonNode =
|
||||||
|
## Serializes a `ULID` to JSON.
|
||||||
|
newJString($u)
|
||||||
|
|
||||||
proc to*(j: JsonNode, _: typedesc[ULID]): ULID =
|
proc to*(j: JsonNode, _: typedesc[ULID]): ULID =
|
||||||
|
## Deserializes a `ULID` from JSON.
|
||||||
if j.kind != JString:
|
if j.kind != JString:
|
||||||
raise newException(JsonKindError, "Expected a string!")
|
raise newException(JsonKindError, "Expected a string!")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue