xk6-codename
Generate random, pronounceable codenames
Usage
For convenient use, the default export of the module is a codename() function, it just needs to be imported and it is ready for use.
import codename from "k6/x/codename";
export default function () {
console.log(`Hello, ${codename()}`); # Hello, mint-bishop
}
The examples directory contains examples of how to use the xk6-codename extension. A k6 binary containing the xk6-codename extension is required to run the examples.
If the search path also contains the k6 command, don't forget to specify which k6 you want to run (for example ./k6).
API
The API consists of only one function:
codename(): generate a codename
The default export of the module is the codename() function.
import codename from "k6/x/codename";
export default function () {
console.log(`Hello, ${codename(4)}`); # Hello, rich-humbug-787b
}
The function has an optional parameter, the length of the token. If this is not zero, then the generated name is supplemented with a randomly generated hexadecimal token of the specified length. Using a token reduces the probability of name collisions.
Build
The xk6 build tool can be used to build a k6 that will include xk6-codename extension:
xk6 build --with codeberg.org/szkiba/xk6-codename@latest
For more build options and how to use xk6, check out the xk6 documentation.