Skip to content

Commit 5f18911

Browse files
committed
Condensed keys normalization in load() ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js-chrome-starter]
1 parent 21b43a1 commit 5f18911

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

starters/chrome/extension/lib/settings.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ window.settings = {
1414
// replyLanguage: { type: 'prompt', symbol: '🌐', label: 'Reply Language' }
1515
},
1616

17-
load() {
18-
const keys = ( // original array if array, else new array from multiple args
19-
Array.isArray(arguments[0]) ? arguments[0] : Array.from(arguments))
17+
load(...keys) {
18+
keys = keys.flat() // flatten array args nested by spread operator
2019
return Promise.all(keys.map(key => // resolve promise when all keys load
2120
new Promise(resolve => // resolve promise when single key value loads
2221
chrome.storage.sync.get(key, result => { // load from Chrome extension storage

0 commit comments

Comments
 (0)