Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-emoji

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-emoji - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

11

lib/emoji.js

@@ -62,8 +62,15 @@ /*jslint node: true*/

* @param {string} str
* @param {function} on_missing (gets emoji name without :: and returns a proper emoji if no emoji was found)
* @return {string}
*/
Emoji.emojify = function emojify(str) {
Emoji.emojify = function emojify(str, on_missing) {
return str.split(parser) // parse emoji via regex
.map(function parseEmoji(s, i) {
return (i % 2 === 0) ? s : Emoji._get(s); // every second element is an emoji, e.g. "test :fast_forward:" -> [ "test ", "fast_forward" ]
// every second element is an emoji, e.g. "test :fast_forward:" -> [ "test ", "fast_forward" ]
if (i % 2 === 0) return s;
var emoji = Emoji._get(s);
if (emoji.indexOf(':') > -1 && typeof on_missing === 'function') {
return on_missing(emoji.substr(1, emoji.length-2));
}
return emoji;
})

@@ -70,0 +77,0 @@ .join('') // convert back to string

2

package.json
{
"name": "node-emoji",
"version": "1.3.0",
"version": "1.3.1",
"description": "simple emoji support for node.js projects",

@@ -5,0 +5,0 @@ "author": "Daniel Bugl <daniel.bugl@touchlay.com>",

@@ -55,2 +55,10 @@ /*jslint node: true*/

});
it("should replace unknown emoji using provided cb function", function () {
var coffee = emoji.emojify('I :unknown_emoji: :star: :another_one:', function(name) {
return name;
});
should.exist(coffee);
coffee.should.be.exactly('I unknown_emoji ⭐️ another_one');
});
});

@@ -57,0 +65,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc