Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions manifests/micro-utilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
"description": "Every modern runtime provides a way to convert byte array to and from base64.",
"example": "// From base64 to Uint8Array\nconst bytes = Uint8Array.fromBase64(base64)\n// From Uint8Array to base64\nconst base64 = bytes.toBase64()"
},
"snippet::base64-id": {
"id": "snippet::base64-id",
"type": "simple",
"description": "You can use `crypto.randomBytes` with `Buffer.prototype.toString` to generate a random base64 id",
"example": "import crypto from 'node:crypto'\nconst id = crypto.randomBytes(15).toString('base64').replaceAll('+', '-').replaceAll('/', '_')"
Comment on lines +72 to +73
Copy link
Copy Markdown
Contributor

@SuperchupuDev SuperchupuDev Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the late comment but we should probably recommend Uint8Array over Buffer due to it being a built-in javascript feature, now that it has base64 support

sindre has a blog post that goes in depth about this topic: https://sindresorhus.com/blog/goodbye-nodejs-buffer

example with Uint8Array + web crypto api (no imports needed):

crypto.getRandomValues(new Uint8Array(15)).toBase64();

Copy link
Copy Markdown
Contributor Author

@gameroman gameroman Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the original package also uses node:crypto module I decided to keep it simple

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can one of you open an issue so we can look into it?

i think you may be right and we should just use uint8arrays but lets track it in a new issue

},
"snippet::call-bind": {
"id": "snippet::call-bind",
"type": "simple",
Expand Down Expand Up @@ -402,6 +408,11 @@
"moduleName": "base64-js",
"replacements": ["snippet::base64"]
},
"base64id": {
"type": "module",
"moduleName": "base64id",
"replacements": ["snippet::base64-id"]
},
"call-bind": {
"type": "module",
"moduleName": "call-bind",
Expand Down