Skip to content

Instantly share code, notes, and snippets.

@liesislukas
Last active February 5, 2021 10:06
Show Gist options
  • Save liesislukas/58bae7c3d5bf6c32be6af159bf01052d to your computer and use it in GitHub Desktop.
Save liesislukas/58bae7c3d5bf6c32be6af159bf01052d to your computer and use it in GitHub Desktop.
helperGetId
// 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