@mkody/twitch-emoticons 2.9.6 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +530 -169
- package/dist/TwitchEmoticons.cjs +950 -0
- package/dist/TwitchEmoticons.esm.min.js +7 -0
- package/dist/TwitchEmoticons.esm.min.js.map +7 -0
- package/dist/TwitchEmoticons.min.js +2 -20
- package/dist/TwitchEmoticons.min.js.map +4 -4
- package/package.json +99 -72
- package/src/index.js +38 -12
- package/src/struct/BTTVEmote.js +72 -74
- package/src/struct/Channel.js +48 -48
- package/src/struct/Emote.js +71 -71
- package/src/struct/EmoteFetcher.js +358 -322
- package/src/struct/EmoteParser.js +95 -84
- package/src/struct/EmoteTypeMapper.js +9 -9
- package/src/struct/FFZEmote.js +91 -93
- package/src/struct/SevenTVEmote.js +88 -90
- package/src/struct/TwitchEmote.js +72 -71
- package/src/util/Collection.js +69 -55
- package/src/util/Constants.js +30 -30
- package/typings/index.d.cts +254 -0
- package/typings/index.d.ts +216 -99
- package/.jsdoc.json +0 -46
- package/.nvmrc +0 -1
- package/docs/BTTVEmote.html +0 -1532
- package/docs/Channel.html +0 -824
- package/docs/Collection.html +0 -798
- package/docs/Emote.html +0 -832
- package/docs/EmoteFetcher.html +0 -3741
- package/docs/EmoteParser.html +0 -1187
- package/docs/FFZEmote.html +0 -1686
- package/docs/SevenTVEmote.html +0 -1596
- package/docs/TwitchEmote.html +0 -1528
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -978
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -1049
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/index.html +0 -233
- package/docs/scripts/collapse.js +0 -39
- package/docs/scripts/commonNav.js +0 -28
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/nav.js +0 -12
- package/docs/scripts/polyfill.js +0 -4
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/scripts/search.js +0 -99
- package/docs/struct_BTTVEmote.js.html +0 -162
- package/docs/struct_Channel.js.html +0 -132
- package/docs/struct_Emote.js.html +0 -159
- package/docs/struct_EmoteFetcher.js.html +0 -429
- package/docs/struct_EmoteParser.js.html +0 -172
- package/docs/struct_FFZEmote.js.html +0 -185
- package/docs/struct_SevenTVEmote.js.html +0 -180
- package/docs/struct_TwitchEmote.js.html +0 -159
- package/docs/styles/jsdoc.css +0 -776
- package/docs/styles/prettify.css +0 -80
- package/docs/util_Collection.js.html +0 -151
- package/eslint.config.mjs +0 -215
- package/jest.config.js +0 -198
- package/test/BTTV.test.js +0 -48
- package/test/FFZ.test.js +0 -71
- package/test/SevenTV.test.js +0 -71
- package/test/ToFromObject.test.js +0 -156
- package/test/Twitch.test.js +0 -64
- package/test/__snapshots__/ToFromObject.test.js.snap +0 -121
- package/test/other.test.js +0 -72
package/docs/scripts/search.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var searchAttr = 'data-search-mode';
|
|
3
|
-
function contains(a,m){
|
|
4
|
-
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m) !== -1;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
//on search
|
|
8
|
-
document.getElementById("nav-search").addEventListener("keyup", function(event) {
|
|
9
|
-
var search = this.value.toUpperCase();
|
|
10
|
-
|
|
11
|
-
if (!search) {
|
|
12
|
-
//no search, show all results
|
|
13
|
-
document.documentElement.removeAttribute(searchAttr);
|
|
14
|
-
|
|
15
|
-
document.querySelectorAll("nav > ul > li:not(.level-hide)").forEach(function(elem) {
|
|
16
|
-
elem.style.display = "block";
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
if (typeof hideAllButCurrent === "function"){
|
|
20
|
-
//let's do what ever collapse wants to do
|
|
21
|
-
hideAllButCurrent();
|
|
22
|
-
} else {
|
|
23
|
-
//menu by default should be opened
|
|
24
|
-
document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
|
|
25
|
-
elem.style.display = "block";
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
//we are searching
|
|
30
|
-
document.documentElement.setAttribute(searchAttr, '');
|
|
31
|
-
|
|
32
|
-
//show all parents
|
|
33
|
-
document.querySelectorAll("nav > ul > li").forEach(function(elem) {
|
|
34
|
-
elem.style.display = "block";
|
|
35
|
-
});
|
|
36
|
-
document.querySelectorAll("nav > ul").forEach(function(elem) {
|
|
37
|
-
elem.style.display = "block";
|
|
38
|
-
});
|
|
39
|
-
//hide all results
|
|
40
|
-
document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
|
|
41
|
-
elem.style.display = "none";
|
|
42
|
-
});
|
|
43
|
-
//show results matching filter
|
|
44
|
-
document.querySelectorAll("nav > ul > li > ul a").forEach(function(elem) {
|
|
45
|
-
if (!contains(elem.parentNode, search)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
elem.parentNode.style.display = "block";
|
|
49
|
-
});
|
|
50
|
-
//hide parents without children
|
|
51
|
-
document.querySelectorAll("nav > ul > li").forEach(function(parent) {
|
|
52
|
-
var countSearchA = 0;
|
|
53
|
-
parent.querySelectorAll("a").forEach(function(elem) {
|
|
54
|
-
if (contains(elem, search)) {
|
|
55
|
-
countSearchA++;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
var countUl = 0;
|
|
60
|
-
var countUlVisible = 0;
|
|
61
|
-
parent.querySelectorAll("ul").forEach(function(ulP) {
|
|
62
|
-
// count all elements that match the search
|
|
63
|
-
if (contains(ulP, search)) {
|
|
64
|
-
countUl++;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// count all visible elements
|
|
68
|
-
var children = ulP.children
|
|
69
|
-
for (i=0; i<children.length; i++) {
|
|
70
|
-
var elem = children[i];
|
|
71
|
-
if (elem.style.display != "none") {
|
|
72
|
-
countUlVisible++;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
if (countSearchA == 0 && countUl === 0){
|
|
78
|
-
//has no child at all and does not contain text
|
|
79
|
-
parent.style.display = "none";
|
|
80
|
-
} else if(countSearchA == 0 && countUlVisible == 0){
|
|
81
|
-
//has no visible child and does not contain text
|
|
82
|
-
parent.style.display = "none";
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
document.querySelectorAll("nav > ul.collapse_top").forEach(function(parent) {
|
|
86
|
-
var countVisible = 0;
|
|
87
|
-
parent.querySelectorAll("li").forEach(function(elem) {
|
|
88
|
-
if (elem.style.display !== "none") {
|
|
89
|
-
countVisible++;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
if (countVisible == 0) {
|
|
94
|
-
//has no child at all and does not contain text
|
|
95
|
-
parent.style.display = "none";
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
});
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<title>struct/BTTVEmote.js - Documentation</title>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<script src="scripts/prettify/prettify.js"></script>
|
|
10
|
-
<script src="scripts/prettify/lang-css.js"></script>
|
|
11
|
-
<!--[if lt IE 9]>
|
|
12
|
-
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
13
|
-
<![endif]-->
|
|
14
|
-
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
15
|
-
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
16
|
-
<script src="scripts/nav.js" defer></script>
|
|
17
|
-
|
|
18
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
|
|
22
|
-
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
|
23
|
-
<label for="nav-trigger" class="navicon-button x">
|
|
24
|
-
<div class="navicon"></div>
|
|
25
|
-
</label>
|
|
26
|
-
|
|
27
|
-
<label for="nav-trigger" class="overlay"></label>
|
|
28
|
-
|
|
29
|
-
<nav >
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<h2><a href="index.html">Home</a></h2><h2><a href="https://github.com/mkody/twitch-emoticons" target="_blank" class="menu-item" id="github_link" >GitHub</a></h2><h3>Classes</h3><ul><li><a href="BTTVEmote.html">BTTVEmote</a><ul class='methods'><li data-type='method'><a href="BTTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#toObject">toObject</a></li><li data-type='method'><a href="BTTVEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="Channel.html">Channel</a><ul class='methods'><li data-type='method'><a href="Channel.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#toObject">toObject</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#fetchTwitchEmotes">fetchTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fromObject">fromObject</a></li></ul></li><li><a href="EmoteParser.html">EmoteParser</a><ul class='methods'><li data-type='method'><a href="EmoteParser.html#parse">parse</a></li></ul></li><li><a href="FFZEmote.html">FFZEmote</a><ul class='methods'><li data-type='method'><a href="FFZEmote.html#toLink">toLink</a></li><li data-type='method'><a href="FFZEmote.html#toObject">toObject</a></li><li data-type='method'><a href="FFZEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="SevenTVEmote.html">SevenTVEmote</a><ul class='methods'><li data-type='method'><a href="SevenTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#toObject">toObject</a></li><li data-type='method'><a href="SevenTVEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="TwitchEmote.html">TwitchEmote</a><ul class='methods'><li data-type='method'><a href="TwitchEmote.html#toLink">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#toObject">toObject</a></li><li data-type='method'><a href="TwitchEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#find">find</a></li><li data-type='method'><a href="Collection.html#filter">filter</a></li><li data-type='method'><a href="Collection.html#map">map</a></li></ul></li></ul>
|
|
33
|
-
|
|
34
|
-
</nav>
|
|
35
|
-
|
|
36
|
-
<div id="main">
|
|
37
|
-
|
|
38
|
-
<h1 class="page-title">struct/BTTVEmote.js</h1>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<section>
|
|
47
|
-
<article>
|
|
48
|
-
<pre class="prettyprint source linenums"><code>const Emote = require('./Emote');
|
|
49
|
-
const Constants = require('../util/Constants');
|
|
50
|
-
|
|
51
|
-
/** @augments Emote */
|
|
52
|
-
class BTTVEmote extends Emote {
|
|
53
|
-
/**
|
|
54
|
-
* A BTTV emote.
|
|
55
|
-
* @param {Channel} channel - Channel this emote belongs to.
|
|
56
|
-
* @param {string} id - ID of the emote.
|
|
57
|
-
* @param {data} data - The raw emote data.
|
|
58
|
-
*/
|
|
59
|
-
constructor(channel, id, data) {
|
|
60
|
-
super(channel, id, data);
|
|
61
|
-
this.type = 'bttv';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The channel of this emote's creator.
|
|
66
|
-
* Not guaranteed to contain the emote, or be cached.
|
|
67
|
-
* @readonly
|
|
68
|
-
* @type {?Channel}
|
|
69
|
-
*/
|
|
70
|
-
get owner() {
|
|
71
|
-
return this.fetcher.channels.get(this.ownerName);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
_setup(data) {
|
|
75
|
-
super._setup(data);
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The name of the emote creator's channel.
|
|
79
|
-
* Will be null for global or channel emotes.
|
|
80
|
-
* @type {?string}
|
|
81
|
-
*/
|
|
82
|
-
this.ownerName = 'user' in data ? data.user.name : null;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* If emote is animated.
|
|
86
|
-
* @type {boolean}
|
|
87
|
-
*/
|
|
88
|
-
this.animated = data.animated;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The image type of the emote.
|
|
92
|
-
* @type {string}
|
|
93
|
-
*/
|
|
94
|
-
this.imageType = 'webp';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Gets the image link of the emote.
|
|
99
|
-
* @param {number} size - The size of the image, 0, 1, or 2.
|
|
100
|
-
* @returns {string}
|
|
101
|
-
*/
|
|
102
|
-
toLink(size = 0) {
|
|
103
|
-
return Constants.BTTV.CDN(this.id, size); // eslint-disable-line new-cap
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Override for `toObject`.
|
|
108
|
-
* Will result in an Object representation of a BTTVEmote
|
|
109
|
-
* @returns {object}
|
|
110
|
-
*/
|
|
111
|
-
toObject() {
|
|
112
|
-
return Object.assign({}, super.toObject(), {
|
|
113
|
-
animated: this.animated,
|
|
114
|
-
ownerName: this.ownerName,
|
|
115
|
-
type: this.type
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Converts an emote Object into a BTTVEmote
|
|
121
|
-
* @param {object} [emoteObject] - Object representation of this emote
|
|
122
|
-
* @param {Channel} [channel=null] - Channel this emote belongs to.
|
|
123
|
-
* @returns {BTTVEmote}
|
|
124
|
-
*/
|
|
125
|
-
static fromObject(emoteObject, channel = null) {
|
|
126
|
-
return new BTTVEmote(channel, emoteObject.id,
|
|
127
|
-
{
|
|
128
|
-
code: emoteObject.code,
|
|
129
|
-
animated: emoteObject.animated,
|
|
130
|
-
user: {
|
|
131
|
-
name: emoteObject.ownerName
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
module.exports = BTTVEmote;
|
|
138
|
-
</code></pre>
|
|
139
|
-
</article>
|
|
140
|
-
</section>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
</div>
|
|
148
|
-
|
|
149
|
-
<br class="clear">
|
|
150
|
-
|
|
151
|
-
<footer>
|
|
152
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
153
|
-
</footer>
|
|
154
|
-
|
|
155
|
-
<script>prettyPrint();</script>
|
|
156
|
-
<script src="scripts/polyfill.js"></script>
|
|
157
|
-
<script src="scripts/linenumber.js"></script>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
</body>
|
|
162
|
-
</html>
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<title>struct/Channel.js - Documentation</title>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<script src="scripts/prettify/prettify.js"></script>
|
|
10
|
-
<script src="scripts/prettify/lang-css.js"></script>
|
|
11
|
-
<!--[if lt IE 9]>
|
|
12
|
-
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
13
|
-
<![endif]-->
|
|
14
|
-
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
15
|
-
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
16
|
-
<script src="scripts/nav.js" defer></script>
|
|
17
|
-
|
|
18
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
|
|
22
|
-
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
|
23
|
-
<label for="nav-trigger" class="navicon-button x">
|
|
24
|
-
<div class="navicon"></div>
|
|
25
|
-
</label>
|
|
26
|
-
|
|
27
|
-
<label for="nav-trigger" class="overlay"></label>
|
|
28
|
-
|
|
29
|
-
<nav >
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<h2><a href="index.html">Home</a></h2><h2><a href="https://github.com/mkody/twitch-emoticons" target="_blank" class="menu-item" id="github_link" >GitHub</a></h2><h3>Classes</h3><ul><li><a href="BTTVEmote.html">BTTVEmote</a><ul class='methods'><li data-type='method'><a href="BTTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#toObject">toObject</a></li><li data-type='method'><a href="BTTVEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="Channel.html">Channel</a><ul class='methods'><li data-type='method'><a href="Channel.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#toObject">toObject</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#fetchTwitchEmotes">fetchTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fromObject">fromObject</a></li></ul></li><li><a href="EmoteParser.html">EmoteParser</a><ul class='methods'><li data-type='method'><a href="EmoteParser.html#parse">parse</a></li></ul></li><li><a href="FFZEmote.html">FFZEmote</a><ul class='methods'><li data-type='method'><a href="FFZEmote.html#toLink">toLink</a></li><li data-type='method'><a href="FFZEmote.html#toObject">toObject</a></li><li data-type='method'><a href="FFZEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="SevenTVEmote.html">SevenTVEmote</a><ul class='methods'><li data-type='method'><a href="SevenTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#toObject">toObject</a></li><li data-type='method'><a href="SevenTVEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="TwitchEmote.html">TwitchEmote</a><ul class='methods'><li data-type='method'><a href="TwitchEmote.html#toLink">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#toObject">toObject</a></li><li data-type='method'><a href="TwitchEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#find">find</a></li><li data-type='method'><a href="Collection.html#filter">filter</a></li><li data-type='method'><a href="Collection.html#map">map</a></li></ul></li></ul>
|
|
33
|
-
|
|
34
|
-
</nav>
|
|
35
|
-
|
|
36
|
-
<div id="main">
|
|
37
|
-
|
|
38
|
-
<h1 class="page-title">struct/Channel.js</h1>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<section>
|
|
47
|
-
<article>
|
|
48
|
-
<pre class="prettyprint source linenums"><code>const Collection = require('../util/Collection');
|
|
49
|
-
|
|
50
|
-
class Channel {
|
|
51
|
-
/**
|
|
52
|
-
* A Twitch channel.
|
|
53
|
-
* @param {EmoteFetcher} fetcher - The emote fetcher.
|
|
54
|
-
* @param {int} id - ID of the channel.
|
|
55
|
-
*/
|
|
56
|
-
constructor(fetcher, id) {
|
|
57
|
-
/**
|
|
58
|
-
* The emote fetcher.
|
|
59
|
-
* @type {EmoteFetcher}
|
|
60
|
-
*/
|
|
61
|
-
this.fetcher = fetcher;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The ID of this channel.
|
|
65
|
-
* For the global channel, the ID will be null.
|
|
66
|
-
* @type {?int}
|
|
67
|
-
*/
|
|
68
|
-
this.channel_id = id;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Cached emotes belonging to this channel.
|
|
72
|
-
* @type {Collection<string, Emote>}
|
|
73
|
-
*/
|
|
74
|
-
this.emotes = new Collection();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* There are tests that those are returning Collections, but c8 doesn't get it. */
|
|
78
|
-
/* c8 ignore start */
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Fetches the BTTV emotes for this channel.
|
|
82
|
-
* @returns {Promise<Collection<string, BTTVEmote>>}
|
|
83
|
-
*/
|
|
84
|
-
fetchBTTVEmotes() {
|
|
85
|
-
return this.fetcher.fetchBTTVEmotes(this.id);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Fetches the FFZ emotes for this channel.
|
|
90
|
-
* @returns {Promise<Collection<string, FFZEmote>>}
|
|
91
|
-
*/
|
|
92
|
-
fetchFFZEmotes() {
|
|
93
|
-
return this.fetcher.fetchFFZEmotes(this.id);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Fetches the 7TV emotes for this channel.
|
|
98
|
-
* @returns {Promise<Collection<string, SevenTVEmote>>}
|
|
99
|
-
*/
|
|
100
|
-
fetchSevenTVEmotes() {
|
|
101
|
-
return this.fetcher.fetchSevenTVEmotes(this.id);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/* c8 ignore end */
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
module.exports = Channel;
|
|
108
|
-
</code></pre>
|
|
109
|
-
</article>
|
|
110
|
-
</section>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
</div>
|
|
118
|
-
|
|
119
|
-
<br class="clear">
|
|
120
|
-
|
|
121
|
-
<footer>
|
|
122
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
123
|
-
</footer>
|
|
124
|
-
|
|
125
|
-
<script>prettyPrint();</script>
|
|
126
|
-
<script src="scripts/polyfill.js"></script>
|
|
127
|
-
<script src="scripts/linenumber.js"></script>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
</body>
|
|
132
|
-
</html>
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<title>struct/Emote.js - Documentation</title>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<script src="scripts/prettify/prettify.js"></script>
|
|
10
|
-
<script src="scripts/prettify/lang-css.js"></script>
|
|
11
|
-
<!--[if lt IE 9]>
|
|
12
|
-
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
13
|
-
<![endif]-->
|
|
14
|
-
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
15
|
-
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
16
|
-
<script src="scripts/nav.js" defer></script>
|
|
17
|
-
|
|
18
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
|
|
22
|
-
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
|
23
|
-
<label for="nav-trigger" class="navicon-button x">
|
|
24
|
-
<div class="navicon"></div>
|
|
25
|
-
</label>
|
|
26
|
-
|
|
27
|
-
<label for="nav-trigger" class="overlay"></label>
|
|
28
|
-
|
|
29
|
-
<nav >
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<h2><a href="index.html">Home</a></h2><h2><a href="https://github.com/mkody/twitch-emoticons" target="_blank" class="menu-item" id="github_link" >GitHub</a></h2><h3>Classes</h3><ul><li><a href="BTTVEmote.html">BTTVEmote</a><ul class='methods'><li data-type='method'><a href="BTTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="BTTVEmote.html#toObject">toObject</a></li><li data-type='method'><a href="BTTVEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="Channel.html">Channel</a><ul class='methods'><li data-type='method'><a href="Channel.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="Channel.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="Channel.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#toObject">toObject</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#fetchTwitchEmotes">fetchTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchBTTVEmotes">fetchBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchFFZEmotes">fetchFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fetchSevenTVEmotes">fetchSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#fromObject">fromObject</a></li></ul></li><li><a href="EmoteParser.html">EmoteParser</a><ul class='methods'><li data-type='method'><a href="EmoteParser.html#parse">parse</a></li></ul></li><li><a href="FFZEmote.html">FFZEmote</a><ul class='methods'><li data-type='method'><a href="FFZEmote.html#toLink">toLink</a></li><li data-type='method'><a href="FFZEmote.html#toObject">toObject</a></li><li data-type='method'><a href="FFZEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="SevenTVEmote.html">SevenTVEmote</a><ul class='methods'><li data-type='method'><a href="SevenTVEmote.html#toLink">toLink</a></li><li data-type='method'><a href="SevenTVEmote.html#toObject">toObject</a></li><li data-type='method'><a href="SevenTVEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="TwitchEmote.html">TwitchEmote</a><ul class='methods'><li data-type='method'><a href="TwitchEmote.html#toLink">toLink</a></li><li data-type='method'><a href="TwitchEmote.html#toObject">toObject</a></li><li data-type='method'><a href="TwitchEmote.html#.fromObject">fromObject</a></li></ul></li><li><a href="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#find">find</a></li><li data-type='method'><a href="Collection.html#filter">filter</a></li><li data-type='method'><a href="Collection.html#map">map</a></li></ul></li></ul>
|
|
33
|
-
|
|
34
|
-
</nav>
|
|
35
|
-
|
|
36
|
-
<div id="main">
|
|
37
|
-
|
|
38
|
-
<h1 class="page-title">struct/Emote.js</h1>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<section>
|
|
47
|
-
<article>
|
|
48
|
-
<pre class="prettyprint source linenums"><code>class Emote {
|
|
49
|
-
/**
|
|
50
|
-
* Base class for emotes.
|
|
51
|
-
* This constructor is not to be used.
|
|
52
|
-
* @param {Channel} channel - Channel this emote belongs to.
|
|
53
|
-
* @param {string} id - ID of the emote.
|
|
54
|
-
* @param {data} data - The raw emote data.
|
|
55
|
-
* @throws {Error} When trying to use the base Emote class directly.
|
|
56
|
-
*/
|
|
57
|
-
constructor(channel, id, data) {
|
|
58
|
-
if (new.target.name === Emote.name) {
|
|
59
|
-
throw new Error('Base Emote class cannot be used');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The emote fetcher.
|
|
64
|
-
* @type {EmoteFetcher}
|
|
65
|
-
*/
|
|
66
|
-
this.fetcher = channel.fetcher;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The channel this emote belongs to.
|
|
70
|
-
* Only accurate and constant on Twitch emotes.
|
|
71
|
-
* For other types of emotes, use the `owner` or `ownerName` property.
|
|
72
|
-
* @type {Channel}
|
|
73
|
-
*/
|
|
74
|
-
this.channel = channel;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The ID of this emote.
|
|
78
|
-
* @type {string}
|
|
79
|
-
*/
|
|
80
|
-
this.id = id;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* The type of this emote.
|
|
84
|
-
* Either `twitch`, `bttv`, `ffz`, or '7tv'.
|
|
85
|
-
* @type {string}
|
|
86
|
-
*/
|
|
87
|
-
this.type = null;
|
|
88
|
-
|
|
89
|
-
this._setup(data);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
_setup(data) {
|
|
93
|
-
/**
|
|
94
|
-
* The code or name of the emote.
|
|
95
|
-
* @type {string}
|
|
96
|
-
*/
|
|
97
|
-
this.code = data.code;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Gets the image link of the emote.
|
|
102
|
-
* @param {number} size - The size of the image.
|
|
103
|
-
* @returns {string}
|
|
104
|
-
*/
|
|
105
|
-
/* c8 ignore next 3*/
|
|
106
|
-
toLink() {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Override for `toString`.
|
|
112
|
-
* Will give the emote's name.
|
|
113
|
-
* @returns {string}
|
|
114
|
-
*/
|
|
115
|
-
/* c8 ignore next 3*/
|
|
116
|
-
toString() {
|
|
117
|
-
return this.code;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Override for `toObject`.
|
|
122
|
-
* Will result in an Object representation of an Emote
|
|
123
|
-
* @returns {object}
|
|
124
|
-
*/
|
|
125
|
-
toObject() {
|
|
126
|
-
return {
|
|
127
|
-
code: this.code,
|
|
128
|
-
id: this.id,
|
|
129
|
-
channel_id: this.channel.channel_id
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
module.exports = Emote;
|
|
135
|
-
</code></pre>
|
|
136
|
-
</article>
|
|
137
|
-
</section>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
</div>
|
|
145
|
-
|
|
146
|
-
<br class="clear">
|
|
147
|
-
|
|
148
|
-
<footer>
|
|
149
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
150
|
-
</footer>
|
|
151
|
-
|
|
152
|
-
<script>prettyPrint();</script>
|
|
153
|
-
<script src="scripts/polyfill.js"></script>
|
|
154
|
-
<script src="scripts/linenumber.js"></script>
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
</body>
|
|
159
|
-
</html>
|