aboutsummaryrefslogtreecommitdiff
path: root/src/shared/Settings.ts
diff options
context:
space:
mode:
authorShin'ya UEOKA <ueokande@i-beam.org>2019-10-05 06:39:20 +0000
committerShin'ya UEOKA <ueokande@i-beam.org>2019-10-06 12:58:59 +0000
commitb86b4680b6c2a3f0cceefaaf7c2e35417ec555df (patch)
tree79296d48f79ebba2496de5e8e09a4c8fc9e1ad41 /src/shared/Settings.ts
parent574692551a27ea56660bf2061daeaa0d34beaff4 (diff)
Make Blacklist class
Diffstat (limited to 'src/shared/Settings.ts')
-rw-r--r--src/shared/Settings.ts21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/shared/Settings.ts b/src/shared/Settings.ts
index 6250aae..2767820 100644
--- a/src/shared/Settings.ts
+++ b/src/shared/Settings.ts
@@ -1,26 +1,15 @@
import Keymaps from './settings/Keymaps';
import Search from './settings/Search';
import Properties from './settings/Properties';
+import Blacklist from './settings/Blacklist';
export default interface Settings {
keymaps: Keymaps;
search: Search;
properties: Properties;
- blacklist: string[];
+ blacklist: Blacklist;
}
-export const blacklistValueOf = (o: any): string[] => {
- if (!Array.isArray(o)) {
- throw new TypeError(`"blacklist" is not an array of string`);
- }
- for (let x of o) {
- if (typeof x !== 'string') {
- throw new TypeError(`"blacklist" is not an array of string`);
- }
- }
- return o as string[];
-};
-
export const valueOf = (o: any): Settings => {
let settings = { ...DefaultSetting };
for (let key of Object.keys(o)) {
@@ -35,7 +24,7 @@ export const valueOf = (o: any): Settings => {
settings.properties = Properties.fromJSON(o.properties);
break;
case 'blacklist':
- settings.blacklist = blacklistValueOf(o.blacklist);
+ settings.blacklist = Blacklist.fromJSON(o.blacklist);
break;
default:
throw new TypeError('unknown setting: ' + key);
@@ -49,7 +38,7 @@ export const toJSON = (settings: Settings): any => {
keymaps: settings.keymaps.toJSON(),
search: settings.search.toJSON(),
properties: settings.properties.toJSON(),
- blacklist: settings.blacklist,
+ blacklist: settings.blacklist.toJSON(),
};
};
@@ -134,5 +123,5 @@ export const DefaultSetting: Settings = {
smoothscroll: false,
complete: 'sbh'
}),
- blacklist: []
+ blacklist: Blacklist.fromJSON([]),
};