Share your code. Components are building blocks, you are the architect.

string/to-base64
v1.0.0
1.0.0
0.0.1
Contributors
Gravatar for undefined
bit
0
MIT
PUBLIC
1
0     DEPENDENCIES
Build: pass
BuildPass
Build Status: pass

encode a string or a buffer to base64

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set @bit:registry https://node.bitsrc.io
Use string/to-base64 in your project
npm i @bit/bit.utils.string.to-base64
Copied

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