Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Commit bdd0c09

Browse files
committed
Minor refactor
1 parent 1e2bc43 commit bdd0c09

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

src/js/popup.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,11 @@ const storage = {
3737
this._setData(JSON.parse(window.localStorage.getItem(this.key) || '{}'))
3838
},
3939
_getData: function (key) {
40-
if (this.mode === this.MODE.private) {
41-
if (key) {
42-
return this.data.private[key]
43-
} else {
44-
return this.data.private
45-
}
46-
}
47-
if (this.mode === this.MODE.global) {
48-
if (key) {
49-
return this.data.global[key]
50-
} else {
51-
return this.data.global
52-
}
40+
const object = this.mode === this.MODE.private ? this.data.private : this.data.global
41+
if (key) {
42+
return object[key]
43+
} else {
44+
return object
5345
}
5446
},
5547
_setData: function (data, key) {
@@ -72,12 +64,13 @@ const storage = {
7264
return this._getData(key)
7365
},
7466
set: function (arg1, arg2) {
75-
// arg1 is a key
67+
// arg1 is a key
7668
if (typeof arg1 === 'string') {
7769
this._setData(arg2, arg1)
7870
} else {
79-
// arg1 is data
80-
this._setData(arg1)
71+
// arg1 is data
72+
throw new Error('This should never happen!')
73+
// this._setData(arg1)
8174
}
8275

8376
var str = JSON.stringify(this._getData() || {})
@@ -390,7 +383,7 @@ popup.include.predefined.forEach(function (lib) {
390383
})
391384

392385
/**
393-
* Inicialize Ace Editor
386+
* Initialize Ace Editor
394387
*/
395388

396389
const initEditor = () => {

0 commit comments

Comments
 (0)