From 904b5efc51b06466f17ae0354eaa9f0215dec62d Mon Sep 17 00:00:00 2001 From: okkdev Date: Thu, 5 Oct 2023 16:18:07 +0200 Subject: [PATCH] refactor: rename monotonic generate --- src/ids/ulid.gleam | 8 ++++---- test/ids/ulid_test.gleam | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ids/ulid.gleam b/src/ids/ulid.gleam index 6ad130f..1aa9e1e 100644 --- a/src/ids/ulid.gleam +++ b/src/ids/ulid.gleam @@ -53,9 +53,9 @@ pub fn start() -> StartResult(Message) { /// import ids/ulid /// /// let assert Ok(channel) = ulid.start() -/// let Ok(id) = ulid.safe_generate(channel) +/// let Ok(id) = ulid.monotonic_generate(channel) /// ``` -pub fn safe_generate(channel: Subject(Message)) -> Result(String, String) { +pub fn monotonic_generate(channel: Subject(Message)) -> Result(String, String) { actor.call(channel, Generate, 1000) } @@ -67,9 +67,9 @@ pub fn safe_generate(channel: Subject(Message)) -> Result(String, String) { /// import ids/ulid /// /// let assert Ok(channel) = ulid.start() -/// let Ok(id) = ulid.safe_from_timestamp(channel, 1_696_346_659_217) +/// let Ok(id) = ulid.monotonic_from_timestamp(channel, 1_696_346_659_217) /// ``` -pub fn safe_from_timestamp( +pub fn monotonic_from_timestamp( channel: Subject(Message), timestamp: Int, ) -> Result(String, String) { diff --git a/test/ids/ulid_test.gleam b/test/ids/ulid_test.gleam index 75170cb..fc5141c 100644 --- a/test/ids/ulid_test.gleam +++ b/test/ids/ulid_test.gleam @@ -72,7 +72,7 @@ pub fn decode_test() { pub fn monotonicity_test() { let assert Ok(actor) = ulid.start() - let assert Ok(id_1) = ulid.safe_generate(actor) + let assert Ok(id_1) = ulid.monotonic_generate(actor) id_1 |> check_length() |> check_starting_character() @@ -80,10 +80,10 @@ pub fn monotonicity_test() { let timestamp = 1_696_346_660_217 let assert Ok(#(_, random_1)) = - ulid.safe_from_timestamp(actor, timestamp) + ulid.monotonic_from_timestamp(actor, timestamp) |> result.then(ulid.decode) let assert Ok(#(_, random_2)) = - ulid.safe_from_timestamp(actor, timestamp) + ulid.monotonic_from_timestamp(actor, timestamp) |> result.then(ulid.decode) random_2