@confuzzle/ecoji-buffers
v1.0.0
Published
Encode and decode arbitrary data as emoji
Downloads
4
Readme
@confuzzle/ecoji-buffers
Encode and decode arbitrary data as emoji. Since it uses ecoji-js under the hood it may be compatible with the ecoji standard, but has not been tested for this.
Huge thanks are owed to the following authors whose work is used in this package under license:
- Keith Turner - ecoji standard
- Dmytro Borysovskyi - ecoji-js
- Ryan Shea - emojicoding
This package differs from the packages above in that it operates with buffers. ecoji-js only accepts and produces strings, so is less convenient for arbitrary binary data. emojicoding accepts only arrays of emoji to decode, meaning strings need to be split into emoji (non-trivial). See grapheme-splitter for a possible way to do this.
ecoji-buffers
also differs from these packages in that it is a standalone package with no dependencies.
Functions
encode(x)
- encodes aUint8Array
orBuffer
as an emoji stringdecode(x)
- decodes an emoji string to aBuffer
Example Usage
const ecoji = require('@confuzzle/ecoji-buffers');
const x = Buffer.from('Hello world');
const y = ecoji.encode(x);
console.log(y); // 🏯🔩🚗🌷🍉🤣🦒🕊👡
const z = ecoji.decode(y).toString();
console.log(z); // Hello world
Limitations
This package has not been optimised for performance in any way, and has not been extensively tested. Use at your own risk.