|
7 | 7 | * @returns {object} valid configuration options.
|
8 | 8 | */
|
9 | 9 | function validateOptions(options) {
|
10 |
| - options = Object.assign( |
11 |
| - { |
12 |
| - id: 'id', |
13 |
| - blacklist: [], |
14 |
| - whitelist: [], |
15 |
| - links: {}, |
16 |
| - relationships: {}, |
17 |
| - topLevelLinks: {}, |
18 |
| - topLevelMeta: {}, |
19 |
| - meta: {}, |
20 |
| - blacklistOnDeserialize: [], |
21 |
| - whitelistOnDeserialize: [], |
22 |
| - jsonapiObject: true |
23 |
| - }, |
24 |
| - options |
25 |
| - ); |
| 10 | + options = { |
| 11 | + id: 'id', |
| 12 | + blacklist: [], |
| 13 | + whitelist: [], |
| 14 | + links: {}, |
| 15 | + relationships: {}, |
| 16 | + topLevelLinks: {}, |
| 17 | + topLevelMeta: {}, |
| 18 | + meta: {}, |
| 19 | + blacklistOnDeserialize: [], |
| 20 | + whitelistOnDeserialize: [], |
| 21 | + jsonapiObject: true, |
| 22 | + ...options |
| 23 | + }; |
26 | 24 |
|
27 | 25 | if (!Array.isArray(options.blacklist)) throw new Error("option 'blacklist' must be an array");
|
28 | 26 | if (!Array.isArray(options.whitelist)) throw new Error("option 'whitelist' must be an array");
|
@@ -64,10 +62,12 @@ function validateOptions(options) {
|
64 | 62 |
|
65 | 63 | const { relationships } = options;
|
66 | 64 | Object.keys(relationships).forEach(key => {
|
67 |
| - relationships[key] = Object.assign( |
68 |
| - { schema: 'default', links: {}, meta: {} }, |
69 |
| - relationships[key] |
70 |
| - ); |
| 65 | + relationships[key] = { |
| 66 | + schema: 'default', |
| 67 | + links: {}, |
| 68 | + meta: {}, |
| 69 | + ...relationships[key] |
| 70 | + }; |
71 | 71 |
|
72 | 72 | if (!relationships[key].type)
|
73 | 73 | throw new Error(`option 'type' for relationship '${key}' is required`);
|
@@ -110,7 +110,7 @@ function validateOptions(options) {
|
110 | 110 | * @returns {object} valid dynamic type options.
|
111 | 111 | */
|
112 | 112 | function validateDynamicTypeOptions(options) {
|
113 |
| - options = Object.assign({ topLevelLinks: {}, topLevelMeta: {}, jsonapiObject: true }, options); |
| 113 | + options = { topLevelLinks: {}, topLevelMeta: {}, jsonapiObject: true, ...options }; |
114 | 114 |
|
115 | 115 | if (!options.type) throw new Error("option 'type' is required");
|
116 | 116 | if (typeof options.type !== 'string' && typeof options.type !== 'function') {
|
|
0 commit comments