Skip to contents

The squids::squids() function generates a sequence of short quasi-unique identifiers (see squids-package for more details). The squids::random_squids() function is a convenience function that randomizes the result before returning it.

Usage

random_squids(x, origin = Sys.time(), follow = NULL, followBy = NULL)

squids(x, origin = Sys.time(), follow = NULL, followBy = NULL)

Arguments

x

The number of identifiers to generate.

origin

The origin to use when generating the SQUIDs. This allows you to reproduce the same sequence of SQUIDs. You can easily get an origin with get_current_origin(). The origin is a timestamp; an object of class POSIXct (see squids-package for more details).

follow

A vector of one or more SQUIDs (or a list; lists are recursively unlist()ed); the highest SQUID will be taken, converted to a timestamp, and used as origin (well, 0.01 second later), so that the new SQUIDs will follow that sequence.

followBy

When following a vector of SQUIDs, this can be used to specify the distance between the two vectors in centiseconds.

Value

A vector of SQUIDs.

Details

SQUIDs are defined as 8-character strings that express a timestamp (the number of centiseconds that passed since the UNIX Epoch) in a base 30 decimal system. The lowest possible SQUID is 00000001 (which corresponds to 1970-01-01 00:00:00 UTC), and the highest possible SQUID is zzzzzzzz, which corresponds to 2177-11-28 11:59:59 UTC. More details are in the squids-package manual page.

Examples

exampleSQUIDs <-
  squids::squids(5);

### Show how SQUIDs are the converted date/time
squids::squids_to_datetime(
  exampleSQUIDs
);
#> [1] "2025-06-07 15:53:33 UTC" "2025-06-07 15:53:33 UTC"
#> [3] "2025-06-07 15:53:33 UTC" "2025-06-07 15:53:33 UTC"
#> [5] "2025-06-07 15:53:33 UTC"

### These seem the same, but if we take these as
### timestamps (seconds passed since the UNIX Epoch)
### and multiply with 100 to see the centiseconds,
### we see the differences:
as.numeric(
  squids::squids_to_datetime(
    exampleSQUIDs
  )
) * 100;
#> [1] 174931161368 174931161369 174931161370 174931161371 174931161372

### Get a sequence following the first one
squids::squids(5, follow=exampleSQUIDs);
#> 🦑 7zyscx2f, 7zyscx2g, 7zyscx2h, 7zyscx2j & 7zyscx2k

### Follow at a distance
squids::squids(
  5,
  follow=exampleSQUIDs,
  followBy = 3
);
#> 🦑 7zyscx2j, 7zyscx2k, 7zyscx2l, 7zyscx2m & 7zyscx2n