diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-06-18 20:52:54 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-18 20:52:54 +0900 |
commit | 897e010f42cbc9968cf1058116b0f8bbe9e9a4fd (patch) | |
tree | 3cba586e52ef703d1b49a85ad15d91aca4cbc65f /src/shared/settings/storage.js | |
parent | 7cae7302bd39a7963b765cd3defd05a093c104a6 (diff) | |
parent | b74acf6f6aef4e4241ba62c72ed8ddb21adc751d (diff) |
Merge pull request #417 from ueokande/async-function
Use await/async on e2e test
Diffstat (limited to 'src/shared/settings/storage.js')
-rw-r--r-- | src/shared/settings/storage.js | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/shared/settings/storage.js b/src/shared/settings/storage.js index 9b8045d..87843ed 100644 --- a/src/shared/settings/storage.js +++ b/src/shared/settings/storage.js @@ -1,30 +1,28 @@ import DefaultSettings from './default'; import * as settingsValues from './values'; -const loadRaw = () => { - return browser.storage.local.get('settings').then(({ settings }) => { - if (!settings) { - return DefaultSettings; - } - return Object.assign({}, DefaultSettings, settings); - }); +const loadRaw = async() => { + let { settings } = await browser.storage.local.get('settings'); + if (!settings) { + return DefaultSettings; + } + return Object.assign({}, DefaultSettings, settings); }; -const loadValue = () => { - return loadRaw().then((settings) => { - let value = JSON.parse(DefaultSettings.json); - if (settings.source === 'json') { - value = settingsValues.valueFromJson(settings.json); - } else if (settings.source === 'form') { - value = settingsValues.valueFromForm(settings.form); - } - if (!value.properties) { - value.properties = {}; - } - return Object.assign({}, - settingsValues.valueFromJson(DefaultSettings.json), - value); - }); +const loadValue = async() => { + let settings = await loadRaw(); + let value = JSON.parse(DefaultSettings.json); + if (settings.source === 'json') { + value = settingsValues.valueFromJson(settings.json); + } else if (settings.source === 'form') { + value = settingsValues.valueFromForm(settings.form); + } + if (!value.properties) { + value.properties = {}; + } + return Object.assign({}, + settingsValues.valueFromJson(DefaultSettings.json), + value); }; const save = (settings) => { |