Last active
February 5, 2021 10:06
-
-
Save liesislukas/58bae7c3d5bf6c32be6af159bf01052d to your computer and use it in GitHub Desktop.
helperGetId
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample usage: | |
// uuid npm v3.3.2 | |
// any-base npm v1.1.0 | |
// const ___getId = require('./getId'); | |
// const branchId = `b-${(await ___getId({})).id}`; | |
const uuid = require('uuid'); | |
const anyBase = require('any-base'); | |
async function helperGetId({}) { | |
// Your code starts here. Do not edit anything above. | |
const fromHex = anyBase(anyBase.HEX, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'); | |
const id = fromHex( | |
uuid() | |
.toLowerCase() | |
.replace(/-/g, ''), | |
); | |
// Your code ends here. Do not edit anything below. | |
return {id}; | |
} | |
module.exports = helperGetId; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment