emotesjs 0.0.8 → 0.0.10

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 (2) hide show
  1. package/index.js +16 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- class EmoteJS {
1
+ class EmotesJS {
2
2
  cachedEmotes = new Map()
3
3
  isReady = false
4
4
  isLoading = Promise.resolve()
@@ -7,20 +7,22 @@ class EmoteJS {
7
7
  height = "1.65rem"
8
8
  format = "WEBP"
9
9
  allowedOrigins = "https://cdn.7tv.app"
10
- instance
10
+ static instance
11
11
 
12
12
  constructor(opts) {
13
- if (EmoteJS.instance) {
14
- return EmoteJS.instance
13
+ if (EmotesJS.instance) {
14
+ return EmotesJS.instance
15
15
  }
16
16
 
17
- this.channelId = opts.channelId || this.channelId
18
- this.requireColon = opts.requireColon || this.requireColon
19
- this.height = opts.height || this.height
20
- this.format = opts.format || this.format
17
+ if (opts) {
18
+ this.channelId = opts.channelId || this.channelId
19
+ this.requireColon = opts.requireColon || this.requireColon
20
+ this.height = opts.height || this.height
21
+ this.format = opts.format || this.format
22
+ }
21
23
 
22
24
  this.isLoading = this.load()
23
- EmoteJS.instance = this
25
+ EmotesJS.instance = this
24
26
  }
25
27
 
26
28
  async load() {
@@ -70,8 +72,8 @@ class EmoteJS {
70
72
  this.isReady = true
71
73
  }
72
74
 
73
- parse(text) {
74
- if (!text || !this.isReady) {
75
+ static parse(text) {
76
+ if (!text || !EmotesJS.isReady) {
75
77
  return text
76
78
  }
77
79
  let words = text.split(' ')
@@ -80,12 +82,12 @@ class EmoteJS {
80
82
  for (let i = 0; i < words.length; i++) {
81
83
  let word = words[i]
82
84
 
83
- if (this.requireColon && !word.startsWith(":")) {
85
+ if (EmotesJS.requireColon && !word.startsWith(":")) {
84
86
  continue
85
87
  }
86
88
 
87
89
  let wordKey = word.replace(':', '')
88
- let emote = this.cachedEmotes.get(wordKey)
90
+ let emote = EmotesJS.cachedEmotes.get(wordKey)
89
91
 
90
92
  if (emote) {
91
93
  fullText += emote + ' '
@@ -100,5 +102,5 @@ class EmoteJS {
100
102
 
101
103
  }
102
104
 
103
- module.exports = { EmoteJS }
105
+ module.exports.EmotesJS = EmotesJS
104
106
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "emotesjs",
3
3
  "description": "",
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "darckfast"