(s: string | Buffer, urlSafe?: boolean)
| 116 | * @return {String} base64 encode format string. |
| 117 | */ |
| 118 | export 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. |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…