-
Notifications
You must be signed in to change notification settings - Fork 9k
/
Copy pathstore.js
45 lines (41 loc) · 917 Bytes
/
store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* @prettier
*/
import merge from "../merge"
const storeFactorization = (options) => {
const state = merge(
{
layout: {
layout: options.layout,
filter: options.filter,
},
spec: {
spec: "",
url: options.url,
},
requestSnippets: options.requestSnippets,
},
options.initialState
)
if (options.initialState) {
/**
* If the user sets a key as `undefined`, that signals to us that we
* should delete the key entirely.
* known usage: Swagger-Editor validate plugin tests
*/
for (const [key, value] of Object.entries(options.initialState)) {
if (value === undefined) {
delete state[key]
}
}
}
return {
system: {
configs: options.configs,
},
plugins: options.presets,
pluginsOptions: options.pluginsOptions,
state,
}
}
export default storeFactorization