bit/utils/string/to-base64

encode a string or a buffer to base64

0 Likes
Use in your codeLearn 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