string-is-uuid
is a UUID validator for node.js.
It offers a single function, isUuid ()
, that does just the same as the version ()
function from uuid
package.
npm install string-is-uuid
const {isUuid} = require ('string-is-uuid')
try {
const version = isUuid (presumedUUID)
// console.log (`OK, this really is a UUID, ver. #${version}`)
}
catch (err) {
// console.log (err)
}
There are plenty of UUID validators available on npm. Still, every one of them the author checked out to date is implemented via regular expressions, that impose a certain performance overhead.
For example, as benchmarks show, the aforementioned version ()
's latency from uuid
v.11.1.0 can be reduced by 78%.