MCPcopy Create free account
hub / github.com/node-modules/utility / base64encode

Function base64encode

src/crypto.ts:118–127  ·  view source on GitHub ↗
(s: string | Buffer, urlSafe?: boolean)

Source from the content-addressed store, hash-verified

116 * @return {String} base64 encode format string.
117 */
118export function base64encode(s: string | Buffer, urlSafe?: boolean): string {
119 if (!Buffer.isBuffer(s)) {
120 s = Buffer.from(s);
121 }
122 let encode = s.toString('base64');
123 if (urlSafe) {
124 encode = encode.replace(/\+/g, '-').replace(/\//g, '_');
125 }
126 return encode;
127}
128
129/**
130 * Base64 string decode.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…