Update eslint cofig

This commit is contained in:
Manuel Bouza
2019-06-26 09:27:31 +02:00
parent fd04d6bf6c
commit 8b2e21c3cf
14 changed files with 115 additions and 151 deletions

View File

@@ -1,5 +1,5 @@
export default class TimeInputParser {
#input;
#input
constructor(input) {
this.#input = input.toLowerCase().replace(/[\s()]/g, "")
@@ -25,11 +25,11 @@ export default class TimeInputParser {
const calculated = hours * 3600 + minutes * 60
return isNegative ? -calculated : calculated
};
}
#parseDecimal = () => {
return this.#input.replace(/[.,]/g, ".")
};
}
#parseTimeAsSeconds = () => {
const match = this.#isTime()
@@ -39,12 +39,12 @@ export default class TimeInputParser {
const minutes = parseInt(match[3])
return this.#calculateFromHoursAndMinutes(hours, minutes, isNegative)
};
}
#parseMinutesAsSeconds = () => {
const minutes = parseInt(this.#isMinutes()[1])
return minutes * 60
};
}
#parseRange = () => {
const match = this.#isRange()
@@ -54,7 +54,7 @@ export default class TimeInputParser {
const to_hours = parseInt(match[3])
const to_minutes = parseInt(match[4])
return (to_hours - from_hours) * 3600 + (to_minutes - from_minutes) * 60
};
}
#parseHoursAndMinutes = () => {
const match = this.#isHoursAndMinutes()
@@ -64,28 +64,26 @@ export default class TimeInputParser {
const minutes = parseInt(match[3])
return this.#calculateFromHoursAndMinutes(hours, minutes, isNegative)
};
}
#isDecimal = () => {
return this.#input.match(/^([-]?[0-9]{0,2})[.,]{1}([0-9]{1,2})$/)
};
}
#isTime = () => {
return this.#input.match(/^([-]?)([0-9]{1,2}):([0-9]{2})$/)
};
}
#isMinutes = () => {
return this.#input.match(/^([-]?[0-9]{1,3})(m|mins?)$/)
};
}
#isRange = () => {
return this.#input.match(
/^([0-9]{1,2})[:.]{0,1}([0-9]{2})-([0-9]{1,2})[:.]{0,1}([0-9]{2})$/
)
};
return this.#input.match(/^([0-9]{1,2})[:.]{0,1}([0-9]{2})-([0-9]{1,2})[:.]{0,1}([0-9]{2})$/)
}
#isHoursAndMinutes = () => {
// 1h 14m(in)
return this.#input.match(/^([-]?)([0-9]{1,2})h([0-9]{1,2})(m|mins?)$/)
};
}
}

View File

@@ -1,14 +1,14 @@
export class BackgroundMessenger {
#ports = new Map();
#handlers = new Map();
#onceHandlers = new Map();
#ports = new Map()
#handlers = new Map()
#onceHandlers = new Map()
#handler = action => {
const handler = this.#handlers.get(action.type)
if (handler) {
handler(action)
}
};
}
#onceHandler = action => {
const handler = this.#onceHandlers.get(action.type)
@@ -16,7 +16,7 @@ export class BackgroundMessenger {
if (handler) {
handler(action)
}
};
}
#registerPort = (tabId, port) => {
this.#ports.set(tabId, port)
@@ -25,14 +25,14 @@ export class BackgroundMessenger {
port.onDisconnect.addListener(() => {
this.#unregisterPort(tabId, port)
})
};
}
#unregisterPort = (tabId, port) => {
port.onMessage.removeListener(this.#handler)
port.onMessage.removeListener(this.#onceHandler)
port.disconnect()
this.#ports.delete(tabId)
};
}
connectTab = tab => {
const currentPort = this.#ports.get(tab.id)
@@ -40,41 +40,41 @@ export class BackgroundMessenger {
const port = chrome.tabs.connect(tab.id)
this.#registerPort(tab.id, port)
}
};
}
disconnectTab = tabId => {
const port = this.#ports.get(tabId)
if (port) {
this.#unregisterPort(tabId, port)
}
};
}
postMessage = (tab, action) => {
const port = this.#ports.get(tab.id)
if (port) {
port.postMessage(action)
}
};
}
once = (type, handler) => {
this.#onceHandlers.set(type, handler)
};
}
on = (type, handler) => {
this.#handlers.set(type, handler)
};
}
}
export class ContentMessenger {
#port;
#handlers = new Map();
#port
#handlers = new Map()
#handler = action => {
const handler = this.#handlers.get(action.type)
if (handler) {
handler(action)
}
};
}
constructor(port) {
this.#port = port
@@ -85,15 +85,15 @@ export class ContentMessenger {
if (this.#port) {
this.#port.postMessage(action)
}
};
}
on = (type, handler) => {
this.#handlers.set(type, handler)
};
}
stop = () => {
this.#port.onMessage.removeListener(this.#handler)
this.#port = null
this.#handlers.clear()
};
}
}