This commit is contained in:
Aevann1 2021-12-13 22:28:32 +00:00
parent 628618df89
commit e031240dff
3749 changed files with 1120848 additions and 1 deletions

1
node_modules/node-emoji/.github/FUNDING.yml generated vendored Normal file
View file

@ -0,0 +1 @@
github: omnidan

3
node_modules/node-emoji/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,3 @@
language: node_js
node_js:
- "0.10"

21
node_modules/node-emoji/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Daniel Bugl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

86
node_modules/node-emoji/README.md generated vendored Normal file
View file

@ -0,0 +1,86 @@
# node-emoji
[![NPM version (1.0.3)](https://img.shields.io/npm/v/node-emoji.svg?style=flat-square)](https://www.npmjs.com/package/node-emoji) [![NPM Downloads](https://img.shields.io/npm/dm/node-emoji.svg?style=flat-square)](https://www.npmjs.com/package/node-emoji) [![Build Status](https://img.shields.io/travis/omnidan/node-emoji/master.svg?style=flat-square)](https://travis-ci.org/omnidan/node-emoji) [![Dependencies](https://img.shields.io/david/omnidan/node-emoji.svg?style=flat-square)](https://david-dm.org/omnidan/node-emoji) [![https://paypal.me/DanielBugl/9](https://img.shields.io/badge/donate-paypal-yellow.svg?style=flat-square)](https://paypal.me/DanielBugl/9)
_simple emoji support for node.js projects_
![node-emoji example](https://i.imgur.com/yIo5Uux.png)
**Help wanted:** We are looking for volunteers to maintain this project, if you are interested, feel free to contact me at [me@omnidan.net](mailto:me@omnidan.net)
## Installation
To install `node-emoji`, you need [node.js](http://nodejs.org/) and [npm](https://github.com/npm/npm#super-easy-install). :rocket:
Once you have that set-up, just run `npm install --save node-emoji` in your project directory. :ship:
You're now ready to use emoji in your node projects! Awesome! :metal:
## Usage
```javascript
var emoji = require('node-emoji')
emoji.get('coffee') // returns the emoji code for coffee (displays emoji on terminals that support it)
emoji.which(emoji.get('coffee')) // returns the string "coffee"
emoji.get(':fast_forward:') // `.get` also supports github flavored markdown emoji (http://www.emoji-cheat-sheet.com/)
emoji.emojify('I :heart: :coffee:!') // replaces all :emoji: with the actual emoji, in this case: returns "I ❤️ ☕️!"
emoji.random() // returns a random emoji + key, e.g. `{ emoji: '❤️', key: 'heart' }`
emoji.search('cof') // returns an array of objects with matching emoji's. `[{ emoji: '☕️', key: 'coffee' }, { emoji: ⚰', key: 'coffin'}]`
emoji.unemojify('I ❤️ 🍕') // replaces the actual emoji with :emoji:, in this case: returns "I :heart: :pizza:"
emoji.find('🍕') // Find the `pizza` emoji, and returns `({ emoji: '🍕', key: 'pizza' })`;
emoji.find('pizza') // Find the `pizza` emoji, and returns `({ emoji: '🍕', key: 'pizza' })`;
emoji.hasEmoji('🍕') // Validate if this library knows an emoji like `🍕`
emoji.hasEmoji('pizza') // Validate if this library knowns a emoji with the name `pizza`
emoji.strip('⚠️ 〰️ 〰️ low disk space') // Strips the string from emoji's, in this case returns: "low disk space".
emoji.replace('⚠️ 〰️ 〰️ low disk space', (emoji) => `${emoji.key}:`) // Replace emoji's by callback method: "warning: low disk space"
```
## Options
### onMissing
`emoji.emojify(str, onMissing)`
As second argument, `emojify` takes an handler to parse unknown emojis. Provide a function to add your own handler:
```js
var onMissing = function (name) {
return name;
});
var emojified = emoji.emojify('I :unknown_emoji: :star: :another_one:', onMissing);
// emojified: I unknown_emoji ⭐️ another_one
```
### format
`emoji.emojify(str, onMissing, format)`
As third argument, `emojify` takes an handler to wrap parsed emojis. Provide a function to place emojis in custom elements, and to apply your custom styling:
```js
var format = function (code, name) {
return '<img alt="' + code + '" src="' + name + '.png" />';
});
var emojified = emoji.emojify('I :unknown_emoji: :star: :another_one:', null, format);
// emojified: I <img alt="❤️" src="heart.png" /> <img alt="☕️" src="coffee.png" />
```
## Adding new emoji
Emoji come from js-emoji (Thanks a lot :thumbsup:). You can get a JSON file with all emoji here: https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json
To update the list or add custom emoji, clone this repository and put them into `lib/emojifile.js`.
Then run `npm run-script emojiparse` in the project directory or `node emojiparse` in the lib directory.
This should generate the new emoji.json file and output `Done.`.
That's all, you now have more emoji you can use! :clap:
## Support / Donations
If you want to support node-emoji development, please consider donating (it helps me keeping my projects active and alive!):
* Paypal: [![daniel.bugl@gmail.com](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YBMS9EKTNPZHJ)
* Bitcoin: [1J5eKsrAcPPLv5gPxSjSUkXnbJpkhndFgA](bitcoin:1J5eKsrAcPPLv5gPxSjSUkXnbJpkhndFgA)
## Special Thanks
... to Dan Perkins (@Aesth3tical) for sponsoring this project via [GitHub Sponsors](https://github.com/sponsors/omnidan)!
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fomnidan%2Fnode-emoji.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fomnidan%2Fnode-emoji?ref=badge_large)

1
node_modules/node-emoji/index.js generated vendored Normal file
View file

@ -0,0 +1 @@
module.exports = require('./lib/emoji');

303
node_modules/node-emoji/lib/emoji.js generated vendored Normal file
View file

@ -0,0 +1,303 @@
/*jslint node: true*/
var toArray = require('lodash/toArray');
var emojiByName = require('./emoji.json');
"use strict";
/**
* regex to parse emoji in a string - finds emoji, e.g. :coffee:
*/
var emojiNameRegex = /:([a-zA-Z0-9_\-\+]+):/g;
/**
* regex to trim whitespace
* use instead of String.prototype.trim() for IE8 support
*/
var trimSpaceRegex = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
/**
* Removes colons on either side
* of the string if present
* @param {string} str
* @return {string}
*/
function stripColons (str) {
var colonIndex = str.indexOf(':');
if (colonIndex > -1) {
// :emoji: (http://www.emoji-cheat-sheet.com/)
if (colonIndex === str.length - 1) {
str = str.substring(0, colonIndex);
return stripColons(str);
} else {
str = str.substr(colonIndex + 1);
return stripColons(str);
}
}
return str;
}
/**
* Adds colons to either side
* of the string
* @param {string} str
* @return {string}
*/
function wrapColons (str) {
return (typeof str === 'string' && str.length > 0) ? ':' + str + ':' : str;
}
/**
* Ensure that the word is wrapped in colons
* by only adding them, if they are not there.
* @param {string} str
* @return {string}
*/
function ensureColons (str) {
return (typeof str === 'string' && str[0] !== ':') ? wrapColons(str) : str;
}
// Non spacing mark, some emoticons have them. It's the 'Variant Form',
// which provides more information so that emoticons can be rendered as
// more colorful graphics. FE0E is a unicode text version, where as FE0F
// should be rendered as a graphical version. The code gracefully degrades.
var NON_SPACING_MARK = String.fromCharCode(65039); // 65039 - '' - 0xFE0F;
var nonSpacingRegex = new RegExp(NON_SPACING_MARK, 'g')
// Remove the non-spacing-mark from the code, never send a stripped version
// to the client, as it kills graphical emoticons.
function stripNSB (code) {
return code.replace(nonSpacingRegex, '');
};
// Reversed hash table, where as emojiByName contains a { heart: '❤' }
// dictionary emojiByCode contains { ❤: 'heart' }. The codes are normalized
// to the text version.
var emojiByCode = Object.keys(emojiByName).reduce(function(h,k) {
h[stripNSB(emojiByName[k])] = k;
return h;
}, {});
/**
* Emoji namespace
*/
var Emoji = {
emoji: emojiByName,
};
/**
* get emoji code from name. return emoji code back if code is passed in.
* @param {string} emoji
* @return {string}
*/
Emoji._get = function _get (emoji) {
if (emojiByCode[stripNSB(emoji)]) {
return emoji;
} else if (emojiByName.hasOwnProperty(emoji)) {
return emojiByName[emoji];
}
return ensureColons(emoji);
};
/**
* get emoji code from :emoji: string or name
* @param {string} emoji
* @return {string}
*/
Emoji.get = function get (emoji) {
emoji = stripColons(emoji);
return Emoji._get(emoji);
};
/**
* find the emoji by either code or name
* @param {string} nameOrCode The emoji to find, either `coffee`, `:coffee:` or ``;
* @return {object}
*/
Emoji.find = function find (nameOrCode) {
return Emoji.findByName(nameOrCode) || Emoji.findByCode(nameOrCode);
};
/**
* find the emoji by name
* @param {string} name The emoji to find either `coffee` or `:coffee:`;
* @return {object}
*/
Emoji.findByName = function findByName (name) {
var stripped = stripColons(name);
var emoji = emojiByName[stripped];
return emoji ? ({ emoji: emoji, key: stripped }) : undefined;
};
/**
* find the emoji by code (emoji)
* @param {string} code The emoji to find; for example `` or ``
* @return {object}
*/
Emoji.findByCode = function findByCode (code) {
var stripped = stripNSB(code);
var name = emojiByCode[stripped];
// lookup emoji to ensure the Variant Form is returned
return name ? ({ emoji: emojiByName[name], key: name }) : undefined;
};
/**
* Check if an emoji is known by this library
* @param {string} nameOrCode The emoji to validate, either `coffee`, `:coffee:` or ``;
* @return {object}
*/
Emoji.hasEmoji = function hasEmoji (nameOrCode) {
return Emoji.hasEmojiByName(nameOrCode) || Emoji.hasEmojiByCode(nameOrCode);
};
/**
* Check if an emoji with given name is known by this library
* @param {string} name The emoji to validate either `coffee` or `:coffee:`;
* @return {object}
*/
Emoji.hasEmojiByName = function hasEmojiByName (name) {
var result = Emoji.findByName(name);
return !!result && result.key === stripColons(name);
};
/**
* Check if a given emoji is known by this library
* @param {string} code The emoji to validate; for example `` or ``
* @return {object}
*/
Emoji.hasEmojiByCode = function hasEmojiByCode (code) {
var result = Emoji.findByCode(code);
return !!result && stripNSB(result.emoji) === stripNSB(code);
};
/**
* get emoji name from code
* @param {string} emoji
* @param {boolean} includeColons should the result include the ::
* @return {string}
*/
Emoji.which = function which (emoji_code, includeColons) {
var code = stripNSB(emoji_code);
var word = emojiByCode[code];
return includeColons ? wrapColons(word) : word;
};
/**
* emojify a string (replace :emoji: with an emoji)
* @param {string} str
* @param {function} on_missing (gets emoji name without :: and returns a proper emoji if no emoji was found)
* @param {function} format (wrap the returned emoji in a custom element)
* @return {string}
*/
Emoji.emojify = function emojify (str, on_missing, format) {
if (!str) return '';
return str.split(emojiNameRegex) // parse emoji via regex
.map(function parseEmoji(s, i) {
// 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);
var isMissing = emoji.indexOf(':') > -1;
if (isMissing && typeof on_missing === 'function') {
return on_missing(s);
}
if (!isMissing && typeof format === 'function') {
return format(emoji, s);
}
return emoji;
})
.join('') // convert back to string
;
};
/**
* return a random emoji
* @return {string}
*/
Emoji.random = function random () {
var emojiKeys = Object.keys(emojiByName);
var randomIndex = Math.floor(Math.random() * emojiKeys.length);
var key = emojiKeys[randomIndex];
var emoji = Emoji._get(key);
return { key: key, emoji: emoji };
}
/**
* return an collection of potential emoji matches
* @param {string} str
* @return {Array.<Object>}
*/
Emoji.search = function search (str) {
var emojiKeys = Object.keys(emojiByName);
var matcher = stripColons(str)
var matchingKeys = emojiKeys.filter(function(key) {
return key.toString().indexOf(matcher) === 0;
});
return matchingKeys.map(function(key) {
return {
key: key,
emoji: Emoji._get(key),
};
});
}
/**
* unemojify a string (replace emoji with :emoji:)
* @param {string} str
* @return {string}
*/
Emoji.unemojify = function unemojify (str) {
if (!str) return '';
var words = toArray(str);
return words.map(function(word) {
return Emoji.which(word, true) || word;
}).join('');
};
/**
* replace emojis with replacement value
* @param {string} str
* @param {function|string} the string or callback function to replace the emoji with
* @param {boolean} should trailing whitespaces be cleaned? Defaults false
* @return {string}
*/
Emoji.replace = function replace (str, replacement, cleanSpaces) {
if (!str) return '';
var replace = typeof replacement === 'function' ? replacement : function() { return replacement; };
var words = toArray(str);
var replaced = words.map(function(word, idx) {
var emoji = Emoji.findByCode(word);
if (emoji && cleanSpaces && words[idx + 1] === ' ') {
words[idx + 1] = '';
}
return emoji ? replace(emoji) : word;
}).join('');
return cleanSpaces ? replaced.replace(trimSpaceRegex, '') : replaced;
};
/**
* remove all emojis from a string
* @param {string} str
* @return {string}
*/
Emoji.strip = function strip (str) {
return Emoji.replace(str, '', true);
};
module.exports = Emoji;

1
node_modules/node-emoji/lib/emoji.json generated vendored Normal file

File diff suppressed because one or more lines are too long

1785
node_modules/node-emoji/lib/emojifile.js generated vendored Normal file

File diff suppressed because it is too large Load diff

27
node_modules/node-emoji/lib/emojiparse.js generated vendored Normal file
View file

@ -0,0 +1,27 @@
// parse emojifile.js and output emoji.json
var fs = require('fs'),
path = require('path'),
emoji = require('./emojifile').data;
// parse
var parsed_emoji = {};
for (var key in emoji) {
if (emoji.hasOwnProperty(key)) {
var names = emoji[key][3];
names = names.constructor === Array ? names : [names];
var emoji_char = emoji[key][0][0];
for (var name of names) {
parsed_emoji[name] = emoji_char;
}
}
}
// write to emoji.json
fs.writeFile(path.join(__dirname, 'emoji.json'), JSON.stringify(parsed_emoji), function(err) {
if(err) {
console.error('Error:', err);
} else {
console.log('Done.');
}
});

74
node_modules/node-emoji/package.json generated vendored Normal file
View file

@ -0,0 +1,74 @@
{
"_args": [
[
"node-emoji@1.11.0",
"/d"
]
],
"_from": "node-emoji@1.11.0",
"_id": "node-emoji@1.11.0",
"_inBundle": false,
"_integrity": "sha512-wo2DpQkQp7Sjm2A0cq+sN7EHKO6Sl0ctXeBdFZrL9T9+UywORbufTcTZxom8YqpLQt/FqNMUkOpkZrJVYSKD3A==",
"_location": "/node-emoji",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "node-emoji@1.11.0",
"name": "node-emoji",
"escapedName": "node-emoji",
"rawSpec": "1.11.0",
"saveSpec": null,
"fetchSpec": "1.11.0"
},
"_requiredBy": [
"/tailwindcss"
],
"_resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz",
"_spec": "1.11.0",
"_where": "/d",
"author": {
"name": "Daniel Bugl",
"email": "daniel.bugl@touchlay.com"
},
"bugs": {
"url": "https://github.com/omnidan/node-emoji/issues"
},
"dependencies": {
"lodash": "^4.17.21"
},
"description": "simple emoji support for node.js projects",
"devDependencies": {
"istanbul": "^0.4.5",
"mocha": "^9.0.3",
"should": "^13.2.3"
},
"homepage": "https://github.com/omnidan/node-emoji#readme",
"keywords": [
"emoji",
"simple",
"emoticons",
"emoticon",
"emojis",
"smiley",
"smileys",
"smilies",
"ideogram",
"ideograms"
],
"license": "MIT",
"main": "index.js",
"name": "node-emoji",
"repository": {
"type": "git",
"url": "git+https://github.com/omnidan/node-emoji.git"
},
"scripts": {
"coverage": "istanbul cover _mocha test",
"emojiparse": "node lib/emojiparse.js",
"prepublish": "npm run test",
"test": "mocha --require should --bail --reporter spec test/*",
"watch": "mocha --require should --bail --reporter spec test/* --watch"
},
"version": "1.11.0"
}

308
node_modules/node-emoji/test/emoji.js generated vendored Normal file
View file

@ -0,0 +1,308 @@
/*jslint node: true*/
/*jslint expr: true*/
/*global describe, it*/
"use strict";
var should = require('should');
var emoji = require('../index');
describe("emoji.js", function () {
describe("get(emoji)", function () {
it("should return an emoji code when passed a string", function () {
var coffee = emoji.get('coffee');
should.exist(coffee);
coffee.should.be.exactly('☕');
});
it("should return emoji code back when passed an emoji code", function () {
var dancers = emoji.get('👯‍♀️');
should.exist(dancers);
dancers.should.be.exactly('👯‍♀️');
})
it("should support github flavored markdown emoji", function () {
var coffee = emoji.get(':coffee:');
should.exist(coffee);
coffee.should.be.exactly('☕');
});
});
describe("random()", function () {
it("should return a random emoji and the corresponding key", function () {
var result = emoji.random();
should.exist(result);
should.exist(result.key);
should.exist(result.emoji);
result.emoji.should.be.exactly(emoji.get(result.key));
});
});
describe("which(emoji_code)", function () {
it("should return name of the emoji", function () {
var coffee = emoji.which('☕');
should.exist(coffee);
coffee.should.be.exactly('coffee');
});
it("should work for differently formed characters", function () {
var umbrella = emoji.which('☔');
should.exist(umbrella);
umbrella.should.be.exactly('umbrella_with_rain_drops');
});
it("should return the same name for differently formed characters", function () {
var umbrella1 = emoji.which('☔');
should.exist(umbrella1);
var umbrella2 = emoji.which('☔️');
should.exist(umbrella2);
umbrella1.should.equal(umbrella2);
});
it("should work for flags", function() {
var mexico = emoji.which('🇲🇽');
should.exists(mexico);
mexico.should.be.exactly('flag-mx');
var marocco = emoji.which('🇲🇦');
should.exists(marocco);
marocco.should.be.exactly('flag-ma');
// see issue #21
mexico.should.not.equal(marocco);
});
});
describe("emojify(str)", function () {
it("should parse :emoji: in a string and replace them with the right emoji", function () {
var coffee = emoji.emojify('I :heart: :coffee:! - :hushed::star::heart_eyes: ::: test : : :+1:+');
should.exist(coffee);
coffee.should.be.exactly('I ❤️ ☕! - 😯⭐😍 ::: test : : 👍+');
});
it("should handle flags correctly", function() {
var flags = emoji.emojify('Mexico :flag-mx: and Marocco :flag-ma: are not the same');
should.exists(flags);
flags.should.be.exactly('Mexico 🇲🇽 and Marocco 🇲🇦 are not the same');
});
it("should leave unknown emoji", function () {
var coffee = emoji.emojify('I :unknown_emoji: :star: :another_one:');
should.exist(coffee);
coffee.should.be.exactly('I :unknown_emoji: ⭐ :another_one:');
});
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');
});
it("should wrap emoji using provided format function", function () {
var coffee = emoji.emojify('I :heart: :coffee:', null, function(code, name) {
return '<img alt="' + code + '" src="' + name + '.png" />';
});
should.exist(coffee);
coffee.should.be.exactly('I <img alt="❤️" src="heart.png" /> <img alt="☕" src="coffee.png" />');
});
it("should not wrap unknown using provided format function", function () {
var coffee = emoji.emojify('I :unknown_emoji: :coffee:', null, function(code, name) {
return '<img alt="' + code + '" src="' + name + '.png" />';
});
should.exist(coffee);
coffee.should.be.exactly('I :unknown_emoji: <img alt="☕" src="coffee.png" />');
});
it("should replace unknown emojis and wrap known emojis using cb functions", function () {
var coffee = emoji.emojify('I :unknown_emoji: :coffee:',
function(name) {
return name;
},
function(code, name) {
return '<img alt="' + code + '" src="' + name + '.png" />';
}
);
should.exist(coffee);
coffee.should.be.exactly('I unknown_emoji <img alt="☕" src="coffee.png" />');
});
});
it("should return an emoji code", function () {
var coffee = emoji.emoji.coffee;
should.exist(coffee);
coffee.should.be.exactly('☕');
});
describe("search(str)", function () {
it("should return partially matched emojis", function () {
var matchingEmojis = emoji.search("cof");
matchingEmojis.length.should.not.eql(0);
matchingEmojis.forEach(function(emoji) {
emoji.key.should.match(/^cof/);
});
});
it("should only include emojies that begin with the search", function () {
var matchingEmojis = emoji.search("ca");
matchingEmojis.length.should.not.eql(0);
matchingEmojis.forEach(function(emoji) {
var index = emoji.key.indexOf("ca");
index.should.be.exactly(0);
});
});
it("should match when you include the colon", function () {
var matchingEmojis = emoji.search(":c");
matchingEmojis.length.should.not.eql(0);
matchingEmojis.forEach(function(emoji) {
var index = emoji.key.indexOf("c");
index.should.be.exactly(0);
});
});
it("should return an empty array when no matching emojis are found", function () {
var matchingEmojis = emoji.search("notAnEmoji");
matchingEmojis.length.should.be.exactly(0);
});
});
describe("unemojify(str)", function () {
it("should parse emoji and replace them with :emoji:", function() {
var coffee = emoji.unemojify('I ❤️ ☕️! - 😯⭐️😍 ::: test : : 👍+');
should.exist(coffee);
coffee.should.be.exactly('I :heart: :coffee:! - :hushed::star::heart_eyes: ::: test : : :thumbsup:+');
})
it("should leave unknown emoji", function () {
// Emoji :melting_face: (U+1FAE0) Unicode 14.0 draft: https://emojipedia.org/unicode-14.0
var coffee = emoji.unemojify('I ⭐️ :another_one: 🫠');
should.exist(coffee);
coffee.should.be.exactly('I :star: :another_one: 🫠');
});
it("should parse a complex emoji like woman-kiss-woman and replace it with :woman-kiss-woman:", function() {
var coffee = emoji.unemojify('I love 👩‍❤️‍💋‍👩');
should.exist(coffee);
coffee.should.be.exactly('I love :woman-kiss-woman:');
});
it("should parse flags correctly", function () {
var flags = emoji.unemojify('The flags of 🇲🇽 and 🇲🇦 are not the same');
should.exists(flags);
flags.should.be.exactly('The flags of :flag-mx: and :flag-ma: are not the same');
});
});
describe('find emoji', function() {
it('Should be able to find a emoji by :name:', function() {
var result = emoji.find(':heart:')
should.exists(result);
result.should.eql({ emoji: '❤️', key: 'heart' });
});
it('Should be able to find an emoji by name', function() {
var result = emoji.find('heart');
should.exists(result);
result.should.eql({ emoji: '❤️', key: 'heart' });
});
it('Should be able to find an emoji by code', function() {
var result = emoji.find('❤');
should.exists(result);
result.should.eql({ emoji: '❤️', key: 'heart' });
});
it('Should return `undefined` for unknown emojis', function() {
var result = emoji.find('unknown_emoji');
should.not.exists(result);
})
});
describe('hasEmoji', function() {
it('Should be able to check a emoji by :name:', function() {
var result = emoji.hasEmoji(':heart:');
result.should.equal(true)
});
it('Should be able to check a emoji by name', function() {
var result = emoji.hasEmoji('heart');
result.should.equal(true);
});
it('Should be able to check a emoji by code text form)', function() {
var result = emoji.hasEmoji('❤');
result.should.equal(true);
});
it('Should be able to check a emoji by code in variant form', function() {
var result = emoji.hasEmoji('❤️');
result.should.equal(true);
});
it('Should return false for unknown emoji names', function() {
var result = emoji.hasEmoji(':pizza-kiss-coffee:');
result.should.equal(false);
});
it('Should return false for unknown emoji codes', function() {
var result = emoji.hasEmoji('🍕❤️‍💋‍☕');
result.should.equal(false);
});
});
describe('replace', function() {
it('Should be able to strip emojis', function() {
var result = emoji.replace('Host: eseaps001 Addr: 10.XX.XX.XX: - ⚠️ 〰️ 〰️ low disk space', '', true);
result.should.equal('Host: eseaps001 Addr: 10.XX.XX.XX: - low disk space');
});
it('Should keep the trailing spaces when not explicitly told to clean', function() {
var result = emoji.replace('Host: eseaps001 Addr: 10.XX.XX.XX: - ⚠️ 〰️ 〰️ low disk space', '');
result.should.equal('Host: eseaps001 Addr: 10.XX.XX.XX: - low disk space');
});
it('Should be able to strip a emoji by code text form', function() {
var result = emoji.replace('I ❤ coffee', '', true);
result.should.equal('I coffee');
});
it('Should be able to strip a emoji by code in variant form', function() {
var result = emoji.replace('I ❤️ cleaning', '', true);
result.should.equal('I cleaning');
});
it('Should be able to strip complex emojis', function() {
var result = emoji.replace('Where did this 👩‍❤️‍💋‍👩 happen?', '', true);
result.should.equal('Where did this happen?');
});
it('Should be able to strip flag emojis', function() {
var result = emoji.replace('There is no flag 🇲🇽', '', true);
result.should.equal('There is no flag');
});
it('Should be able to replace by callback function', function() {
var result = emoji.replace('There is no ⚠ on my hard drive', function (emoji) {
return emoji.key;
});
result.should.equal('There is no warning on my hard drive');
});
it('Non existing complex emojis are known to be ignored', function() {
var result = emoji.replace('Some 🍕❤️‍💋‍☕ emoji', '');
result.should.not.equal('Some emoji');
});
});
describe('strip', function() {
it('Should be able to strip emojis', function() {
var result = emoji.strip('Host: eseaps001 Addr: 10.XX.XX.XX: - ⚠️ 〰️ 〰️ low disk space');
result.should.equal('Host: eseaps001 Addr: 10.XX.XX.XX: - low disk space');
});
});
});