Awesome
base64-emoji
Inspired by base-emoji this module allows for transformation of any binary data to and from emoji using only 64 different emojicons (+1 for padding).
Installation
npm install base64-emoji
Usage
var emoji = require('base64-emoji')
var encoded = emoji.encode('Hello World')
var decoded = emoji.decode(encoded)
console.log(encoded.toString()) // => 🍕📙🕡🌵🎎📙🚢😮🕡🐗🏦🕤🎎📙🕖📫
console.log(decoded.toString()) // => Hello World
API
buffer = emoji.encode(buffer|string, [buffer], [offset])
The encode
function takes a buffer or a string and returns a buffer
containing the encoded bytes. The optional 2nd buffer argument will be
used to store the encoded result. If not provided a new buffer will be
allocated. If an offset is passed as the 3rd argument the input will be
encoded into the buffer at that byte offset. The offset defauls to 0
.
buffer = emoji.decode(buffer|string, [offset], [length])
The decode
function takes a buffer or a string and returns a buffer
containing the decoded bytes. If an offset is passed as the 2nd
argumetn, the input will be decoded from that byte offset. Tye byte
offset defaults to 0
. A length can be passed as the 3rd argument
specifying the number of bytes that should be decoded. The length
defaults to the input byte length.
length = emoji.encodingLength(buffer|string)
Returns the amount of bytes needed to encode the buffer
or string
given as input.
License
MIT