Init
This commit is contained in:
commit
4e066bffc9
10017 changed files with 1322084 additions and 0 deletions
7
node_modules/node-emoji/.npmignore
generated
vendored
Normal file
7
node_modules/node-emoji/.npmignore
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
node_modules
|
||||
*.log
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
*.txt
|
||||
test.js
|
||||
coverage
|
||||
3
node_modules/node-emoji/.travis.yml
generated
vendored
Normal file
3
node_modules/node-emoji/.travis.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
21
node_modules/node-emoji/LICENSE
generated
vendored
Normal file
21
node_modules/node-emoji/LICENSE
generated
vendored
Normal 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.
|
||||
43
node_modules/node-emoji/README.md
generated
vendored
Normal file
43
node_modules/node-emoji/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# node-emoji
|
||||
|
||||
[](https://www.npmjs.com/package/node-emoji) [](https://www.npmjs.com/package/node-emoji) [](https://travis-ci.org/omnidan/node-emoji) [](https://david-dm.org/omnidan/node-emoji) [](https://codeclimate.com/github/omnidan/node-emoji) [](https://paypal.me/DanielBugl/10) [](https://gratipay.com/~omnidan/)
|
||||
|
||||
_simple emoji support for node.js projects_
|
||||
|
||||

|
||||
|
||||
## 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'}]`
|
||||
```
|
||||
|
||||
## 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: [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YBMS9EKTNPZHJ)
|
||||
* Gratipay: [](https://gratipay.com/omnidan/)
|
||||
* Bitcoin: 114veSsYoyw2QrXkPTxHD51B5i39TinsBP
|
||||
|
||||

|
||||
1
node_modules/node-emoji/index.js
generated
vendored
Normal file
1
node_modules/node-emoji/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('./lib/emoji');
|
||||
128
node_modules/node-emoji/lib/emoji.js
generated
vendored
Normal file
128
node_modules/node-emoji/lib/emoji.js
generated
vendored
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/*jslint node: true*/
|
||||
require('string.prototype.codepointat');
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* regex to parse emoji in a string - finds emoji, e.g. :coffee:
|
||||
*/
|
||||
var parser = /:([a-zA-Z0-9_\-\+]+):/g;
|
||||
|
||||
/**
|
||||
* Removes colons on either side
|
||||
* of the string if present
|
||||
* @param {string} str
|
||||
* @return {string}
|
||||
*/
|
||||
var trim = function(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 trim(str);
|
||||
} else {
|
||||
str = str.substr(colonIndex + 1);
|
||||
return trim(str);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
/**
|
||||
* Emoji namespace
|
||||
*/
|
||||
var Emoji = module.exports = {
|
||||
emoji: require('./emoji.json')
|
||||
};
|
||||
|
||||
/**
|
||||
* get emoji code from name
|
||||
* @param {string} emoji
|
||||
* @return {string}
|
||||
*/
|
||||
Emoji._get = function _get(emoji) {
|
||||
if (Emoji.emoji.hasOwnProperty(emoji)) {
|
||||
return Emoji.emoji[emoji];
|
||||
}
|
||||
return ':' + emoji + ':';
|
||||
};
|
||||
|
||||
/**
|
||||
* get emoji code from :emoji: string or name
|
||||
* @param {string} emoji
|
||||
* @return {string}
|
||||
*/
|
||||
Emoji.get = function get(emoji) {
|
||||
emoji = trim(emoji);
|
||||
|
||||
return Emoji._get(emoji);
|
||||
};
|
||||
|
||||
/**
|
||||
* get emoji name from code
|
||||
* @param {string} emoji_code
|
||||
* @return {string}
|
||||
*/
|
||||
Emoji.which = function which(emoji_code) {
|
||||
for (var prop in Emoji.emoji) {
|
||||
if (Emoji.emoji.hasOwnProperty(prop)) {
|
||||
if (Emoji.emoji[prop].codePointAt() === emoji_code.codePointAt()) {
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @return {string}
|
||||
*/
|
||||
Emoji.emojify = function emojify(str, on_missing) {
|
||||
if (!str) return '';
|
||||
|
||||
return str.split(parser) // 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);
|
||||
if (emoji.indexOf(':') > -1 && typeof on_missing === 'function') {
|
||||
return on_missing(emoji.substr(1, emoji.length-2));
|
||||
}
|
||||
return emoji;
|
||||
})
|
||||
.join('') // convert back to string
|
||||
;
|
||||
};
|
||||
|
||||
/**
|
||||
* return a random emoji
|
||||
* @return {string}
|
||||
*/
|
||||
Emoji.random = function random() {
|
||||
var emojiKeys = Object.keys(Emoji.emoji);
|
||||
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(Emoji.emoji);
|
||||
var matcher = trim(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),
|
||||
};
|
||||
});
|
||||
}
|
||||
1
node_modules/node-emoji/lib/emoji.json
generated
vendored
Normal file
1
node_modules/node-emoji/lib/emoji.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1304
node_modules/node-emoji/lib/emojifile.js
generated
vendored
Normal file
1304
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
27
node_modules/node-emoji/lib/emojiparse.js
generated
vendored
Normal 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.');
|
||||
}
|
||||
});
|
||||
105
node_modules/node-emoji/package.json
generated
vendored
Normal file
105
node_modules/node-emoji/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "node-emoji@^1.4.1",
|
||||
"scope": null,
|
||||
"escapedName": "node-emoji",
|
||||
"name": "node-emoji",
|
||||
"rawSpec": "^1.4.1",
|
||||
"spec": ">=1.4.1 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/Users/jose/Documents/GitHub/About/node_modules/marked-terminal"
|
||||
]
|
||||
],
|
||||
"_from": "node-emoji@>=1.4.1 <2.0.0",
|
||||
"_id": "node-emoji@1.5.1",
|
||||
"_inCache": true,
|
||||
"_location": "/node-emoji",
|
||||
"_nodeVersion": "6.8.1",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/node-emoji-1.5.1.tgz_1484487574434_0.1159358520526439"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "omnidan",
|
||||
"email": "me@omnidan.net"
|
||||
},
|
||||
"_npmVersion": "3.10.8",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "node-emoji@^1.4.1",
|
||||
"scope": null,
|
||||
"escapedName": "node-emoji",
|
||||
"name": "node-emoji",
|
||||
"rawSpec": "^1.4.1",
|
||||
"spec": ">=1.4.1 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/marked-terminal"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.5.1.tgz",
|
||||
"_shasum": "fd918e412769bf8c448051238233840b2aff16a1",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "node-emoji@^1.4.1",
|
||||
"_where": "/Users/jose/Documents/GitHub/About/node_modules/marked-terminal",
|
||||
"author": {
|
||||
"name": "Daniel Bugl",
|
||||
"email": "daniel.bugl@touchlay.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/omnidan/node-emoji/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"string.prototype.codepointat": "^0.2.0"
|
||||
},
|
||||
"description": "simple emoji support for node.js projects",
|
||||
"devDependencies": {
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.0.2",
|
||||
"should": "^11.1.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "fd918e412769bf8c448051238233840b2aff16a1",
|
||||
"tarball": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.5.1.tgz"
|
||||
},
|
||||
"gitHead": "b0a43f72e84ce612d9d6b72cd564b8c1bbde173b",
|
||||
"homepage": "https://github.com/omnidan/node-emoji#readme",
|
||||
"keywords": [
|
||||
"emoji",
|
||||
"simple",
|
||||
"emoticons",
|
||||
"emoticon",
|
||||
"emojis",
|
||||
"smiley",
|
||||
"smileys",
|
||||
"smilies",
|
||||
"ideogram",
|
||||
"ideograms"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "omnidan",
|
||||
"email": "daniel.bugl@touchlay.com"
|
||||
}
|
||||
],
|
||||
"name": "node-emoji",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"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/*"
|
||||
},
|
||||
"version": "1.5.1"
|
||||
}
|
||||
113
node_modules/node-emoji/test/emoji.js
generated
vendored
Normal file
113
node_modules/node-emoji/test/emoji.js
generated
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*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", function () {
|
||||
var coffee = emoji.get('coffee');
|
||||
should.exist(coffee);
|
||||
coffee.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');
|
||||
});
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
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 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 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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue