Skip to content

Commit 31b68f7

Browse files
committed
various: match function style across parser/utils
1 parent 412258f commit 31b68f7

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

lib/parser.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,13 @@ function parseComplexTag(tags, tagKey, splA = ',', splB = '/', splC) {
5959

6060
module.exports = {
6161
// Parse Twitch badges..
62-
badges(tags) {
63-
return parseComplexTag(tags, 'badges');
64-
},
62+
badges: tags => parseComplexTag(tags, 'badges'),
6563

6664
// Parse Twitch badge-info..
67-
badgeInfo(tags) {
68-
return parseComplexTag(tags, 'badge-info');
69-
},
65+
badgeInfo: tags => parseComplexTag(tags, 'badge-info'),
7066

7167
// Parse Twitch emotes..
72-
emotes(tags) {
73-
return parseComplexTag(tags, 'emotes', '/', ':', ',');
74-
},
68+
emotes: tags => parseComplexTag(tags, 'emotes', '/', ':', ','),
7569

7670
// Parse regex emotes..
7771
emoteRegex(msg, code, id, obj) {

lib/utils.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const _ = module.exports = {
2121
isFinite: int => isFinite(int) && !isNaN(parseFloat(int)),
2222

2323
// Parse string to number. Returns NaN if string can't be parsed to number..
24-
toNumber: (num, precision) => {
24+
toNumber(num, precision) {
2525
if(num === null) {
2626
return 0;
2727
}
@@ -45,13 +45,13 @@ const _ = module.exports = {
4545
isJustinfan: username => justinFanRegex.test(username),
4646

4747
// Return a valid channel name..
48-
channel: str => {
48+
channel(str) {
4949
const channel = (str ? str : '').toLowerCase();
5050
return channel[0] === '#' ? channel : '#' + channel;
5151
},
5252

5353
// Return a valid username..
54-
username: str => {
54+
username(str) {
5555
const username = (str ? str : '').toLowerCase();
5656
return username[0] === '#' ? username.slice(1) : username;
5757
},
@@ -60,15 +60,15 @@ const _ = module.exports = {
6060
token: str => str ? str.toLowerCase().replace('oauth:', '') : '',
6161

6262
// Return a valid password..
63-
password: str => {
63+
password(str) {
6464
const token = _.token(str);
6565
return token ? `oauth:${token}` : '';
6666
},
6767

6868
actionMessage: msg => msg.match(actionMessageRegex),
6969

7070
// Replace all occurences of a string using an object..
71-
replaceAll: (str, obj) => {
71+
replaceAll(str, obj) {
7272
if(str === null || typeof str === 'undefined') {
7373
return null;
7474
}
@@ -87,7 +87,7 @@ const _ = module.exports = {
8787

8888
// Escaping values:
8989
// http://ircv3.net/specs/core/message-tags-3.2.html#escaping-values
90-
unescapeIRC: msg => {
90+
unescapeIRC(msg) {
9191
if(!msg || typeof msg !== 'string' || !msg.includes('\\')) {
9292
return msg;
9393
}
@@ -97,7 +97,7 @@ const _ = module.exports = {
9797
);
9898
},
9999

100-
escapeIRC: msg => {
100+
escapeIRC(msg) {
101101
if(!msg || typeof msg !== 'string') {
102102
return msg;
103103
}
@@ -111,7 +111,7 @@ const _ = module.exports = {
111111
addWord: (line, word) => line.length ? line + ' ' + word : line + word,
112112

113113
// Split a line but try not to cut a word in half..
114-
splitLine: (input, length) => {
114+
splitLine(input, length) {
115115
let lastSpace = input.substring(0, length).lastIndexOf(' ');
116116
// No spaces found, split at the very end to avoid a loop..
117117
if(lastSpace === -1) {
@@ -121,7 +121,7 @@ const _ = module.exports = {
121121
},
122122

123123
// Extract a number from a string..
124-
extractNumber: str => {
124+
extractNumber(str) {
125125
const parts = str.split(' ');
126126
for (let i = 0; i < parts.length; i++) {
127127
if(_.isInteger(parts[i])) {
@@ -132,7 +132,7 @@ const _ = module.exports = {
132132
},
133133

134134
// Format the date..
135-
formatDate: date => {
135+
formatDate(date) {
136136
let hours = date.getHours();
137137
let mins = date.getMinutes();
138138

@@ -142,7 +142,7 @@ const _ = module.exports = {
142142
},
143143

144144
// Inherit the prototype methods from one constructor into another..
145-
inherits: (ctor, superCtor) => {
145+
inherits(ctor, superCtor) {
146146
ctor.super_ = superCtor;
147147
const TempCtor = function () {};
148148
TempCtor.prototype = superCtor.prototype;
@@ -151,7 +151,7 @@ const _ = module.exports = {
151151
},
152152

153153
// Return whether inside a Node application or not..
154-
isNode: () => {
154+
isNode() {
155155
try {
156156
return typeof process === 'object' &&
157157
Object.prototype.toString.call(process) === '[object process]';

0 commit comments

Comments
 (0)