Gravatar for undefined
Log in to like
7 Likes

encode a string or a buffer to base64

Use in your code Learn more
bit import bit.utils/string/to-base64

toBase64 (val: (string|Buffer)) : string

encode a string or a buffer to base64

Example

 toBase64('foo bar') // => Zm9vIGJhcg==
 toBase64(new Buffer('foo bar')) // => Zm9vIGJhcg==

Argument

val: (string|Buffer)

string or buffer to encode

Returns

string

base64 encoded string

Test Summary

#toBase64() should return a base64 encoded string for string `foo bar`Pass
#toBase64() should return a base64 encoded string for buffer `foo bar`Pass
#toBase64() should not mutate given referencePass