Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

to-base64

v1.0.0arrow_drop_down
v1.0.0
v0.0.1
STATUS
Passing
DOWNLOADS
26
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
2 years ago
SIZE
7 KB
encode a string or a buffer to base64
2 contributors
Use to-base64 in your project ?
Copied
npm i @bit/bit.utils.string.to-base64
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
revert changes
reload
toggle layout
maximize
toBase64("foo bar"); // => Zm9vIGJhcg==
toBase64(new Buffer("foo bar")); // => Zm9vIGJhcg==
modifieddraft
chevron_left
chevron_right
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 reference

Pass