@mkody/twitch-emoticons 2.7.0 → 2.8.0

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.
Files changed (45) hide show
  1. package/.eslintrc.json +143 -143
  2. package/.github/codeql/codeql-config.yml +4 -4
  3. package/.github/workflows/codeql.yml +50 -50
  4. package/.github/workflows/eslint.yml +50 -50
  5. package/.github/workflows/release.yml +22 -0
  6. package/.github/workflows/yarn-test.yml +17 -17
  7. package/.jsdoc.json +39 -39
  8. package/.nvmrc +1 -0
  9. package/LICENSE +22 -22
  10. package/README.md +36 -4
  11. package/docs/BTTVEmote.html +1641 -1319
  12. package/docs/Channel.html +823 -823
  13. package/docs/Collection.html +797 -797
  14. package/docs/Emote.html +906 -801
  15. package/docs/EmoteFetcher.html +3680 -2946
  16. package/docs/EmoteParser.html +811 -811
  17. package/docs/FFZEmote.html +1795 -1473
  18. package/docs/SevenTV.html +1190 -1190
  19. package/docs/SevenTVEmote.html +1705 -1395
  20. package/docs/TwitchEmote.html +1637 -1315
  21. package/docs/index.html +230 -206
  22. package/docs/struct_BTTVEmote.js.html +162 -132
  23. package/docs/struct_Channel.js.html +127 -127
  24. package/docs/struct_Emote.js.html +151 -138
  25. package/docs/struct_EmoteFetcher.js.html +427 -399
  26. package/docs/struct_EmoteParser.js.html +153 -153
  27. package/docs/struct_FFZEmote.js.html +185 -146
  28. package/docs/struct_SevenTVEmote.js.html +178 -141
  29. package/docs/struct_TwitchEmote.js.html +159 -130
  30. package/docs/util_Collection.js.html +150 -150
  31. package/package.json +57 -57
  32. package/src/index.js +12 -12
  33. package/src/struct/BTTVEmote.js +90 -60
  34. package/src/struct/Channel.js +55 -55
  35. package/src/struct/Emote.js +79 -66
  36. package/src/struct/EmoteFetcher.js +355 -327
  37. package/src/struct/EmoteParser.js +81 -81
  38. package/src/struct/EmoteTypeMapper.js +13 -0
  39. package/src/struct/FFZEmote.js +113 -74
  40. package/src/struct/SevenTVEmote.js +106 -69
  41. package/src/struct/TwitchEmote.js +87 -58
  42. package/src/util/Collection.js +78 -78
  43. package/src/util/Constants.js +31 -31
  44. package/test/index.js +482 -174
  45. package/typings/index.d.ts +115 -98
@@ -1,141 +1,178 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
-
5
- <meta charset="utf-8">
6
- <title>struct/SevenTVEmote.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><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#toString">toString</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="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#filter">filter</a></li><li data-type='method'><a href="Collection.html#find">find</a></li><li data-type='method'><a href="Collection.html#map">map</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#toString">toString</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#_cacheBTTVEmote">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmoteSet">_getRawFFZEmoteSet</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawTwitchEmotes">_getRawTwitchEmotes</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#fetchTwitchEmotes">fetchTwitchEmotes</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#toString">toString</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#toString">toString</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#toString">toString</a></li></ul></li></ul>
33
-
34
- </nav>
35
-
36
- <div id="main">
37
-
38
- <h1 class="page-title">struct/SevenTVEmote.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
- /** @extends Emote */
52
- class SevenTVEmote extends Emote {
53
- /**
54
- * A 7TV 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 = '7tv';
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
- this.code = data.name;
77
-
78
- /**
79
- * The name of the emote creator's channel.
80
- * @type {string}
81
- */
82
- this.ownerName = data.owner.display_name;
83
-
84
- /**
85
- * Available image sizes.
86
- * @type {string[]}
87
- */
88
- this.sizes = data.host.files
89
- .filter(el => el.format === this.channel.format.toUpperCase())
90
- .map(el => el.name);
91
-
92
- /**
93
- * If emote is animated.
94
- * @type {boolean}
95
- */
96
- this.animated = data.animated;
97
-
98
- /**
99
- * The image type of the emote.
100
- * @type {string}
101
- */
102
- this.imageType = this.channel.format;
103
- }
104
-
105
- /**
106
- * Gets the image link of the emote.
107
- * @param {number} size - The size of the image.
108
- * @returns {string}
109
- */
110
- toLink(size = 0) {
111
- size = this.sizes[size];
112
- return Constants.SevenTV.CDN(this.id, size); // eslint-disable-line new-cap
113
- }
114
- }
115
-
116
- module.exports = SevenTVEmote;
117
- </code></pre>
118
- </article>
119
- </section>
120
-
121
-
122
-
123
-
124
-
125
-
126
- </div>
127
-
128
- <br class="clear">
129
-
130
- <footer>
131
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
132
- </footer>
133
-
134
- <script>prettyPrint();</script>
135
- <script src="scripts/polyfill.js"></script>
136
- <script src="scripts/linenumber.js"></script>
137
-
138
-
139
-
140
- </body>
141
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <title>struct/SevenTVEmote.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><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#toString">toString</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="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#filter">filter</a></li><li data-type='method'><a href="Collection.html#find">find</a></li><li data-type='method'><a href="Collection.html#map">map</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><li data-type='method'><a href="Emote.html#toString">toString</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#_cacheBTTVEmote">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmoteSet">_getRawFFZEmoteSet</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_setupChannel">_setupChannel</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#fetchTwitchEmotes">fetchTwitchEmotes</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#toString">toString</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#toString">toString</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#toString">toString</a></li><li data-type='method'><a href="TwitchEmote.html#.fromObject">fromObject</a></li></ul></li></ul>
33
+
34
+ </nav>
35
+
36
+ <div id="main">
37
+
38
+ <h1 class="page-title">struct/SevenTVEmote.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
+ /** @extends Emote */
52
+ class SevenTVEmote extends Emote {
53
+ /**
54
+ * A 7TV 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 = '7tv';
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
+ this.code = data.name;
77
+
78
+ /**
79
+ * The name of the emote creator's channel.
80
+ * @type {?string}
81
+ */
82
+ this.ownerName = 'owner' in data ? data.owner.display_name : null;
83
+
84
+ /**
85
+ * Available image sizes.
86
+ * @type {string[]}
87
+ */
88
+ this.sizes = data.host.files
89
+ .filter(el => el.format === this.channel.format.toUpperCase())
90
+ .map(el => el.name);
91
+
92
+ /**
93
+ * If emote is animated.
94
+ * @type {boolean}
95
+ */
96
+ this.animated = data.animated;
97
+
98
+ /**
99
+ * The image type of the emote.
100
+ * @type {string}
101
+ */
102
+ this.imageType = this.channel.format;
103
+ }
104
+
105
+ /**
106
+ * Gets the image link of the emote.
107
+ * @param {number} size - The size of the image.
108
+ * @returns {string}
109
+ */
110
+ toLink(size = 0) {
111
+ size = this.sizes[size];
112
+ return Constants.SevenTV.CDN(this.id, size); // eslint-disable-line new-cap
113
+ }
114
+
115
+ /**
116
+ * Override for `toObject`.
117
+ * Will result in an Object representation of a SevenTVEmote
118
+ * @returns {Object}
119
+ */
120
+ toObject() {
121
+ return Object.assign({}, super.toObject(), {
122
+ animated: this.animated,
123
+ sizes: this.sizes,
124
+ ownerName: this.ownerName,
125
+ type: this.type,
126
+ imageType: this.imageType
127
+ });
128
+ }
129
+
130
+ /**
131
+ * Converts an emote Object into a SevenTVEmote
132
+ * @param {Object} [emoteObject] - Object representation of this emote
133
+ * @param {Channel} [channel] - Channel this emote belongs to.
134
+ * @returns {SevenTVEmote}
135
+ */
136
+ static fromObject(emoteObject, channel) {
137
+ const sizes = emoteObject.sizes.map(size => { return { format: channel.format.toUpperCase(), name: size }; });
138
+ return new SevenTVEmote(channel, emoteObject.id,
139
+ {
140
+ code: emoteObject.code,
141
+ name: emoteObject.code,
142
+ animated: emoteObject.animated,
143
+ owner: {
144
+ display_name: emoteObject.ownerName
145
+ },
146
+ host: {
147
+ files: sizes
148
+ }
149
+ });
150
+ }
151
+ }
152
+
153
+ module.exports = SevenTVEmote;
154
+ </code></pre>
155
+ </article>
156
+ </section>
157
+
158
+
159
+
160
+
161
+
162
+
163
+ </div>
164
+
165
+ <br class="clear">
166
+
167
+ <footer>
168
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
169
+ </footer>
170
+
171
+ <script>prettyPrint();</script>
172
+ <script src="scripts/polyfill.js"></script>
173
+ <script src="scripts/linenumber.js"></script>
174
+
175
+
176
+
177
+ </body>
178
+ </html>
@@ -1,130 +1,159 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
-
5
- <meta charset="utf-8">
6
- <title>struct/TwitchEmote.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><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#toString">toString</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="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#filter">filter</a></li><li data-type='method'><a href="Collection.html#find">find</a></li><li data-type='method'><a href="Collection.html#map">map</a></li></ul></li><li><a href="Emote.html">Emote</a><ul class='methods'><li data-type='method'><a href="Emote.html#toString">toString</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#_cacheBTTVEmote">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmoteSet">_getRawFFZEmoteSet</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawTwitchEmotes">_getRawTwitchEmotes</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#fetchTwitchEmotes">fetchTwitchEmotes</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#toString">toString</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#toString">toString</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#toString">toString</a></li></ul></li></ul>
33
-
34
- </nav>
35
-
36
- <div id="main">
37
-
38
- <h1 class="page-title">struct/TwitchEmote.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
- /** @extends Emote */
52
- class TwitchEmote extends Emote {
53
- /**
54
- * A Twitch 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 = 'twitch';
62
- }
63
-
64
- /**
65
- * The channel of this emote's creator.
66
- * @readonly
67
- * @type {Channel}
68
- */
69
- get owner() {
70
- return this.channel;
71
- }
72
-
73
- _setup(data) {
74
- super._setup(data);
75
-
76
- /**
77
- * The set ID of the emote.
78
- * @type {?string}
79
- */
80
- this.set = data.emoticon_set;
81
-
82
- /**
83
- * If emote is animated.
84
- * @type {boolean}
85
- */
86
- this.animated = 'animated' in data.formats;
87
-
88
- /**
89
- * The image type of the emote.
90
- * @type {string}
91
- */
92
- this.imageType = 'animated' in data.formats ? 'gif' : 'png';
93
- }
94
-
95
- /**
96
- * Gets the image link of the emote.
97
- * @param {number} size - The size of the image, 0, 1, or 2.
98
- * @returns {string}
99
- */
100
- toLink(size = 0) {
101
- return Constants.Twitch.CDN(this.id, size); // eslint-disable-line new-cap
102
- }
103
- }
104
-
105
- module.exports = TwitchEmote;
106
- </code></pre>
107
- </article>
108
- </section>
109
-
110
-
111
-
112
-
113
-
114
-
115
- </div>
116
-
117
- <br class="clear">
118
-
119
- <footer>
120
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
121
- </footer>
122
-
123
- <script>prettyPrint();</script>
124
- <script src="scripts/polyfill.js"></script>
125
- <script src="scripts/linenumber.js"></script>
126
-
127
-
128
-
129
- </body>
130
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <title>struct/TwitchEmote.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><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#toString">toString</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="Collection.html">Collection</a><ul class='methods'><li data-type='method'><a href="Collection.html#filter">filter</a></li><li data-type='method'><a href="Collection.html#find">find</a></li><li data-type='method'><a href="Collection.html#map">map</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><li data-type='method'><a href="Emote.html#toString">toString</a></li></ul></li><li><a href="EmoteFetcher.html">EmoteFetcher</a><ul class='methods'><li data-type='method'><a href="EmoteFetcher.html#_cacheBTTVEmote">_cacheBTTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheFFZEmote">_cacheFFZEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheSevenTVEmote">_cacheSevenTVEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_cacheTwitchEmote">_cacheTwitchEmote</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawBTTVEmotes">_getRawBTTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmoteSet">_getRawFFZEmoteSet</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawFFZEmotes">_getRawFFZEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawSevenTVEmotes">_getRawSevenTVEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_getRawTwitchEmotes">_getRawTwitchEmotes</a></li><li data-type='method'><a href="EmoteFetcher.html#_setupChannel">_setupChannel</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#fetchTwitchEmotes">fetchTwitchEmotes</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#toString">toString</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#toString">toString</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#toString">toString</a></li><li data-type='method'><a href="TwitchEmote.html#.fromObject">fromObject</a></li></ul></li></ul>
33
+
34
+ </nav>
35
+
36
+ <div id="main">
37
+
38
+ <h1 class="page-title">struct/TwitchEmote.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
+ /** @extends Emote */
52
+ class TwitchEmote extends Emote {
53
+ /**
54
+ * A Twitch 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 = 'twitch';
62
+ }
63
+
64
+ /**
65
+ * The channel of this emote's creator.
66
+ * @readonly
67
+ * @type {Channel}
68
+ */
69
+ get owner() {
70
+ return this.channel;
71
+ }
72
+
73
+ _setup(data) {
74
+ super._setup(data);
75
+
76
+ /**
77
+ * The set ID of the emote.
78
+ * @type {?string}
79
+ */
80
+ this.set = data.emoticon_set;
81
+
82
+ /**
83
+ * If emote is animated.
84
+ * @type {boolean}
85
+ */
86
+ this.animated = 'animated' in data.formats;
87
+
88
+ /**
89
+ * The image type of the emote.
90
+ * @type {string}
91
+ */
92
+ this.imageType = 'animated' in data.formats ? 'gif' : 'png';
93
+ }
94
+
95
+ /**
96
+ * Gets the image link of the emote.
97
+ * @param {number} size - The size of the image, 0, 1, or 2.
98
+ * @returns {string}
99
+ */
100
+ toLink(size = 0) {
101
+ return Constants.Twitch.CDN(this.id, size); // eslint-disable-line new-cap
102
+ }
103
+
104
+ /**
105
+ * Override for `toObject`.
106
+ * Will result in an Object representation of a TwitchEmote
107
+ * @returns {Object}
108
+ */
109
+ toObject() {
110
+ return Object.assign({}, super.toObject(), {
111
+ animated: this.animated,
112
+ set: this.set,
113
+ type: this.type
114
+ });
115
+ }
116
+
117
+ /**
118
+ * Converts an emote Object into a TwitchEmote
119
+ * @param {Object} [emoteObject] - Object representation of this emote
120
+ * @param {Channel} [channel=null] - Channel this emote belongs to.
121
+ * @returns {TwitchEmote}
122
+ */
123
+ static fromObject(emoteObject, channel = null) {
124
+ return new TwitchEmote(channel, emoteObject.id,
125
+ {
126
+ code: emoteObject.code,
127
+ animated: emoteObject.animated,
128
+ emoticon_set: emoteObject.set,
129
+ formats: emoteObject.animated ? { animated: emoteObject.animated } : {}
130
+ });
131
+ }
132
+ }
133
+
134
+ module.exports = TwitchEmote;
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.2</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>