Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
grape-js-emoji
Advanced tools
IMPORTANT NOTE: To get to a working version I had to update the emoji-data submodule to the latest master and then re-run the build script. This way I could get to a working version of the script with an available emoji sheet.
Most macOS and iOS versions allow display and input of emoji. It's nice to show them on
other devices too, and the browser is a good place to do it. This library converts emoji
(either from character codes or colon-sequences like :smile:
) into something that will
work on the host computer - either native character codes, a CSS styled span or a text
representation.
Either clone the git repo, or npm install emoji-js
<link href="emoji.css" rel="stylesheet" type="text/css" />
<script src="emoji.js" type="text/javascript"></script>
<script type="text/javascript">
var emoji = new EmojiConvertor();
// replaces \u{1F604} with platform appropriate content
var output1 = emoji.replace_unified(input);
// replaces :smile: with platform appropriate content
var output2 = emoji.replace_colons(input);
// force text output mode
emoji.text_mode = true;
// show the short-name as a `title` attribute for css/img emoji
emoji.include_title = true;
// change the path to your emoji images (requires trailing slash)
// you can grab the images from the emoji-data link here:
// https://github.com/iamcal/js-emoji/tree/master/build
emoji.img_sets.apple.path = 'http://my-cdn.com/emoji-apple-64/';
emoji.img_sets.apple.sheet = 'http://my-cdn.com/emoji-apple-sheet-64.png';
// Configure this library to use the sheets defined in `img_sets` (see above)
emoji.use_sheet = true;
// find out the auto-detected mode
alert(emoji.replace_mode);
// add some aliases of your own - you can override builtins too
emoji.addAliases({
'doge' : '1f415',
'cat' : '1f346'
});
// remove your custom aliases - this will reset builtins
emoji.removeAliases([
'doge',
'cat',
]);
// convert colons to unicode
emoji.init_env(); // else auto-detection will trigger when we first convert
emoji.replace_mode = 'unified';
emoji.allow_native = true;
var output3 = emoji.replace_colons(input);
</script>
You can view a live demo here.
Prior to version 3.0, the emoji.js
library would instantiate a global object called emoji
, which you would call methods on.
In versions 3.0 and later, the library exposes a single class called EmojiConvertor
which needs to be instantiated manually.
To upgrade old code, simply add this line in a global context:
var emoji = new EmojiConvertor();
The library is designed to be used with the following flow:
:colon:
style<span>
elements with background images or simple images.While the JS library can replace unified emoji codes (as used by iOS6), it's much slower than replacing colon sequences. By translating to and storing colon sequences on the backend, you are able to:
:smile:
and have it appear as an emoji everywhereSome special care may be needed to store emoji in your database. While some characters (e.g. Cloud, U+2601) are
within the Basic Multilingual Plane (BMP), others (e.g. Close Umbrella, U+1F302) are not. As such,
they require 4 bytes of storage to encode each character. Inside MySQL, this requires switching from utf8
storage to utf8mb4
.
You can modify a database and table using a statement like:
ALTER DATABASE my_database DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE my_table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
You will also need to modify your connection character set.
You don't need to worry about this if you translate to colon syntax before storage.
See CHANGES.md
3.4.0 - 2017-11-19
FAQs
A JS Emoji conversion library
The npm package grape-js-emoji receives a total of 1 weekly downloads. As such, grape-js-emoji popularity was classified as not popular.
We found that grape-js-emoji demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.