I'm in a situation where I need to run some javascript in a place where I cannot use external packages.
Ideally the function should take a string as parameter and return a string in the format of a uuid (not random), based on the string parameter of course.
I've been searching all over the internet but except a few npm packages I could not find a simple and short function for doing so, since most of the functions are just random uuidv4 functions.
Since I need this to run some js in an external application, it is important that no external dependencies are used, and also the shorter the better.
Use case:
I have an entity without an id (uuid) field.
It does have 2 other ids however.
Before I persist it I want to generate an id in the format of a uuid based on a concatenated string of ${fooId}-${barId}
so I will be able to get the resource by this id from the API.
If I did not have the limitation of not being able to use external dependencies / npm packages and scripts, I would have used the uuid package and the uuidv5. Sadly I do not have this possibility, so I thought it would be possible to to this in a single vanilla js function.
If I was not clear before I need to figure out what to put here
const stringToUuid = (str) => {
// return string formatted as a uuid, based on the str parameter
}