Skip to content

Commit

Permalink
refactor: rename monotonic generate
Browse files Browse the repository at this point in the history
  • Loading branch information
okkdev authored and rvcas committed Oct 6, 2023
1 parent 509af88 commit 904b5ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/ids/ulid.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions test/ids/ulid_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ 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()
|> check_crockford_characters()

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
Expand Down

0 comments on commit 904b5ef

Please sign in to comment.