Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
316test cases
1,320files differ
1,320modified
0new
0deleted
6,730changed lines
+4,553 −2,177insertions / deletions
Base b848720ff991a5e25d8f194da6d4aed99b478368 · PR merge f239c99271dd40ecb47af7e739d8ea4e1d0e1f10 · Head 841417de4ab2e6ea2054a631d21d6341d044733d · raw patch
Test case

test/inputs/graphql/github1.graphql

3 generated files · +6 −6
Mgraphql-flowdefault / TopLevel.js+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Mgraphql-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mgraphql-typescriptdefault / TopLevel.ts+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Test case

test/inputs/graphql/github2.graphql

3 generated files · +6 −6
Mgraphql-flowdefault / TopLevel.js+2 −2
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 if (val === null || typeof val !== "object" || Array.isArray(val)) {
131131 return invalidValue(l(ref || "object"), val, key, parent);
132132 }
133- const result: any = {};
133+ const result: any = Object.create(null);
134134 Object.getOwnPropertyNames(props).forEach(key => {
135135 const prop = props[key];
136136 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -141,7 +141,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
141141 result[key] = transform(val[key], additional, getProps, key, ref);
142142 }
143143 });
144- return result;
144+ return Object.setPrototypeOf(result, Object.prototype);
145145 }
146146
147147 if (typ === "any") return val;
Mgraphql-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mgraphql-typescriptdefault / TopLevel.ts+2 −2
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 if (val === null || typeof val !== "object" || Array.isArray(val)) {
131131 return invalidValue(l(ref || "object"), val, key, parent);
132132 }
133- const result: any = {};
133+ const result: any = Object.create(null);
134134 Object.getOwnPropertyNames(props).forEach(key => {
135135 const prop = props[key];
136136 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -141,7 +141,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
141141 result[key] = transform(val[key], additional, getProps, key, ref);
142142 }
143143 });
144- return result;
144+ return Object.setPrototypeOf(result, Object.prototype);
145145 }
146146
147147 if (typ === "any") return val;
Test case

test/inputs/graphql/github3.graphql

3 generated files · +6 −6
Mgraphql-flowdefault / TopLevel.js+2 −2
@@ -138,7 +138,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
138138 if (val === null || typeof val !== "object" || Array.isArray(val)) {
139139 return invalidValue(l(ref || "object"), val, key, parent);
140140 }
141- const result: any = {};
141+ const result: any = Object.create(null);
142142 Object.getOwnPropertyNames(props).forEach(key => {
143143 const prop = props[key];
144144 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -149,7 +149,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
149149 result[key] = transform(val[key], additional, getProps, key, ref);
150150 }
151151 });
152- return result;
152+ return Object.setPrototypeOf(result, Object.prototype);
153153 }
154154
155155 if (typ === "any") return val;
Mgraphql-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mgraphql-typescriptdefault / TopLevel.ts+2 −2
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 if (val === null || typeof val !== "object" || Array.isArray(val)) {
136136 return invalidValue(l(ref || "object"), val, key, parent);
137137 }
138- const result: any = {};
138+ const result: any = Object.create(null);
139139 Object.getOwnPropertyNames(props).forEach(key => {
140140 const prop = props[key];
141141 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 result[key] = transform(val[key], additional, getProps, key, ref);
147147 }
148148 });
149- return result;
149+ return Object.setPrototypeOf(result, Object.prototype);
150150 }
151151
152152 if (typ === "any") return val;
Test case

test/inputs/graphql/github4.graphql

3 generated files · +6 −6
Mgraphql-flowdefault / TopLevel.js+2 −2
@@ -139,7 +139,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
139139 if (val === null || typeof val !== "object" || Array.isArray(val)) {
140140 return invalidValue(l(ref || "object"), val, key, parent);
141141 }
142- const result: any = {};
142+ const result: any = Object.create(null);
143143 Object.getOwnPropertyNames(props).forEach(key => {
144144 const prop = props[key];
145145 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -150,7 +150,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
150150 result[key] = transform(val[key], additional, getProps, key, ref);
151151 }
152152 });
153- return result;
153+ return Object.setPrototypeOf(result, Object.prototype);
154154 }
155155
156156 if (typ === "any") return val;
Mgraphql-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mgraphql-typescriptdefault / TopLevel.ts+2 −2
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 if (val === null || typeof val !== "object" || Array.isArray(val)) {
137137 return invalidValue(l(ref || "object"), val, key, parent);
138138 }
139- const result: any = {};
139+ const result: any = Object.create(null);
140140 Object.getOwnPropertyNames(props).forEach(key => {
141141 const prop = props[key];
142142 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 result[key] = transform(val[key], additional, getProps, key, ref);
148148 }
149149 });
150- return result;
150+ return Object.setPrototypeOf(result, Object.prototype);
151151 }
152152
153153 if (typ === "any") return val;
Test case

test/inputs/graphql/github5.graphql

3 generated files · +6 −6
Mgraphql-flowdefault / TopLevel.js+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Mgraphql-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mgraphql-typescriptdefault / TopLevel.ts+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Test case

test/inputs/graphql/github6.graphql

3 generated files · +6 −6
Mgraphql-flowdefault / TopLevel.js+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Mgraphql-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mgraphql-typescriptdefault / TopLevel.ts+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Test case

test/inputs/graphql/github7.graphql

3 generated files · +6 −6
Mgraphql-flowdefault / TopLevel.js+2 −2
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 if (val === null || typeof val !== "object" || Array.isArray(val)) {
143143 return invalidValue(l(ref || "object"), val, key, parent);
144144 }
145- const result: any = {};
145+ const result: any = Object.create(null);
146146 Object.getOwnPropertyNames(props).forEach(key => {
147147 const prop = props[key];
148148 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -153,7 +153,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
153153 result[key] = transform(val[key], additional, getProps, key, ref);
154154 }
155155 });
156- return result;
156+ return Object.setPrototypeOf(result, Object.prototype);
157157 }
158158
159159 if (typ === "any") return val;
Mgraphql-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mgraphql-typescriptdefault / TopLevel.ts+2 −2
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 if (val === null || typeof val !== "object" || Array.isArray(val)) {
143143 return invalidValue(l(ref || "object"), val, key, parent);
144144 }
145- const result: any = {};
145+ const result: any = Object.create(null);
146146 Object.getOwnPropertyNames(props).forEach(key => {
147147 const prop = props[key];
148148 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -153,7 +153,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
153153 result[key] = transform(val[key], additional, getProps, key, ref);
154154 }
155155 });
156- return result;
156+ return Object.setPrototypeOf(result, Object.prototype);
157157 }
158158
159159 if (typ === "any") return val;
Test case

test/inputs/graphql/github8.graphql

3 generated files · +6 −6
Mgraphql-flowdefault / TopLevel.js+2 −2
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 if (val === null || typeof val !== "object" || Array.isArray(val)) {
133133 return invalidValue(l(ref || "object"), val, key, parent);
134134 }
135- const result: any = {};
135+ const result: any = Object.create(null);
136136 Object.getOwnPropertyNames(props).forEach(key => {
137137 const prop = props[key];
138138 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -143,7 +143,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
143143 result[key] = transform(val[key], additional, getProps, key, ref);
144144 }
145145 });
146- return result;
146+ return Object.setPrototypeOf(result, Object.prototype);
147147 }
148148
149149 if (typ === "any") return val;
Mgraphql-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mgraphql-typescriptdefault / TopLevel.ts+2 −2
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 if (val === null || typeof val !== "object" || Array.isArray(val)) {
131131 return invalidValue(l(ref || "object"), val, key, parent);
132132 }
133- const result: any = {};
133+ const result: any = Object.create(null);
134134 Object.getOwnPropertyNames(props).forEach(key => {
135135 const prop = props[key];
136136 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -141,7 +141,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
141141 result[key] = transform(val[key], additional, getProps, key, ref);
142142 }
143143 });
144- return result;
144+ return Object.setPrototypeOf(result, Object.prototype);
145145 }
146146
147147 if (typ === "any") return val;
Test case

test/inputs/graphql/github9.graphql

3 generated files · +6 −6
Mgraphql-flowdefault / TopLevel.js+2 −2
@@ -139,7 +139,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
139139 if (val === null || typeof val !== "object" || Array.isArray(val)) {
140140 return invalidValue(l(ref || "object"), val, key, parent);
141141 }
142- const result: any = {};
142+ const result: any = Object.create(null);
143143 Object.getOwnPropertyNames(props).forEach(key => {
144144 const prop = props[key];
145145 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -150,7 +150,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
150150 result[key] = transform(val[key], additional, getProps, key, ref);
151151 }
152152 });
153- return result;
153+ return Object.setPrototypeOf(result, Object.prototype);
154154 }
155155
156156 if (typ === "any") return val;
Mgraphql-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mgraphql-typescriptdefault / TopLevel.ts+2 −2
@@ -133,7 +133,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
133133 if (val === null || typeof val !== "object" || Array.isArray(val)) {
134134 return invalidValue(l(ref || "object"), val, key, parent);
135135 }
136- const result: any = {};
136+ const result: any = Object.create(null);
137137 Object.getOwnPropertyNames(props).forEach(key => {
138138 const prop = props[key];
139139 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -144,7 +144,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
144144 result[key] = transform(val[key], additional, getProps, key, ref);
145145 }
146146 });
147- return result;
147+ return Object.setPrototypeOf(result, Object.prototype);
148148 }
149149
150150 if (typ === "any") return val;
Test case

test/inputs/json/misc/00c36.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -169,6 +169,14 @@ encodeFluffyQuickType x =
169169
170170 --- encoder helpers
171171
172+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
173+makeDictEncoder f m r =
174+ r
175+ |> Dict.toList
176+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
177+ |> String.join ","
178+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
179+
172180 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
173181 makeNullableEncoder f m =
174182 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 if (val === null || typeof val !== "object" || Array.isArray(val)) {
136136 return invalidValue(l(ref || "object"), val, key, parent);
137137 }
138- const result: any = {};
138+ const result: any = Object.create(null);
139139 Object.getOwnPropertyNames(props).forEach(key => {
140140 const prop = props[key];
141141 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 result[key] = transform(val[key], additional, getProps, key, ref);
147147 }
148148 });
149- return result;
149+ return Object.setPrototypeOf(result, Object.prototype);
150150 }
151151
152152 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 if (val === null || typeof val !== "object" || Array.isArray(val)) {
132132 return invalidValue(l(ref || "object"), val, key, parent);
133133 }
134- const result: any = {};
134+ const result: any = Object.create(null);
135135 Object.getOwnPropertyNames(props).forEach(key => {
136136 const prop = props[key];
137137 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 result[key] = transform(val[key], additional, getProps, key, ref);
143143 }
144144 });
145- return result;
145+ return Object.setPrototypeOf(result, Object.prototype);
146146 }
147147
148148 if (typ === "any") return val;
Test case

test/inputs/json/misc/00ec5.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -160,7 +160,7 @@ provider =
160160 encodeProvider : Provider -> Jenc.Value
161161 encodeProvider x =
162162 Jenc.object
163- [ ("properties", Jenc.dict identity encodeProperty x.properties)
163+ [ ("properties", makeDictEncoder identity encodeProperty x.properties)
164164 ]
165165
166166 property : Jdec.Decoder Property
@@ -303,6 +303,14 @@ encodeSchema x =
303303
304304 --- encoder helpers
305305
306+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
307+makeDictEncoder f m r =
308+ r
309+ |> Dict.toList
310+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
311+ |> String.join ","
312+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
313+
306314 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
307315 makeNullableEncoder f m =
308316 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -174,7 +174,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
174174 if (val === null || typeof val !== "object" || Array.isArray(val)) {
175175 return invalidValue(l(ref || "object"), val, key, parent);
176176 }
177- const result: any = {};
177+ const result: any = Object.create(null);
178178 Object.getOwnPropertyNames(props).forEach(key => {
179179 const prop = props[key];
180180 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -185,7 +185,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
185185 result[key] = transform(val[key], additional, getProps, key, ref);
186186 }
187187 });
188- return result;
188+ return Object.setPrototypeOf(result, Object.prototype);
189189 }
190190
191191 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -173,7 +173,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
173173 if (val === null || typeof val !== "object" || Array.isArray(val)) {
174174 return invalidValue(l(ref || "object"), val, key, parent);
175175 }
176- const result: any = {};
176+ const result: any = Object.create(null);
177177 Object.getOwnPropertyNames(props).forEach(key => {
178178 const prop = props[key];
179179 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -184,7 +184,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
184184 result[key] = transform(val[key], additional, getProps, key, ref);
185185 }
186186 });
187- return result;
187+ return Object.setPrototypeOf(result, Object.prototype);
188188 }
189189
190190 if (typ === "any") return val;
Test case

test/inputs/json/misc/010b1.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -88,6 +88,14 @@ encodeCountry x = case x of
8888
8989 --- encoder helpers
9090
91+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
92+makeDictEncoder f m r =
93+ r
94+ |> Dict.toList
95+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
96+ |> String.join ","
97+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
98+
9199 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
92100 makeNullableEncoder f m =
93101 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/json/misc/016af.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/033b1.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/050b0.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -274,6 +274,14 @@ encodeTitle x = case x of
274274
275275 --- encoder helpers
276276
277+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
278+makeDictEncoder f m r =
279+ r
280+ |> Dict.toList
281+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
282+ |> String.join ","
283+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
284+
277285 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
278286 makeNullableEncoder f m =
279287 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -163,7 +163,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
163163 if (val === null || typeof val !== "object" || Array.isArray(val)) {
164164 return invalidValue(l(ref || "object"), val, key, parent);
165165 }
166- const result: any = {};
166+ const result: any = Object.create(null);
167167 Object.getOwnPropertyNames(props).forEach(key => {
168168 const prop = props[key];
169169 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -174,7 +174,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
174174 result[key] = transform(val[key], additional, getProps, key, ref);
175175 }
176176 });
177- return result;
177+ return Object.setPrototypeOf(result, Object.prototype);
178178 }
179179
180180 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 if (val === null || typeof val !== "object" || Array.isArray(val)) {
148148 return invalidValue(l(ref || "object"), val, key, parent);
149149 }
150- const result: any = {};
150+ const result: any = Object.create(null);
151151 Object.getOwnPropertyNames(props).forEach(key => {
152152 const prop = props[key];
153153 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -158,7 +158,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
158158 result[key] = transform(val[key], additional, getProps, key, ref);
159159 }
160160 });
161- return result;
161+ return Object.setPrototypeOf(result, Object.prototype);
162162 }
163163
164164 if (typ === "any") return val;
Test case

test/inputs/json/misc/06bee.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -234,6 +234,14 @@ encodeTitle x = case x of
234234
235235 --- encoder helpers
236236
237+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
238+makeDictEncoder f m r =
239+ r
240+ |> Dict.toList
241+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
242+ |> String.join ","
243+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
244+
237245 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
238246 makeNullableEncoder f m =
239247 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 if (val === null || typeof val !== "object" || Array.isArray(val)) {
152152 return invalidValue(l(ref || "object"), val, key, parent);
153153 }
154- const result: any = {};
154+ const result: any = Object.create(null);
155155 Object.getOwnPropertyNames(props).forEach(key => {
156156 const prop = props[key];
157157 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -162,7 +162,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
162162 result[key] = transform(val[key], additional, getProps, key, ref);
163163 }
164164 });
165- return result;
165+ return Object.setPrototypeOf(result, Object.prototype);
166166 }
167167
168168 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 if (val === null || typeof val !== "object" || Array.isArray(val)) {
143143 return invalidValue(l(ref || "object"), val, key, parent);
144144 }
145- const result: any = {};
145+ const result: any = Object.create(null);
146146 Object.getOwnPropertyNames(props).forEach(key => {
147147 const prop = props[key];
148148 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -153,7 +153,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
153153 result[key] = transform(val[key], additional, getProps, key, ref);
154154 }
155155 });
156- return result;
156+ return Object.setPrototypeOf(result, Object.prototype);
157157 }
158158
159159 if (typ === "any") return val;
Test case

test/inputs/json/misc/07540.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -65,6 +65,14 @@ encodeCookies x =
6565
6666 --- encoder helpers
6767
68+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
69+makeDictEncoder f m r =
70+ r
71+ |> Dict.toList
72+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
73+ |> String.join ","
74+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
75+
6876 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6977 makeNullableEncoder f m =
7078 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Test case

test/inputs/json/misc/0779f.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/07c75.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -137,6 +137,14 @@ encodeText x =
137137
138138 --- encoder helpers
139139
140+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
141+makeDictEncoder f m r =
142+ r
143+ |> Dict.toList
144+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
145+ |> String.join ","
146+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
147+
140148 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
141149 makeNullableEncoder f m =
142150 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 if (val === null || typeof val !== "object" || Array.isArray(val)) {
133133 return invalidValue(l(ref || "object"), val, key, parent);
134134 }
135- const result: any = {};
135+ const result: any = Object.create(null);
136136 Object.getOwnPropertyNames(props).forEach(key => {
137137 const prop = props[key];
138138 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -143,7 +143,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
143143 result[key] = transform(val[key], additional, getProps, key, ref);
144144 }
145145 });
146- return result;
146+ return Object.setPrototypeOf(result, Object.prototype);
147147 }
148148
149149 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 if (val === null || typeof val !== "object" || Array.isArray(val)) {
133133 return invalidValue(l(ref || "object"), val, key, parent);
134134 }
135- const result: any = {};
135+ const result: any = Object.create(null);
136136 Object.getOwnPropertyNames(props).forEach(key => {
137137 const prop = props[key];
138138 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -143,7 +143,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
143143 result[key] = transform(val[key], additional, getProps, key, ref);
144144 }
145145 });
146- return result;
146+ return Object.setPrototypeOf(result, Object.prototype);
147147 }
148148
149149 if (typ === "any") return val;
Test case

test/inputs/json/misc/09f54.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -61,7 +61,7 @@ quickType =
6161 encodeQuickType : QuickType -> Jenc.Value
6262 encodeQuickType x =
6363 Jenc.object
64- [ ("data", Jenc.dict identity encodeDatum x.data)
64+ [ ("data", makeDictEncoder identity encodeDatum x.data)
6565 , ("description", encodeDescription x.description)
6666 ]
6767
@@ -97,6 +97,14 @@ encodeDescription x =
9797
9898 --- encoder helpers
9999
100+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
101+makeDictEncoder f m r =
102+ r
103+ |> Dict.toList
104+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
105+ |> String.join ","
106+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
107+
100108 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
101109 makeNullableEncoder f m =
102110 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Test case

test/inputs/json/misc/0a358.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -114,6 +114,14 @@ encodeResult x =
114114
115115 --- encoder helpers
116116
117+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
118+makeDictEncoder f m r =
119+ r
120+ |> Dict.toList
121+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
122+ |> String.join ","
123+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
124+
117125 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
118126 makeNullableEncoder f m =
119127 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 if (val === null || typeof val !== "object" || Array.isArray(val)) {
126126 return invalidValue(l(ref || "object"), val, key, parent);
127127 }
128- const result: any = {};
128+ const result: any = Object.create(null);
129129 Object.getOwnPropertyNames(props).forEach(key => {
130130 const prop = props[key];
131131 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 result[key] = transform(val[key], additional, getProps, key, ref);
137137 }
138138 });
139- return result;
139+ return Object.setPrototypeOf(result, Object.prototype);
140140 }
141141
142142 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 if (val === null || typeof val !== "object" || Array.isArray(val)) {
123123 return invalidValue(l(ref || "object"), val, key, parent);
124124 }
125- const result: any = {};
125+ const result: any = Object.create(null);
126126 Object.getOwnPropertyNames(props).forEach(key => {
127127 const prop = props[key];
128128 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -133,7 +133,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
133133 result[key] = transform(val[key], additional, getProps, key, ref);
134134 }
135135 });
136- return result;
136+ return Object.setPrototypeOf(result, Object.prototype);
137137 }
138138
139139 if (typ === "any") return val;
Test case

test/inputs/json/misc/0a91a.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -762,6 +762,14 @@ encodeQuickTypeRepo x =
762762
763763 --- encoder helpers
764764
765+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
766+makeDictEncoder f m r =
767+ r
768+ |> Dict.toList
769+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
770+ |> String.join ","
771+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
772+
765773 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
766774 makeNullableEncoder f m =
767775 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -327,7 +327,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
327327 if (val === null || typeof val !== "object" || Array.isArray(val)) {
328328 return invalidValue(l(ref || "object"), val, key, parent);
329329 }
330- const result: any = {};
330+ const result: any = Object.create(null);
331331 Object.getOwnPropertyNames(props).forEach(key => {
332332 const prop = props[key];
333333 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -338,7 +338,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
338338 result[key] = transform(val[key], additional, getProps, key, ref);
339339 }
340340 });
341- return result;
341+ return Object.setPrototypeOf(result, Object.prototype);
342342 }
343343
344344 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -322,7 +322,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
322322 if (val === null || typeof val !== "object" || Array.isArray(val)) {
323323 return invalidValue(l(ref || "object"), val, key, parent);
324324 }
325- const result: any = {};
325+ const result: any = Object.create(null);
326326 Object.getOwnPropertyNames(props).forEach(key => {
327327 const prop = props[key];
328328 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -333,7 +333,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
333333 result[key] = transform(val[key], additional, getProps, key, ref);
334334 }
335335 });
336- return result;
336+ return Object.setPrototypeOf(result, Object.prototype);
337337 }
338338
339339 if (typ === "any") return val;
Test case

test/inputs/json/misc/0b91a.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -190,6 +190,14 @@ encodeComponent x =
190190
191191 --- encoder helpers
192192
193+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
194+makeDictEncoder f m r =
195+ r
196+ |> Dict.toList
197+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
198+ |> String.join ","
199+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
200+
193201 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
194202 makeNullableEncoder f m =
195203 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 if (val === null || typeof val !== "object" || Array.isArray(val)) {
148148 return invalidValue(l(ref || "object"), val, key, parent);
149149 }
150- const result: any = {};
150+ const result: any = Object.create(null);
151151 Object.getOwnPropertyNames(props).forEach(key => {
152152 const prop = props[key];
153153 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -158,7 +158,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
158158 result[key] = transform(val[key], additional, getProps, key, ref);
159159 }
160160 });
161- return result;
161+ return Object.setPrototypeOf(result, Object.prototype);
162162 }
163163
164164 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 if (val === null || typeof val !== "object" || Array.isArray(val)) {
148148 return invalidValue(l(ref || "object"), val, key, parent);
149149 }
150- const result: any = {};
150+ const result: any = Object.create(null);
151151 Object.getOwnPropertyNames(props).forEach(key => {
152152 const prop = props[key];
153153 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -158,7 +158,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
158158 result[key] = transform(val[key], additional, getProps, key, ref);
159159 }
160160 });
161- return result;
161+ return Object.setPrototypeOf(result, Object.prototype);
162162 }
163163
164164 if (typ === "any") return val;
Test case

test/inputs/json/misc/0cffa.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -455,6 +455,14 @@ encodePagination x =
455455
456456 --- encoder helpers
457457
458+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
459+makeDictEncoder f m r =
460+ r
461+ |> Dict.toList
462+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
463+ |> String.join ","
464+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
465+
458466 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
459467 makeNullableEncoder f m =
460468 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -222,7 +222,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
222222 if (val === null || typeof val !== "object" || Array.isArray(val)) {
223223 return invalidValue(l(ref || "object"), val, key, parent);
224224 }
225- const result: any = {};
225+ const result: any = Object.create(null);
226226 Object.getOwnPropertyNames(props).forEach(key => {
227227 const prop = props[key];
228228 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -233,7 +233,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
233233 result[key] = transform(val[key], additional, getProps, key, ref);
234234 }
235235 });
236- return result;
236+ return Object.setPrototypeOf(result, Object.prototype);
237237 }
238238
239239 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -215,7 +215,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
215215 if (val === null || typeof val !== "object" || Array.isArray(val)) {
216216 return invalidValue(l(ref || "object"), val, key, parent);
217217 }
218- const result: any = {};
218+ const result: any = Object.create(null);
219219 Object.getOwnPropertyNames(props).forEach(key => {
220220 const prop = props[key];
221221 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -226,7 +226,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
226226 result[key] = transform(val[key], additional, getProps, key, ref);
227227 }
228228 });
229- return result;
229+ return Object.setPrototypeOf(result, Object.prototype);
230230 }
231231
232232 if (typ === "any") return val;
Test case

test/inputs/json/misc/0e0c2.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -333,6 +333,14 @@ encodeVoteScore x =
333333
334334 --- encoder helpers
335335
336+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
337+makeDictEncoder f m r =
338+ r
339+ |> Dict.toList
340+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
341+ |> String.join ","
342+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
343+
336344 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
337345 makeNullableEncoder f m =
338346 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -184,7 +184,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
184184 if (val === null || typeof val !== "object" || Array.isArray(val)) {
185185 return invalidValue(l(ref || "object"), val, key, parent);
186186 }
187- const result: any = {};
187+ const result: any = Object.create(null);
188188 Object.getOwnPropertyNames(props).forEach(key => {
189189 const prop = props[key];
190190 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -195,7 +195,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
195195 result[key] = transform(val[key], additional, getProps, key, ref);
196196 }
197197 });
198- return result;
198+ return Object.setPrototypeOf(result, Object.prototype);
199199 }
200200
201201 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -178,7 +178,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
178178 if (val === null || typeof val !== "object" || Array.isArray(val)) {
179179 return invalidValue(l(ref || "object"), val, key, parent);
180180 }
181- const result: any = {};
181+ const result: any = Object.create(null);
182182 Object.getOwnPropertyNames(props).forEach(key => {
183183 const prop = props[key];
184184 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -189,7 +189,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
189189 result[key] = transform(val[key], additional, getProps, key, ref);
190190 }
191191 });
192- return result;
192+ return Object.setPrototypeOf(result, Object.prototype);
193193 }
194194
195195 if (typ === "any") return val;
Test case

test/inputs/json/misc/0fecf.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Test case

test/inputs/json/misc/10be4.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -307,6 +307,14 @@ encodeTitle x = case x of
307307
308308 --- encoder helpers
309309
310+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
311+makeDictEncoder f m r =
312+ r
313+ |> Dict.toList
314+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
315+ |> String.join ","
316+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
317+
310318 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
311319 makeNullableEncoder f m =
312320 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -174,7 +174,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
174174 if (val === null || typeof val !== "object" || Array.isArray(val)) {
175175 return invalidValue(l(ref || "object"), val, key, parent);
176176 }
177- const result: any = {};
177+ const result: any = Object.create(null);
178178 Object.getOwnPropertyNames(props).forEach(key => {
179179 const prop = props[key];
180180 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -185,7 +185,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
185185 result[key] = transform(val[key], additional, getProps, key, ref);
186186 }
187187 });
188- return result;
188+ return Object.setPrototypeOf(result, Object.prototype);
189189 }
190190
191191 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 if (val === null || typeof val !== "object" || Array.isArray(val)) {
148148 return invalidValue(l(ref || "object"), val, key, parent);
149149 }
150- const result: any = {};
150+ const result: any = Object.create(null);
151151 Object.getOwnPropertyNames(props).forEach(key => {
152152 const prop = props[key];
153153 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -158,7 +158,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
158158 result[key] = transform(val[key], additional, getProps, key, ref);
159159 }
160160 });
161- return result;
161+ return Object.setPrototypeOf(result, Object.prototype);
162162 }
163163
164164 if (typ === "any") return val;
Test case

test/inputs/json/misc/112b5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -99,6 +99,14 @@ encodeHeaders x =
9999
100100 --- encoder helpers
101101
102+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
103+makeDictEncoder f m r =
104+ r
105+ |> Dict.toList
106+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
107+ |> String.join ","
108+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
109+
102110 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
103111 makeNullableEncoder f m =
104112 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Test case

test/inputs/json/misc/127a1.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -452,6 +452,14 @@ encodePagination x =
452452
453453 --- encoder helpers
454454
455+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
456+makeDictEncoder f m r =
457+ r
458+ |> Dict.toList
459+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
460+ |> String.join ","
461+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
462+
455463 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
456464 makeNullableEncoder f m =
457465 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -221,7 +221,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
221221 if (val === null || typeof val !== "object" || Array.isArray(val)) {
222222 return invalidValue(l(ref || "object"), val, key, parent);
223223 }
224- const result: any = {};
224+ const result: any = Object.create(null);
225225 Object.getOwnPropertyNames(props).forEach(key => {
226226 const prop = props[key];
227227 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -232,7 +232,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
232232 result[key] = transform(val[key], additional, getProps, key, ref);
233233 }
234234 });
235- return result;
235+ return Object.setPrototypeOf(result, Object.prototype);
236236 }
237237
238238 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -215,7 +215,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
215215 if (val === null || typeof val !== "object" || Array.isArray(val)) {
216216 return invalidValue(l(ref || "object"), val, key, parent);
217217 }
218- const result: any = {};
218+ const result: any = Object.create(null);
219219 Object.getOwnPropertyNames(props).forEach(key => {
220220 const prop = props[key];
221221 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -226,7 +226,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
226226 result[key] = transform(val[key], additional, getProps, key, ref);
227227 }
228228 });
229- return result;
229+ return Object.setPrototypeOf(result, Object.prototype);
230230 }
231231
232232 if (typ === "any") return val;
Test case

test/inputs/json/misc/13d8d.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -140,6 +140,14 @@ encodeOutcomeStatus x =
140140
141141 --- encoder helpers
142142
143+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
144+makeDictEncoder f m r =
145+ r
146+ |> Dict.toList
147+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
148+ |> String.join ","
149+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
150+
143151 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
144152 makeNullableEncoder f m =
145153 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -133,7 +133,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
133133 if (val === null || typeof val !== "object" || Array.isArray(val)) {
134134 return invalidValue(l(ref || "object"), val, key, parent);
135135 }
136- const result: any = {};
136+ const result: any = Object.create(null);
137137 Object.getOwnPropertyNames(props).forEach(key => {
138138 const prop = props[key];
139139 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -144,7 +144,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
144144 result[key] = transform(val[key], additional, getProps, key, ref);
145145 }
146146 });
147- return result;
147+ return Object.setPrototypeOf(result, Object.prototype);
148148 }
149149
150150 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -133,7 +133,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
133133 if (val === null || typeof val !== "object" || Array.isArray(val)) {
134134 return invalidValue(l(ref || "object"), val, key, parent);
135135 }
136- const result: any = {};
136+ const result: any = Object.create(null);
137137 Object.getOwnPropertyNames(props).forEach(key => {
138138 const prop = props[key];
139139 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -144,7 +144,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
144144 result[key] = transform(val[key], additional, getProps, key, ref);
145145 }
146146 });
147- return result;
147+ return Object.setPrototypeOf(result, Object.prototype);
148148 }
149149
150150 if (typ === "any") return val;
Test case

test/inputs/json/misc/14d38.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -75,6 +75,14 @@ encodeHeaders x =
7575
7676 --- encoder helpers
7777
78+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
79+makeDictEncoder f m r =
80+ r
81+ |> Dict.toList
82+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
83+ |> String.join ","
84+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
85+
7886 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7987 makeNullableEncoder f m =
8088 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/json/misc/167d6.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/16bc5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -396,6 +396,14 @@ encodeWind x =
396396
397397 --- encoder helpers
398398
399+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
400+makeDictEncoder f m r =
401+ r
402+ |> Dict.toList
403+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
404+ |> String.join ","
405+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
406+
399407 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
400408 makeNullableEncoder f m =
401409 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Test case

test/inputs/json/misc/176f1.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -141,6 +141,14 @@ encodeFootnote x =
141141
142142 --- encoder helpers
143143
144+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
145+makeDictEncoder f m r =
146+ r
147+ |> Dict.toList
148+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
149+ |> String.join ","
150+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
151+
144152 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
145153 makeNullableEncoder f m =
146154 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 if (val === null || typeof val !== "object" || Array.isArray(val)) {
133133 return invalidValue(l(ref || "object"), val, key, parent);
134134 }
135- const result: any = {};
135+ const result: any = Object.create(null);
136136 Object.getOwnPropertyNames(props).forEach(key => {
137137 const prop = props[key];
138138 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -143,7 +143,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
143143 result[key] = transform(val[key], additional, getProps, key, ref);
144144 }
145145 });
146- return result;
146+ return Object.setPrototypeOf(result, Object.prototype);
147147 }
148148
149149 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 if (val === null || typeof val !== "object" || Array.isArray(val)) {
133133 return invalidValue(l(ref || "object"), val, key, parent);
134134 }
135- const result: any = {};
135+ const result: any = Object.create(null);
136136 Object.getOwnPropertyNames(props).forEach(key => {
137137 const prop = props[key];
138138 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -143,7 +143,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
143143 result[key] = transform(val[key], additional, getProps, key, ref);
144144 }
145145 });
146- return result;
146+ return Object.setPrototypeOf(result, Object.prototype);
147147 }
148148
149149 if (typ === "any") return val;
Test case

test/inputs/json/misc/1a7f5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -88,6 +88,14 @@ encodeCountry x = case x of
8888
8989 --- encoder helpers
9090
91+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
92+makeDictEncoder f m r =
93+ r
94+ |> Dict.toList
95+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
96+ |> String.join ","
97+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
98+
9199 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
92100 makeNullableEncoder f m =
93101 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/json/misc/1b28c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/1b409.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -395,6 +395,14 @@ encodeTitle x = case x of
395395
396396 --- encoder helpers
397397
398+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
399+makeDictEncoder f m r =
400+ r
401+ |> Dict.toList
402+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
403+ |> String.join ","
404+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
405+
398406 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
399407 makeNullableEncoder f m =
400408 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -198,7 +198,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
198198 if (val === null || typeof val !== "object" || Array.isArray(val)) {
199199 return invalidValue(l(ref || "object"), val, key, parent);
200200 }
201- const result: any = {};
201+ const result: any = Object.create(null);
202202 Object.getOwnPropertyNames(props).forEach(key => {
203203 const prop = props[key];
204204 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -209,7 +209,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
209209 result[key] = transform(val[key], additional, getProps, key, ref);
210210 }
211211 });
212- return result;
212+ return Object.setPrototypeOf(result, Object.prototype);
213213 }
214214
215215 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -181,7 +181,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
181181 if (val === null || typeof val !== "object" || Array.isArray(val)) {
182182 return invalidValue(l(ref || "object"), val, key, parent);
183183 }
184- const result: any = {};
184+ const result: any = Object.create(null);
185185 Object.getOwnPropertyNames(props).forEach(key => {
186186 const prop = props[key];
187187 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -192,7 +192,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
192192 result[key] = transform(val[key], additional, getProps, key, ref);
193193 }
194194 });
195- return result;
195+ return Object.setPrototypeOf(result, Object.prototype);
196196 }
197197
198198 if (typ === "any") return val;
Test case

test/inputs/json/misc/2465e.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -317,6 +317,14 @@ encodeSchema x =
317317
318318 --- encoder helpers
319319
320+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
321+makeDictEncoder f m r =
322+ r
323+ |> Dict.toList
324+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
325+ |> String.join ","
326+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
327+
320328 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
321329 makeNullableEncoder f m =
322330 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -180,7 +180,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
180180 if (val === null || typeof val !== "object" || Array.isArray(val)) {
181181 return invalidValue(l(ref || "object"), val, key, parent);
182182 }
183- const result: any = {};
183+ const result: any = Object.create(null);
184184 Object.getOwnPropertyNames(props).forEach(key => {
185185 const prop = props[key];
186186 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -191,7 +191,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
191191 result[key] = transform(val[key], additional, getProps, key, ref);
192192 }
193193 });
194- return result;
194+ return Object.setPrototypeOf(result, Object.prototype);
195195 }
196196
197197 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -180,7 +180,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
180180 if (val === null || typeof val !== "object" || Array.isArray(val)) {
181181 return invalidValue(l(ref || "object"), val, key, parent);
182182 }
183- const result: any = {};
183+ const result: any = Object.create(null);
184184 Object.getOwnPropertyNames(props).forEach(key => {
185185 const prop = props[key];
186186 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -191,7 +191,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
191191 result[key] = transform(val[key], additional, getProps, key, ref);
192192 }
193193 });
194- return result;
194+ return Object.setPrototypeOf(result, Object.prototype);
195195 }
196196
197197 if (typ === "any") return val;
Test case

test/inputs/json/misc/24f52.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/262f0.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -419,6 +419,14 @@ encodeWind x =
419419
420420 --- encoder helpers
421421
422+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
423+makeDictEncoder f m r =
424+ r
425+ |> Dict.toList
426+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
427+ |> String.join ","
428+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
429+
422430 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
423431 makeNullableEncoder f m =
424432 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -210,7 +210,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
210210 if (val === null || typeof val !== "object" || Array.isArray(val)) {
211211 return invalidValue(l(ref || "object"), val, key, parent);
212212 }
213- const result: any = {};
213+ const result: any = Object.create(null);
214214 Object.getOwnPropertyNames(props).forEach(key => {
215215 const prop = props[key];
216216 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -221,7 +221,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
221221 result[key] = transform(val[key], additional, getProps, key, ref);
222222 }
223223 });
224- return result;
224+ return Object.setPrototypeOf(result, Object.prototype);
225225 }
226226
227227 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -207,7 +207,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
207207 if (val === null || typeof val !== "object" || Array.isArray(val)) {
208208 return invalidValue(l(ref || "object"), val, key, parent);
209209 }
210- const result: any = {};
210+ const result: any = Object.create(null);
211211 Object.getOwnPropertyNames(props).forEach(key => {
212212 const prop = props[key];
213213 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -218,7 +218,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
218218 result[key] = transform(val[key], additional, getProps, key, ref);
219219 }
220220 });
221- return result;
221+ return Object.setPrototypeOf(result, Object.prototype);
222222 }
223223
224224 if (typ === "any") return val;
Test case

test/inputs/json/misc/26b49.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -438,6 +438,14 @@ encodePagination x =
438438
439439 --- encoder helpers
440440
441+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
442+makeDictEncoder f m r =
443+ r
444+ |> Dict.toList
445+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
446+ |> String.join ","
447+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
448+
441449 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
442450 makeNullableEncoder f m =
443451 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -219,7 +219,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
219219 if (val === null || typeof val !== "object" || Array.isArray(val)) {
220220 return invalidValue(l(ref || "object"), val, key, parent);
221221 }
222- const result: any = {};
222+ const result: any = Object.create(null);
223223 Object.getOwnPropertyNames(props).forEach(key => {
224224 const prop = props[key];
225225 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -230,7 +230,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
230230 result[key] = transform(val[key], additional, getProps, key, ref);
231231 }
232232 });
233- return result;
233+ return Object.setPrototypeOf(result, Object.prototype);
234234 }
235235
236236 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -214,7 +214,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
214214 if (val === null || typeof val !== "object" || Array.isArray(val)) {
215215 return invalidValue(l(ref || "object"), val, key, parent);
216216 }
217- const result: any = {};
217+ const result: any = Object.create(null);
218218 Object.getOwnPropertyNames(props).forEach(key => {
219219 const prop = props[key];
220220 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -225,7 +225,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
225225 result[key] = transform(val[key], additional, getProps, key, ref);
226226 }
227227 });
228- return result;
228+ return Object.setPrototypeOf(result, Object.prototype);
229229 }
230230
231231 if (typ === "any") return val;
Test case

test/inputs/json/misc/26c9c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -717,6 +717,14 @@ encodeExpression x =
717717
718718 --- encoder helpers
719719
720+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
721+makeDictEncoder f m r =
722+ r
723+ |> Dict.toList
724+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
725+ |> String.join ","
726+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
727+
720728 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
721729 makeNullableEncoder f m =
722730 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -294,7 +294,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
294294 if (val === null || typeof val !== "object" || Array.isArray(val)) {
295295 return invalidValue(l(ref || "object"), val, key, parent);
296296 }
297- const result: any = {};
297+ const result: any = Object.create(null);
298298 Object.getOwnPropertyNames(props).forEach(key => {
299299 const prop = props[key];
300300 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -305,7 +305,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
305305 result[key] = transform(val[key], additional, getProps, key, ref);
306306 }
307307 });
308- return result;
308+ return Object.setPrototypeOf(result, Object.prototype);
309309 }
310310
311311 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -294,7 +294,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
294294 if (val === null || typeof val !== "object" || Array.isArray(val)) {
295295 return invalidValue(l(ref || "object"), val, key, parent);
296296 }
297- const result: any = {};
297+ const result: any = Object.create(null);
298298 Object.getOwnPropertyNames(props).forEach(key => {
299299 const prop = props[key];
300300 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -305,7 +305,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
305305 result[key] = transform(val[key], additional, getProps, key, ref);
306306 }
307307 });
308- return result;
308+ return Object.setPrototypeOf(result, Object.prototype);
309309 }
310310
311311 if (typ === "any") return val;
Test case

test/inputs/json/misc/27332.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -607,6 +607,14 @@ encodeKind x = case x of
607607
608608 --- encoder helpers
609609
610+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
611+makeDictEncoder f m r =
612+ r
613+ |> Dict.toList
614+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
615+ |> String.join ","
616+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
617+
610618 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
611619 makeNullableEncoder f m =
612620 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -260,7 +260,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
260260 if (val === null || typeof val !== "object" || Array.isArray(val)) {
261261 return invalidValue(l(ref || "object"), val, key, parent);
262262 }
263- const result: any = {};
263+ const result: any = Object.create(null);
264264 Object.getOwnPropertyNames(props).forEach(key => {
265265 const prop = props[key];
266266 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -271,7 +271,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
271271 result[key] = transform(val[key], additional, getProps, key, ref);
272272 }
273273 });
274- return result;
274+ return Object.setPrototypeOf(result, Object.prototype);
275275 }
276276
277277 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -246,7 +246,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
246246 if (val === null || typeof val !== "object" || Array.isArray(val)) {
247247 return invalidValue(l(ref || "object"), val, key, parent);
248248 }
249- const result: any = {};
249+ const result: any = Object.create(null);
250250 Object.getOwnPropertyNames(props).forEach(key => {
251251 const prop = props[key];
252252 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -257,7 +257,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
257257 result[key] = transform(val[key], additional, getProps, key, ref);
258258 }
259259 });
260- return result;
260+ return Object.setPrototypeOf(result, Object.prototype);
261261 }
262262
263263 if (typ === "any") return val;
Test case

test/inputs/json/misc/29f47.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -580,6 +580,14 @@ encodeKind x = case x of
580580
581581 --- encoder helpers
582582
583+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
584+makeDictEncoder f m r =
585+ r
586+ |> Dict.toList
587+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
588+ |> String.join ","
589+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
590+
583591 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
584592 makeNullableEncoder f m =
585593 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -246,7 +246,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
246246 if (val === null || typeof val !== "object" || Array.isArray(val)) {
247247 return invalidValue(l(ref || "object"), val, key, parent);
248248 }
249- const result: any = {};
249+ const result: any = Object.create(null);
250250 Object.getOwnPropertyNames(props).forEach(key => {
251251 const prop = props[key];
252252 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -257,7 +257,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
257257 result[key] = transform(val[key], additional, getProps, key, ref);
258258 }
259259 });
260- return result;
260+ return Object.setPrototypeOf(result, Object.prototype);
261261 }
262262
263263 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -233,7 +233,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
233233 if (val === null || typeof val !== "object" || Array.isArray(val)) {
234234 return invalidValue(l(ref || "object"), val, key, parent);
235235 }
236- const result: any = {};
236+ const result: any = Object.create(null);
237237 Object.getOwnPropertyNames(props).forEach(key => {
238238 const prop = props[key];
239239 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -244,7 +244,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
244244 result[key] = transform(val[key], additional, getProps, key, ref);
245245 }
246246 });
247- return result;
247+ return Object.setPrototypeOf(result, Object.prototype);
248248 }
249249
250250 if (typ === "any") return val;
Test case

test/inputs/json/misc/2d4e2.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -475,6 +475,14 @@ encodeTitle x = case x of
475475
476476 --- encoder helpers
477477
478+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
479+makeDictEncoder f m r =
480+ r
481+ |> Dict.toList
482+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
483+ |> String.join ","
484+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
485+
478486 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
479487 makeNullableEncoder f m =
480488 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -214,7 +214,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
214214 if (val === null || typeof val !== "object" || Array.isArray(val)) {
215215 return invalidValue(l(ref || "object"), val, key, parent);
216216 }
217- const result: any = {};
217+ const result: any = Object.create(null);
218218 Object.getOwnPropertyNames(props).forEach(key => {
219219 const prop = props[key];
220220 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -225,7 +225,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
225225 result[key] = transform(val[key], additional, getProps, key, ref);
226226 }
227227 });
228- return result;
228+ return Object.setPrototypeOf(result, Object.prototype);
229229 }
230230
231231 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -191,7 +191,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
191191 if (val === null || typeof val !== "object" || Array.isArray(val)) {
192192 return invalidValue(l(ref || "object"), val, key, parent);
193193 }
194- const result: any = {};
194+ const result: any = Object.create(null);
195195 Object.getOwnPropertyNames(props).forEach(key => {
196196 const prop = props[key];
197197 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -202,7 +202,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
202202 result[key] = transform(val[key], additional, getProps, key, ref);
203203 }
204204 });
205- return result;
205+ return Object.setPrototypeOf(result, Object.prototype);
206206 }
207207
208208 if (typ === "any") return val;
Test case

test/inputs/json/misc/2df80.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -304,6 +304,14 @@ encodeFluffyQuickType x =
304304
305305 --- encoder helpers
306306
307+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
308+makeDictEncoder f m r =
309+ r
310+ |> Dict.toList
311+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
312+ |> String.join ","
313+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
314+
307315 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
308316 makeNullableEncoder f m =
309317 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -180,7 +180,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
180180 if (val === null || typeof val !== "object" || Array.isArray(val)) {
181181 return invalidValue(l(ref || "object"), val, key, parent);
182182 }
183- const result: any = {};
183+ const result: any = Object.create(null);
184184 Object.getOwnPropertyNames(props).forEach(key => {
185185 const prop = props[key];
186186 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -191,7 +191,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
191191 result[key] = transform(val[key], additional, getProps, key, ref);
192192 }
193193 });
194- return result;
194+ return Object.setPrototypeOf(result, Object.prototype);
195195 }
196196
197197 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 if (val === null || typeof val !== "object" || Array.isArray(val)) {
137137 return invalidValue(l(ref || "object"), val, key, parent);
138138 }
139- const result: any = {};
139+ const result: any = Object.create(null);
140140 Object.getOwnPropertyNames(props).forEach(key => {
141141 const prop = props[key];
142142 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 result[key] = transform(val[key], additional, getProps, key, ref);
148148 }
149149 });
150- return result;
150+ return Object.setPrototypeOf(result, Object.prototype);
151151 }
152152
153153 if (typ === "any") return val;
Test case

test/inputs/json/misc/31189.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -131,6 +131,14 @@ encodeRates x =
131131
132132 --- encoder helpers
133133
134+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
135+makeDictEncoder f m r =
136+ r
137+ |> Dict.toList
138+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
139+ |> String.join ","
140+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
141+
134142 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
135143 makeNullableEncoder f m =
136144 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 if (val === null || typeof val !== "object" || Array.isArray(val)) {
136136 return invalidValue(l(ref || "object"), val, key, parent);
137137 }
138- const result: any = {};
138+ const result: any = Object.create(null);
139139 Object.getOwnPropertyNames(props).forEach(key => {
140140 const prop = props[key];
141141 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 result[key] = transform(val[key], additional, getProps, key, ref);
147147 }
148148 });
149- return result;
149+ return Object.setPrototypeOf(result, Object.prototype);
150150 }
151151
152152 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -134,7 +134,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
134134 if (val === null || typeof val !== "object" || Array.isArray(val)) {
135135 return invalidValue(l(ref || "object"), val, key, parent);
136136 }
137- const result: any = {};
137+ const result: any = Object.create(null);
138138 Object.getOwnPropertyNames(props).forEach(key => {
139139 const prop = props[key];
140140 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -145,7 +145,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
145145 result[key] = transform(val[key], additional, getProps, key, ref);
146146 }
147147 });
148- return result;
148+ return Object.setPrototypeOf(result, Object.prototype);
149149 }
150150
151151 if (typ === "any") return val;
Test case

test/inputs/json/misc/32431.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -319,6 +319,14 @@ encodeMetadata x =
319319
320320 --- encoder helpers
321321
322+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
323+makeDictEncoder f m r =
324+ r
325+ |> Dict.toList
326+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
327+ |> String.join ","
328+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
329+
322330 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
323331 makeNullableEncoder f m =
324332 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -178,7 +178,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
178178 if (val === null || typeof val !== "object" || Array.isArray(val)) {
179179 return invalidValue(l(ref || "object"), val, key, parent);
180180 }
181- const result: any = {};
181+ const result: any = Object.create(null);
182182 Object.getOwnPropertyNames(props).forEach(key => {
183183 const prop = props[key];
184184 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -189,7 +189,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
189189 result[key] = transform(val[key], additional, getProps, key, ref);
190190 }
191191 });
192- return result;
192+ return Object.setPrototypeOf(result, Object.prototype);
193193 }
194194
195195 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -170,7 +170,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
170170 if (val === null || typeof val !== "object" || Array.isArray(val)) {
171171 return invalidValue(l(ref || "object"), val, key, parent);
172172 }
173- const result: any = {};
173+ const result: any = Object.create(null);
174174 Object.getOwnPropertyNames(props).forEach(key => {
175175 const prop = props[key];
176176 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -181,7 +181,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
181181 result[key] = transform(val[key], additional, getProps, key, ref);
182182 }
183183 });
184- return result;
184+ return Object.setPrototypeOf(result, Object.prototype);
185185 }
186186
187187 if (typ === "any") return val;
Test case

test/inputs/json/misc/32d5c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -77,6 +77,14 @@ encodeQuickTypeElement x =
7777
7878 --- encoder helpers
7979
80+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
81+makeDictEncoder f m r =
82+ r
83+ |> Dict.toList
84+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
85+ |> String.join ","
86+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
87+
8088 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8189 makeNullableEncoder f m =
8290 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/json/misc/337ed.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -292,6 +292,14 @@ encodeResultType x = case x of
292292
293293 --- encoder helpers
294294
295+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
296+makeDictEncoder f m r =
297+ r
298+ |> Dict.toList
299+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
300+ |> String.join ","
301+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
302+
295303 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
296304 makeNullableEncoder f m =
297305 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -175,7 +175,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
175175 if (val === null || typeof val !== "object" || Array.isArray(val)) {
176176 return invalidValue(l(ref || "object"), val, key, parent);
177177 }
178- const result: any = {};
178+ const result: any = Object.create(null);
179179 Object.getOwnPropertyNames(props).forEach(key => {
180180 const prop = props[key];
181181 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -186,7 +186,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
186186 result[key] = transform(val[key], additional, getProps, key, ref);
187187 }
188188 });
189- return result;
189+ return Object.setPrototypeOf(result, Object.prototype);
190190 }
191191
192192 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -165,7 +165,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
165165 if (val === null || typeof val !== "object" || Array.isArray(val)) {
166166 return invalidValue(l(ref || "object"), val, key, parent);
167167 }
168- const result: any = {};
168+ const result: any = Object.create(null);
169169 Object.getOwnPropertyNames(props).forEach(key => {
170170 const prop = props[key];
171171 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -176,7 +176,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
176176 result[key] = transform(val[key], additional, getProps, key, ref);
177177 }
178178 });
179- return result;
179+ return Object.setPrototypeOf(result, Object.prototype);
180180 }
181181
182182 if (typ === "any") return val;
Test case

test/inputs/json/misc/33d2e.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -227,6 +227,14 @@ encodeCategory x = case x of
227227
228228 --- encoder helpers
229229
230+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
231+makeDictEncoder f m r =
232+ r
233+ |> Dict.toList
234+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
235+ |> String.join ","
236+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
237+
230238 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
231239 makeNullableEncoder f m =
232240 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -160,7 +160,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
160160 if (val === null || typeof val !== "object" || Array.isArray(val)) {
161161 return invalidValue(l(ref || "object"), val, key, parent);
162162 }
163- const result: any = {};
163+ const result: any = Object.create(null);
164164 Object.getOwnPropertyNames(props).forEach(key => {
165165 const prop = props[key];
166166 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -171,7 +171,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
171171 result[key] = transform(val[key], additional, getProps, key, ref);
172172 }
173173 });
174- return result;
174+ return Object.setPrototypeOf(result, Object.prototype);
175175 }
176176
177177 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -148,7 +148,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
148148 if (val === null || typeof val !== "object" || Array.isArray(val)) {
149149 return invalidValue(l(ref || "object"), val, key, parent);
150150 }
151- const result: any = {};
151+ const result: any = Object.create(null);
152152 Object.getOwnPropertyNames(props).forEach(key => {
153153 const prop = props[key];
154154 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -159,7 +159,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
159159 result[key] = transform(val[key], additional, getProps, key, ref);
160160 }
161161 });
162- return result;
162+ return Object.setPrototypeOf(result, Object.prototype);
163163 }
164164
165165 if (typ === "any") return val;
Test case

test/inputs/json/misc/34702.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -382,6 +382,14 @@ encodeRegion x = case x of
382382
383383 --- encoder helpers
384384
385+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
386+makeDictEncoder f m r =
387+ r
388+ |> Dict.toList
389+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
390+ |> String.join ","
391+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
392+
385393 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
386394 makeNullableEncoder f m =
387395 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -195,7 +195,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
195195 if (val === null || typeof val !== "object" || Array.isArray(val)) {
196196 return invalidValue(l(ref || "object"), val, key, parent);
197197 }
198- const result: any = {};
198+ const result: any = Object.create(null);
199199 Object.getOwnPropertyNames(props).forEach(key => {
200200 const prop = props[key];
201201 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -206,7 +206,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
206206 result[key] = transform(val[key], additional, getProps, key, ref);
207207 }
208208 });
209- return result;
209+ return Object.setPrototypeOf(result, Object.prototype);
210210 }
211211
212212 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -162,7 +162,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
162162 if (val === null || typeof val !== "object" || Array.isArray(val)) {
163163 return invalidValue(l(ref || "object"), val, key, parent);
164164 }
165- const result: any = {};
165+ const result: any = Object.create(null);
166166 Object.getOwnPropertyNames(props).forEach(key => {
167167 const prop = props[key];
168168 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -173,7 +173,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
173173 result[key] = transform(val[key], additional, getProps, key, ref);
174174 }
175175 });
176- return result;
176+ return Object.setPrototypeOf(result, Object.prototype);
177177 }
178178
179179 if (typ === "any") return val;
Test case

test/inputs/json/misc/3536b.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -183,6 +183,14 @@ encodeText x =
183183
184184 --- encoder helpers
185185
186+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
187+makeDictEncoder f m r =
188+ r
189+ |> Dict.toList
190+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
191+ |> String.join ","
192+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
193+
186194 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
187195 makeNullableEncoder f m =
188196 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 if (val === null || typeof val !== "object" || Array.isArray(val)) {
143143 return invalidValue(l(ref || "object"), val, key, parent);
144144 }
145- const result: any = {};
145+ const result: any = Object.create(null);
146146 Object.getOwnPropertyNames(props).forEach(key => {
147147 const prop = props[key];
148148 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -153,7 +153,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
153153 result[key] = transform(val[key], additional, getProps, key, ref);
154154 }
155155 });
156- return result;
156+ return Object.setPrototypeOf(result, Object.prototype);
157157 }
158158
159159 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 if (val === null || typeof val !== "object" || Array.isArray(val)) {
137137 return invalidValue(l(ref || "object"), val, key, parent);
138138 }
139- const result: any = {};
139+ const result: any = Object.create(null);
140140 Object.getOwnPropertyNames(props).forEach(key => {
141141 const prop = props[key];
142142 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 result[key] = transform(val[key], additional, getProps, key, ref);
148148 }
149149 });
150- return result;
150+ return Object.setPrototypeOf(result, Object.prototype);
151151 }
152152
153153 if (typ === "any") return val;
Test case

test/inputs/json/misc/3659d.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/36d5d.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/3a6b3.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/3e9a3.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -141,6 +141,14 @@ encodeFootnote x =
141141
142142 --- encoder helpers
143143
144+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
145+makeDictEncoder f m r =
146+ r
147+ |> Dict.toList
148+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
149+ |> String.join ","
150+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
151+
144152 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
145153 makeNullableEncoder f m =
146154 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 if (val === null || typeof val !== "object" || Array.isArray(val)) {
133133 return invalidValue(l(ref || "object"), val, key, parent);
134134 }
135- const result: any = {};
135+ const result: any = Object.create(null);
136136 Object.getOwnPropertyNames(props).forEach(key => {
137137 const prop = props[key];
138138 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -143,7 +143,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
143143 result[key] = transform(val[key], additional, getProps, key, ref);
144144 }
145145 });
146- return result;
146+ return Object.setPrototypeOf(result, Object.prototype);
147147 }
148148
149149 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 if (val === null || typeof val !== "object" || Array.isArray(val)) {
133133 return invalidValue(l(ref || "object"), val, key, parent);
134134 }
135- const result: any = {};
135+ const result: any = Object.create(null);
136136 Object.getOwnPropertyNames(props).forEach(key => {
137137 const prop = props[key];
138138 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -143,7 +143,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
143143 result[key] = transform(val[key], additional, getProps, key, ref);
144144 }
145145 });
146- return result;
146+ return Object.setPrototypeOf(result, Object.prototype);
147147 }
148148
149149 if (typ === "any") return val;
Test case

test/inputs/json/misc/3f1ce.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -413,6 +413,14 @@ encodeWind x =
413413
414414 --- encoder helpers
415415
416+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
417+makeDictEncoder f m r =
418+ r
419+ |> Dict.toList
420+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
421+ |> String.join ","
422+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
423+
416424 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
417425 makeNullableEncoder f m =
418426 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -208,7 +208,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
208208 if (val === null || typeof val !== "object" || Array.isArray(val)) {
209209 return invalidValue(l(ref || "object"), val, key, parent);
210210 }
211- const result: any = {};
211+ const result: any = Object.create(null);
212212 Object.getOwnPropertyNames(props).forEach(key => {
213213 const prop = props[key];
214214 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -219,7 +219,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
219219 result[key] = transform(val[key], additional, getProps, key, ref);
220220 }
221221 });
222- return result;
222+ return Object.setPrototypeOf(result, Object.prototype);
223223 }
224224
225225 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -207,7 +207,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
207207 if (val === null || typeof val !== "object" || Array.isArray(val)) {
208208 return invalidValue(l(ref || "object"), val, key, parent);
209209 }
210- const result: any = {};
210+ const result: any = Object.create(null);
211211 Object.getOwnPropertyNames(props).forEach(key => {
212212 const prop = props[key];
213213 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -218,7 +218,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
218218 result[key] = transform(val[key], additional, getProps, key, ref);
219219 }
220220 });
221- return result;
221+ return Object.setPrototypeOf(result, Object.prototype);
222222 }
223223
224224 if (typ === "any") return val;
Test case

test/inputs/json/misc/421d4.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -456,6 +456,14 @@ encodeOwner x =
456456
457457 --- encoder helpers
458458
459+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
460+makeDictEncoder f m r =
461+ r
462+ |> Dict.toList
463+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
464+ |> String.join ","
465+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
466+
459467 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
460468 makeNullableEncoder f m =
461469 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -221,7 +221,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
221221 if (val === null || typeof val !== "object" || Array.isArray(val)) {
222222 return invalidValue(l(ref || "object"), val, key, parent);
223223 }
224- const result: any = {};
224+ const result: any = Object.create(null);
225225 Object.getOwnPropertyNames(props).forEach(key => {
226226 const prop = props[key];
227227 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -232,7 +232,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
232232 result[key] = transform(val[key], additional, getProps, key, ref);
233233 }
234234 });
235- return result;
235+ return Object.setPrototypeOf(result, Object.prototype);
236236 }
237237
238238 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -218,7 +218,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
218218 if (val === null || typeof val !== "object" || Array.isArray(val)) {
219219 return invalidValue(l(ref || "object"), val, key, parent);
220220 }
221- const result: any = {};
221+ const result: any = Object.create(null);
222222 Object.getOwnPropertyNames(props).forEach(key => {
223223 const prop = props[key];
224224 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -229,7 +229,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
229229 result[key] = transform(val[key], additional, getProps, key, ref);
230230 }
231231 });
232- return result;
232+ return Object.setPrototypeOf(result, Object.prototype);
233233 }
234234
235235 if (typ === "any") return val;
Test case

test/inputs/json/misc/437e7.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -429,6 +429,14 @@ encodePagination x =
429429
430430 --- encoder helpers
431431
432+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
433+makeDictEncoder f m r =
434+ r
435+ |> Dict.toList
436+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
437+ |> String.join ","
438+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
439+
432440 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
433441 makeNullableEncoder f m =
434442 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 if (val === null || typeof val !== "object" || Array.isArray(val)) {
217217 return invalidValue(l(ref || "object"), val, key, parent);
218218 }
219- const result: any = {};
219+ const result: any = Object.create(null);
220220 Object.getOwnPropertyNames(props).forEach(key => {
221221 const prop = props[key];
222222 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -227,7 +227,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
227227 result[key] = transform(val[key], additional, getProps, key, ref);
228228 }
229229 });
230- return result;
230+ return Object.setPrototypeOf(result, Object.prototype);
231231 }
232232
233233 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -211,7 +211,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
211211 if (val === null || typeof val !== "object" || Array.isArray(val)) {
212212 return invalidValue(l(ref || "object"), val, key, parent);
213213 }
214- const result: any = {};
214+ const result: any = Object.create(null);
215215 Object.getOwnPropertyNames(props).forEach(key => {
216216 const prop = props[key];
217217 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -222,7 +222,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
222222 result[key] = transform(val[key], additional, getProps, key, ref);
223223 }
224224 });
225- return result;
225+ return Object.setPrototypeOf(result, Object.prototype);
226226 }
227227
228228 if (typ === "any") return val;
Test case

test/inputs/json/misc/43970.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -62,6 +62,14 @@ encodeQuickTypeElement x =
6262
6363 --- encoder helpers
6464
65+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
66+makeDictEncoder f m r =
67+ r
68+ |> Dict.toList
69+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
70+ |> String.join ","
71+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
72+
6573 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6674 makeNullableEncoder f m =
6775 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/misc/43eaf.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/458db.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -204,6 +204,14 @@ encodeName x = case x of
204204
205205 --- encoder helpers
206206
207+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
208+makeDictEncoder f m r =
209+ r
210+ |> Dict.toList
211+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
212+ |> String.join ","
213+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
214+
207215 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
208216 makeNullableEncoder f m =
209217 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -149,7 +149,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
149149 if (val === null || typeof val !== "object" || Array.isArray(val)) {
150150 return invalidValue(l(ref || "object"), val, key, parent);
151151 }
152- const result: any = {};
152+ const result: any = Object.create(null);
153153 Object.getOwnPropertyNames(props).forEach(key => {
154154 const prop = props[key];
155155 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -160,7 +160,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
160160 result[key] = transform(val[key], additional, getProps, key, ref);
161161 }
162162 });
163- return result;
163+ return Object.setPrototypeOf(result, Object.prototype);
164164 }
165165
166166 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -148,7 +148,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
148148 if (val === null || typeof val !== "object" || Array.isArray(val)) {
149149 return invalidValue(l(ref || "object"), val, key, parent);
150150 }
151- const result: any = {};
151+ const result: any = Object.create(null);
152152 Object.getOwnPropertyNames(props).forEach(key => {
153153 const prop = props[key];
154154 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -159,7 +159,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
159159 result[key] = transform(val[key], additional, getProps, key, ref);
160160 }
161161 });
162- return result;
162+ return Object.setPrototypeOf(result, Object.prototype);
163163 }
164164
165165 if (typ === "any") return val;
Test case

test/inputs/json/misc/4961a.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/4a0d7.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/4a455.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -223,6 +223,14 @@ encodeFeatureProperties x =
223223
224224 --- encoder helpers
225225
226+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
227+makeDictEncoder f m r =
228+ r
229+ |> Dict.toList
230+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
231+ |> String.join ","
232+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
233+
226234 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
227235 makeNullableEncoder f m =
228236 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -150,7 +150,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
150150 if (val === null || typeof val !== "object" || Array.isArray(val)) {
151151 return invalidValue(l(ref || "object"), val, key, parent);
152152 }
153- const result: any = {};
153+ const result: any = Object.create(null);
154154 Object.getOwnPropertyNames(props).forEach(key => {
155155 const prop = props[key];
156156 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -161,7 +161,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
161161 result[key] = transform(val[key], additional, getProps, key, ref);
162162 }
163163 });
164- return result;
164+ return Object.setPrototypeOf(result, Object.prototype);
165165 }
166166
167167 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 if (val === null || typeof val !== "object" || Array.isArray(val)) {
148148 return invalidValue(l(ref || "object"), val, key, parent);
149149 }
150- const result: any = {};
150+ const result: any = Object.create(null);
151151 Object.getOwnPropertyNames(props).forEach(key => {
152152 const prop = props[key];
153153 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -158,7 +158,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
158158 result[key] = transform(val[key], additional, getProps, key, ref);
159159 }
160160 });
161- return result;
161+ return Object.setPrototypeOf(result, Object.prototype);
162162 }
163163
164164 if (typ === "any") return val;
Test case

test/inputs/json/misc/4c547.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -396,6 +396,14 @@ encodeWind x =
396396
397397 --- encoder helpers
398398
399+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
400+makeDictEncoder f m r =
401+ r
402+ |> Dict.toList
403+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
404+ |> String.join ","
405+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
406+
399407 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
400408 makeNullableEncoder f m =
401409 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Test case

test/inputs/json/misc/4d6fb.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -584,6 +584,14 @@ encodeKind x = case x of
584584
585585 --- encoder helpers
586586
587+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
588+makeDictEncoder f m r =
589+ r
590+ |> Dict.toList
591+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
592+ |> String.join ","
593+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
594+
587595 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
588596 makeNullableEncoder f m =
589597 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -255,7 +255,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
255255 if (val === null || typeof val !== "object" || Array.isArray(val)) {
256256 return invalidValue(l(ref || "object"), val, key, parent);
257257 }
258- const result: any = {};
258+ const result: any = Object.create(null);
259259 Object.getOwnPropertyNames(props).forEach(key => {
260260 const prop = props[key];
261261 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -266,7 +266,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
266266 result[key] = transform(val[key], additional, getProps, key, ref);
267267 }
268268 });
269- return result;
269+ return Object.setPrototypeOf(result, Object.prototype);
270270 }
271271
272272 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -245,7 +245,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
245245 if (val === null || typeof val !== "object" || Array.isArray(val)) {
246246 return invalidValue(l(ref || "object"), val, key, parent);
247247 }
248- const result: any = {};
248+ const result: any = Object.create(null);
249249 Object.getOwnPropertyNames(props).forEach(key => {
250250 const prop = props[key];
251251 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -256,7 +256,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
256256 result[key] = transform(val[key], additional, getProps, key, ref);
257257 }
258258 });
259- return result;
259+ return Object.setPrototypeOf(result, Object.prototype);
260260 }
261261
262262 if (typ === "any") return val;
Test case

test/inputs/json/misc/4e336.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/54147.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -108,6 +108,14 @@ encodeHeaders x =
108108
109109 --- encoder helpers
110110
111+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
112+makeDictEncoder f m r =
113+ r
114+ |> Dict.toList
115+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
116+ |> String.join ","
117+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
118+
111119 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
112120 makeNullableEncoder f m =
113121 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 if (val === null || typeof val !== "object" || Array.isArray(val)) {
124124 return invalidValue(l(ref || "object"), val, key, parent);
125125 }
126- const result: any = {};
126+ const result: any = Object.create(null);
127127 Object.getOwnPropertyNames(props).forEach(key => {
128128 const prop = props[key];
129129 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -134,7 +134,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
134134 result[key] = transform(val[key], additional, getProps, key, ref);
135135 }
136136 });
137- return result;
137+ return Object.setPrototypeOf(result, Object.prototype);
138138 }
139139
140140 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Test case

test/inputs/json/misc/54d32.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -134,6 +134,14 @@ encodeStatus x = case x of
134134
135135 --- encoder helpers
136136
137+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
138+makeDictEncoder f m r =
139+ r
140+ |> Dict.toList
141+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
142+ |> String.join ","
143+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
144+
137145 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
138146 makeNullableEncoder f m =
139147 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -129,7 +129,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
129129 if (val === null || typeof val !== "object" || Array.isArray(val)) {
130130 return invalidValue(l(ref || "object"), val, key, parent);
131131 }
132- const result: any = {};
132+ const result: any = Object.create(null);
133133 Object.getOwnPropertyNames(props).forEach(key => {
134134 const prop = props[key];
135135 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 result[key] = transform(val[key], additional, getProps, key, ref);
141141 }
142142 });
143- return result;
143+ return Object.setPrototypeOf(result, Object.prototype);
144144 }
145145
146146 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 if (val === null || typeof val !== "object" || Array.isArray(val)) {
125125 return invalidValue(l(ref || "object"), val, key, parent);
126126 }
127- const result: any = {};
127+ const result: any = Object.create(null);
128128 Object.getOwnPropertyNames(props).forEach(key => {
129129 const prop = props[key];
130130 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 result[key] = transform(val[key], additional, getProps, key, ref);
136136 }
137137 });
138- return result;
138+ return Object.setPrototypeOf(result, Object.prototype);
139139 }
140140
141141 if (typ === "any") return val;
Test case

test/inputs/json/misc/570ec.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -179,6 +179,14 @@ encodeText x =
179179
180180 --- encoder helpers
181181
182+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
183+makeDictEncoder f m r =
184+ r
185+ |> Dict.toList
186+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
187+ |> String.join ","
188+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
189+
182190 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
183191 makeNullableEncoder f m =
184192 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 if (val === null || typeof val !== "object" || Array.isArray(val)) {
143143 return invalidValue(l(ref || "object"), val, key, parent);
144144 }
145- const result: any = {};
145+ const result: any = Object.create(null);
146146 Object.getOwnPropertyNames(props).forEach(key => {
147147 const prop = props[key];
148148 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -153,7 +153,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
153153 result[key] = transform(val[key], additional, getProps, key, ref);
154154 }
155155 });
156- return result;
156+ return Object.setPrototypeOf(result, Object.prototype);
157157 }
158158
159159 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -139,7 +139,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
139139 if (val === null || typeof val !== "object" || Array.isArray(val)) {
140140 return invalidValue(l(ref || "object"), val, key, parent);
141141 }
142- const result: any = {};
142+ const result: any = Object.create(null);
143143 Object.getOwnPropertyNames(props).forEach(key => {
144144 const prop = props[key];
145145 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -150,7 +150,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
150150 result[key] = transform(val[key], additional, getProps, key, ref);
151151 }
152152 });
153- return result;
153+ return Object.setPrototypeOf(result, Object.prototype);
154154 }
155155
156156 if (typ === "any") return val;
Test case

test/inputs/json/misc/5dd0d.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/5eae5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -65,6 +65,14 @@ encodeQuickTypeElement x =
6565
6666 --- encoder helpers
6767
68+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
69+makeDictEncoder f m r =
70+ r
71+ |> Dict.toList
72+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
73+ |> String.join ","
74+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
75+
6876 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6977 makeNullableEncoder f m =
7078 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/5eb20.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/5f3a1.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/5f7fe.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -728,6 +728,14 @@ encodeExpression x =
728728
729729 --- encoder helpers
730730
731+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
732+makeDictEncoder f m r =
733+ r
734+ |> Dict.toList
735+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
736+ |> String.join ","
737+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
738+
731739 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
732740 makeNullableEncoder f m =
733741 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -295,7 +295,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
295295 if (val === null || typeof val !== "object" || Array.isArray(val)) {
296296 return invalidValue(l(ref || "object"), val, key, parent);
297297 }
298- const result: any = {};
298+ const result: any = Object.create(null);
299299 Object.getOwnPropertyNames(props).forEach(key => {
300300 const prop = props[key];
301301 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -306,7 +306,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
306306 result[key] = transform(val[key], additional, getProps, key, ref);
307307 }
308308 });
309- return result;
309+ return Object.setPrototypeOf(result, Object.prototype);
310310 }
311311
312312 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -292,7 +292,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
292292 if (val === null || typeof val !== "object" || Array.isArray(val)) {
293293 return invalidValue(l(ref || "object"), val, key, parent);
294294 }
295- const result: any = {};
295+ const result: any = Object.create(null);
296296 Object.getOwnPropertyNames(props).forEach(key => {
297297 const prop = props[key];
298298 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -303,7 +303,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
303303 result[key] = transform(val[key], additional, getProps, key, ref);
304304 }
305305 });
306- return result;
306+ return Object.setPrototypeOf(result, Object.prototype);
307307 }
308308
309309 if (typ === "any") return val;
Test case

test/inputs/json/misc/617e8.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -725,6 +725,14 @@ encodeExpression x =
725725
726726 --- encoder helpers
727727
728+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
729+makeDictEncoder f m r =
730+ r
731+ |> Dict.toList
732+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
733+ |> String.join ","
734+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
735+
728736 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
729737 makeNullableEncoder f m =
730738 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -294,7 +294,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
294294 if (val === null || typeof val !== "object" || Array.isArray(val)) {
295295 return invalidValue(l(ref || "object"), val, key, parent);
296296 }
297- const result: any = {};
297+ const result: any = Object.create(null);
298298 Object.getOwnPropertyNames(props).forEach(key => {
299299 const prop = props[key];
300300 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -305,7 +305,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
305305 result[key] = transform(val[key], additional, getProps, key, ref);
306306 }
307307 });
308- return result;
308+ return Object.setPrototypeOf(result, Object.prototype);
309309 }
310310
311311 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -291,7 +291,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
291291 if (val === null || typeof val !== "object" || Array.isArray(val)) {
292292 return invalidValue(l(ref || "object"), val, key, parent);
293293 }
294- const result: any = {};
294+ const result: any = Object.create(null);
295295 Object.getOwnPropertyNames(props).forEach(key => {
296296 const prop = props[key];
297297 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -302,7 +302,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
302302 result[key] = transform(val[key], additional, getProps, key, ref);
303303 }
304304 });
305- return result;
305+ return Object.setPrototypeOf(result, Object.prototype);
306306 }
307307
308308 if (typ === "any") return val;
Test case

test/inputs/json/misc/61b66.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/6260a.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/65dec.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -371,6 +371,14 @@ encodeType x = case x of
371371
372372 --- encoder helpers
373373
374+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
375+makeDictEncoder f m r =
376+ r
377+ |> Dict.toList
378+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
379+ |> String.join ","
380+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
381+
374382 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
375383 makeNullableEncoder f m =
376384 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -194,7 +194,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
194194 if (val === null || typeof val !== "object" || Array.isArray(val)) {
195195 return invalidValue(l(ref || "object"), val, key, parent);
196196 }
197- const result: any = {};
197+ const result: any = Object.create(null);
198198 Object.getOwnPropertyNames(props).forEach(key => {
199199 const prop = props[key];
200200 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 result[key] = transform(val[key], additional, getProps, key, ref);
206206 }
207207 });
208- return result;
208+ return Object.setPrototypeOf(result, Object.prototype);
209209 }
210210
211211 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -170,7 +170,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
170170 if (val === null || typeof val !== "object" || Array.isArray(val)) {
171171 return invalidValue(l(ref || "object"), val, key, parent);
172172 }
173- const result: any = {};
173+ const result: any = Object.create(null);
174174 Object.getOwnPropertyNames(props).forEach(key => {
175175 const prop = props[key];
176176 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -181,7 +181,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
181181 result[key] = transform(val[key], additional, getProps, key, ref);
182182 }
183183 });
184- return result;
184+ return Object.setPrototypeOf(result, Object.prototype);
185185 }
186186
187187 if (typ === "any") return val;
Test case

test/inputs/json/misc/66121.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -234,6 +234,14 @@ encodeTitle x = case x of
234234
235235 --- encoder helpers
236236
237+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
238+makeDictEncoder f m r =
239+ r
240+ |> Dict.toList
241+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
242+ |> String.join ","
243+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
244+
237245 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
238246 makeNullableEncoder f m =
239247 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 if (val === null || typeof val !== "object" || Array.isArray(val)) {
152152 return invalidValue(l(ref || "object"), val, key, parent);
153153 }
154- const result: any = {};
154+ const result: any = Object.create(null);
155155 Object.getOwnPropertyNames(props).forEach(key => {
156156 const prop = props[key];
157157 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -162,7 +162,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
162162 result[key] = transform(val[key], additional, getProps, key, ref);
163163 }
164164 });
165- return result;
165+ return Object.setPrototypeOf(result, Object.prototype);
166166 }
167167
168168 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 if (val === null || typeof val !== "object" || Array.isArray(val)) {
143143 return invalidValue(l(ref || "object"), val, key, parent);
144144 }
145- const result: any = {};
145+ const result: any = Object.create(null);
146146 Object.getOwnPropertyNames(props).forEach(key => {
147147 const prop = props[key];
148148 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -153,7 +153,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
153153 result[key] = transform(val[key], additional, getProps, key, ref);
154154 }
155155 });
156- return result;
156+ return Object.setPrototypeOf(result, Object.prototype);
157157 }
158158
159159 if (typ === "any") return val;
Test case

test/inputs/json/misc/6617c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -75,6 +75,14 @@ encodeIssPosition x =
7575
7676 --- encoder helpers
7777
78+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
79+makeDictEncoder f m r =
80+ r
81+ |> Dict.toList
82+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
83+ |> String.join ","
84+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
85+
7886 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7987 makeNullableEncoder f m =
8088 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/json/misc/67c03.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -75,6 +75,14 @@ encodePerson x =
7575
7676 --- encoder helpers
7777
78+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
79+makeDictEncoder f m r =
80+ r
81+ |> Dict.toList
82+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
83+ |> String.join ","
84+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
85+
7886 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7987 makeNullableEncoder f m =
8088 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/json/misc/68c30.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -155,6 +155,14 @@ encodeOut x =
155155
156156 --- encoder helpers
157157
158+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
159+makeDictEncoder f m r =
160+ r
161+ |> Dict.toList
162+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
163+ |> String.join ","
164+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
165+
158166 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
159167 makeNullableEncoder f m =
160168 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -138,7 +138,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
138138 if (val === null || typeof val !== "object" || Array.isArray(val)) {
139139 return invalidValue(l(ref || "object"), val, key, parent);
140140 }
141- const result: any = {};
141+ const result: any = Object.create(null);
142142 Object.getOwnPropertyNames(props).forEach(key => {
143143 const prop = props[key];
144144 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -149,7 +149,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
149149 result[key] = transform(val[key], additional, getProps, key, ref);
150150 }
151151 });
152- return result;
152+ return Object.setPrototypeOf(result, Object.prototype);
153153 }
154154
155155 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -138,7 +138,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
138138 if (val === null || typeof val !== "object" || Array.isArray(val)) {
139139 return invalidValue(l(ref || "object"), val, key, parent);
140140 }
141- const result: any = {};
141+ const result: any = Object.create(null);
142142 Object.getOwnPropertyNames(props).forEach(key => {
143143 const prop = props[key];
144144 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -149,7 +149,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
149149 result[key] = transform(val[key], additional, getProps, key, ref);
150150 }
151151 });
152- return result;
152+ return Object.setPrototypeOf(result, Object.prototype);
153153 }
154154
155155 if (typ === "any") return val;
Test case

test/inputs/json/misc/6c155.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -233,6 +233,14 @@ encodeLocation x =
233233
234234 --- encoder helpers
235235
236+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
237+makeDictEncoder f m r =
238+ r
239+ |> Dict.toList
240+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
241+ |> String.join ","
242+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
243+
236244 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
237245 makeNullableEncoder f m =
238246 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -160,7 +160,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
160160 if (val === null || typeof val !== "object" || Array.isArray(val)) {
161161 return invalidValue(l(ref || "object"), val, key, parent);
162162 }
163- const result: any = {};
163+ const result: any = Object.create(null);
164164 Object.getOwnPropertyNames(props).forEach(key => {
165165 const prop = props[key];
166166 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -171,7 +171,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
171171 result[key] = transform(val[key], additional, getProps, key, ref);
172172 }
173173 });
174- return result;
174+ return Object.setPrototypeOf(result, Object.prototype);
175175 }
176176
177177 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -160,7 +160,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
160160 if (val === null || typeof val !== "object" || Array.isArray(val)) {
161161 return invalidValue(l(ref || "object"), val, key, parent);
162162 }
163- const result: any = {};
163+ const result: any = Object.create(null);
164164 Object.getOwnPropertyNames(props).forEach(key => {
165165 const prop = props[key];
166166 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -171,7 +171,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
171171 result[key] = transform(val[key], additional, getProps, key, ref);
172172 }
173173 });
174- return result;
174+ return Object.setPrototypeOf(result, Object.prototype);
175175 }
176176
177177 if (typ === "any") return val;
Test case

test/inputs/json/misc/6de06.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -562,6 +562,14 @@ encodeKind x = case x of
562562
563563 --- encoder helpers
564564
565+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
566+makeDictEncoder f m r =
567+ r
568+ |> Dict.toList
569+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
570+ |> String.join ","
571+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
572+
565573 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
566574 makeNullableEncoder f m =
567575 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -255,7 +255,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
255255 if (val === null || typeof val !== "object" || Array.isArray(val)) {
256256 return invalidValue(l(ref || "object"), val, key, parent);
257257 }
258- const result: any = {};
258+ const result: any = Object.create(null);
259259 Object.getOwnPropertyNames(props).forEach(key => {
260260 const prop = props[key];
261261 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -266,7 +266,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
266266 result[key] = transform(val[key], additional, getProps, key, ref);
267267 }
268268 });
269- return result;
269+ return Object.setPrototypeOf(result, Object.prototype);
270270 }
271271
272272 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -250,7 +250,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
250250 if (val === null || typeof val !== "object" || Array.isArray(val)) {
251251 return invalidValue(l(ref || "object"), val, key, parent);
252252 }
253- const result: any = {};
253+ const result: any = Object.create(null);
254254 Object.getOwnPropertyNames(props).forEach(key => {
255255 const prop = props[key];
256256 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -261,7 +261,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
261261 result[key] = transform(val[key], additional, getProps, key, ref);
262262 }
263263 });
264- return result;
264+ return Object.setPrototypeOf(result, Object.prototype);
265265 }
266266
267267 if (typ === "any") return val;
Test case

test/inputs/json/misc/6dec6.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -419,6 +419,14 @@ encodeWind x =
419419
420420 --- encoder helpers
421421
422+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
423+makeDictEncoder f m r =
424+ r
425+ |> Dict.toList
426+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
427+ |> String.join ","
428+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
429+
422430 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
423431 makeNullableEncoder f m =
424432 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -210,7 +210,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
210210 if (val === null || typeof val !== "object" || Array.isArray(val)) {
211211 return invalidValue(l(ref || "object"), val, key, parent);
212212 }
213- const result: any = {};
213+ const result: any = Object.create(null);
214214 Object.getOwnPropertyNames(props).forEach(key => {
215215 const prop = props[key];
216216 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -221,7 +221,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
221221 result[key] = transform(val[key], additional, getProps, key, ref);
222222 }
223223 });
224- return result;
224+ return Object.setPrototypeOf(result, Object.prototype);
225225 }
226226
227227 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -207,7 +207,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
207207 if (val === null || typeof val !== "object" || Array.isArray(val)) {
208208 return invalidValue(l(ref || "object"), val, key, parent);
209209 }
210- const result: any = {};
210+ const result: any = Object.create(null);
211211 Object.getOwnPropertyNames(props).forEach(key => {
212212 const prop = props[key];
213213 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -218,7 +218,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
218218 result[key] = transform(val[key], additional, getProps, key, ref);
219219 }
220220 });
221- return result;
221+ return Object.setPrototypeOf(result, Object.prototype);
222222 }
223223
224224 if (typ === "any") return val;
Test case

test/inputs/json/misc/6eb00.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -62,6 +62,14 @@ encodeQuickTypeElement x =
6262
6363 --- encoder helpers
6464
65+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
66+makeDictEncoder f m r =
67+ r
68+ |> Dict.toList
69+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
70+ |> String.join ","
71+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
72+
6573 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6674 makeNullableEncoder f m =
6775 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/misc/70c77.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/734ad.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -290,6 +290,14 @@ encodeStatus x = case x of
290290
291291 --- encoder helpers
292292
293+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
294+makeDictEncoder f m r =
295+ r
296+ |> Dict.toList
297+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
298+ |> String.join ","
299+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
300+
293301 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
294302 makeNullableEncoder f m =
295303 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -181,7 +181,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
181181 if (val === null || typeof val !== "object" || Array.isArray(val)) {
182182 return invalidValue(l(ref || "object"), val, key, parent);
183183 }
184- const result: any = {};
184+ const result: any = Object.create(null);
185185 Object.getOwnPropertyNames(props).forEach(key => {
186186 const prop = props[key];
187187 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -192,7 +192,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
192192 result[key] = transform(val[key], additional, getProps, key, ref);
193193 }
194194 });
195- return result;
195+ return Object.setPrototypeOf(result, Object.prototype);
196196 }
197197
198198 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -176,7 +176,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
176176 if (val === null || typeof val !== "object" || Array.isArray(val)) {
177177 return invalidValue(l(ref || "object"), val, key, parent);
178178 }
179- const result: any = {};
179+ const result: any = Object.create(null);
180180 Object.getOwnPropertyNames(props).forEach(key => {
181181 const prop = props[key];
182182 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -187,7 +187,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
187187 result[key] = transform(val[key], additional, getProps, key, ref);
188188 }
189189 });
190- return result;
190+ return Object.setPrototypeOf(result, Object.prototype);
191191 }
192192
193193 if (typ === "any") return val;
Test case

test/inputs/json/misc/75912.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/7681c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -458,6 +458,14 @@ encodePagination x =
458458
459459 --- encoder helpers
460460
461+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
462+makeDictEncoder f m r =
463+ r
464+ |> Dict.toList
465+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
466+ |> String.join ","
467+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
468+
461469 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
462470 makeNullableEncoder f m =
463471 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -223,7 +223,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
223223 if (val === null || typeof val !== "object" || Array.isArray(val)) {
224224 return invalidValue(l(ref || "object"), val, key, parent);
225225 }
226- const result: any = {};
226+ const result: any = Object.create(null);
227227 Object.getOwnPropertyNames(props).forEach(key => {
228228 const prop = props[key];
229229 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -234,7 +234,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
234234 result[key] = transform(val[key], additional, getProps, key, ref);
235235 }
236236 });
237- return result;
237+ return Object.setPrototypeOf(result, Object.prototype);
238238 }
239239
240240 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -215,7 +215,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
215215 if (val === null || typeof val !== "object" || Array.isArray(val)) {
216216 return invalidValue(l(ref || "object"), val, key, parent);
217217 }
218- const result: any = {};
218+ const result: any = Object.create(null);
219219 Object.getOwnPropertyNames(props).forEach(key => {
220220 const prop = props[key];
221221 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -226,7 +226,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
226226 result[key] = transform(val[key], additional, getProps, key, ref);
227227 }
228228 });
229- return result;
229+ return Object.setPrototypeOf(result, Object.prototype);
230230 }
231231
232232 if (typ === "any") return val;
Test case

test/inputs/json/misc/76ae1.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -316,7 +316,7 @@ article =
316316 encodeArticle : Article -> Jenc.Value
317317 encodeArticle x =
318318 Jenc.object
319- [ ("properties", Jenc.dict identity encodeProperty x.properties)
319+ [ ("properties", makeDictEncoder identity encodeProperty x.properties)
320320 ]
321321
322322 property : Jdec.Decoder Property
@@ -722,6 +722,14 @@ encodeSchemaType x = case x of
722722
723723 --- encoder helpers
724724
725+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
726+makeDictEncoder f m r =
727+ r
728+ |> Dict.toList
729+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
730+ |> String.join ","
731+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
732+
725733 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
726734 makeNullableEncoder f m =
727735 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -291,7 +291,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
291291 if (val === null || typeof val !== "object" || Array.isArray(val)) {
292292 return invalidValue(l(ref || "object"), val, key, parent);
293293 }
294- const result: any = {};
294+ const result: any = Object.create(null);
295295 Object.getOwnPropertyNames(props).forEach(key => {
296296 const prop = props[key];
297297 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -302,7 +302,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
302302 result[key] = transform(val[key], additional, getProps, key, ref);
303303 }
304304 });
305- return result;
305+ return Object.setPrototypeOf(result, Object.prototype);
306306 }
307307
308308 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -288,7 +288,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
288288 if (val === null || typeof val !== "object" || Array.isArray(val)) {
289289 return invalidValue(l(ref || "object"), val, key, parent);
290290 }
291- const result: any = {};
291+ const result: any = Object.create(null);
292292 Object.getOwnPropertyNames(props).forEach(key => {
293293 const prop = props[key];
294294 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -299,7 +299,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
299299 result[key] = transform(val[key], additional, getProps, key, ref);
300300 }
301301 });
302- return result;
302+ return Object.setPrototypeOf(result, Object.prototype);
303303 }
304304
305305 if (typ === "any") return val;
Test case

test/inputs/json/misc/77392.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -147,6 +147,14 @@ encodePha x = case x of
147147
148148 --- encoder helpers
149149
150+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
151+makeDictEncoder f m r =
152+ r
153+ |> Dict.toList
154+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
155+ |> String.join ","
156+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
157+
150158 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
151159 makeNullableEncoder f m =
152160 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -134,7 +134,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
134134 if (val === null || typeof val !== "object" || Array.isArray(val)) {
135135 return invalidValue(l(ref || "object"), val, key, parent);
136136 }
137- const result: any = {};
137+ const result: any = Object.create(null);
138138 Object.getOwnPropertyNames(props).forEach(key => {
139139 const prop = props[key];
140140 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -145,7 +145,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
145145 result[key] = transform(val[key], additional, getProps, key, ref);
146146 }
147147 });
148- return result;
148+ return Object.setPrototypeOf(result, Object.prototype);
149149 }
150150
151151 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 if (val === null || typeof val !== "object" || Array.isArray(val)) {
123123 return invalidValue(l(ref || "object"), val, key, parent);
124124 }
125- const result: any = {};
125+ const result: any = Object.create(null);
126126 Object.getOwnPropertyNames(props).forEach(key => {
127127 const prop = props[key];
128128 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -133,7 +133,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
133133 result[key] = transform(val[key], additional, getProps, key, ref);
134134 }
135135 });
136- return result;
136+ return Object.setPrototypeOf(result, Object.prototype);
137137 }
138138
139139 if (typ === "any") return val;
Test case

test/inputs/json/misc/7d397.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -170,7 +170,7 @@ listClass =
170170 encodeListClass : ListClass -> Jenc.Value
171171 encodeListClass x =
172172 Jenc.object
173- [ ("properties", Jenc.dict identity encodeProperty x.properties)
173+ [ ("properties", makeDictEncoder identity encodeProperty x.properties)
174174 ]
175175
176176 property : Jdec.Decoder Property
@@ -339,6 +339,14 @@ encodeItems x =
339339
340340 --- encoder helpers
341341
342+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
343+makeDictEncoder f m r =
344+ r
345+ |> Dict.toList
346+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
347+ |> String.join ","
348+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
349+
342350 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
343351 makeNullableEncoder f m =
344352 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -182,7 +182,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
182182 if (val === null || typeof val !== "object" || Array.isArray(val)) {
183183 return invalidValue(l(ref || "object"), val, key, parent);
184184 }
185- const result: any = {};
185+ const result: any = Object.create(null);
186186 Object.getOwnPropertyNames(props).forEach(key => {
187187 const prop = props[key];
188188 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -193,7 +193,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
193193 result[key] = transform(val[key], additional, getProps, key, ref);
194194 }
195195 });
196- return result;
196+ return Object.setPrototypeOf(result, Object.prototype);
197197 }
198198
199199 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -180,7 +180,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
180180 if (val === null || typeof val !== "object" || Array.isArray(val)) {
181181 return invalidValue(l(ref || "object"), val, key, parent);
182182 }
183- const result: any = {};
183+ const result: any = Object.create(null);
184184 Object.getOwnPropertyNames(props).forEach(key => {
185185 const prop = props[key];
186186 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -191,7 +191,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
191191 result[key] = transform(val[key], additional, getProps, key, ref);
192192 }
193193 });
194- return result;
194+ return Object.setPrototypeOf(result, Object.prototype);
195195 }
196196
197197 if (typ === "any") return val;
Test case

test/inputs/json/misc/7d722.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/7df41.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -84,6 +84,14 @@ encodePC x =
8484
8585 --- encoder helpers
8686
87+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
88+makeDictEncoder f m r =
89+ r
90+ |> Dict.toList
91+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
92+ |> String.join ","
93+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
94+
8795 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8896 makeNullableEncoder f m =
8997 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Test case

test/inputs/json/misc/7dfa6.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/7eb30.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -230,6 +230,14 @@ encodeTelEnum x = case x of
230230
231231 --- encoder helpers
232232
233+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
234+makeDictEncoder f m r =
235+ r
236+ |> Dict.toList
237+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
238+ |> String.join ","
239+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
240+
233241 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
234242 makeNullableEncoder f m =
235243 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 if (val === null || typeof val !== "object" || Array.isArray(val)) {
152152 return invalidValue(l(ref || "object"), val, key, parent);
153153 }
154- const result: any = {};
154+ const result: any = Object.create(null);
155155 Object.getOwnPropertyNames(props).forEach(key => {
156156 const prop = props[key];
157157 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -162,7 +162,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
162162 result[key] = transform(val[key], additional, getProps, key, ref);
163163 }
164164 });
165- return result;
165+ return Object.setPrototypeOf(result, Object.prototype);
166166 }
167167
168168 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -144,7 +144,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
144144 if (val === null || typeof val !== "object" || Array.isArray(val)) {
145145 return invalidValue(l(ref || "object"), val, key, parent);
146146 }
147- const result: any = {};
147+ const result: any = Object.create(null);
148148 Object.getOwnPropertyNames(props).forEach(key => {
149149 const prop = props[key];
150150 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -155,7 +155,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
155155 result[key] = transform(val[key], additional, getProps, key, ref);
156156 }
157157 });
158- return result;
158+ return Object.setPrototypeOf(result, Object.prototype);
159159 }
160160
161161 if (typ === "any") return val;
Test case

test/inputs/json/misc/7f568.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -103,7 +103,7 @@ encodeQuickTypeElement x =
103103 , ("commits_url", Jenc.string x.commitsURL)
104104 , ("created_at", Jenc.string x.createdAt)
105105 , ("description", makeNullableEncoder Jenc.string x.description)
106- , ("files", Jenc.dict identity encodeFile x.files)
106+ , ("files", makeDictEncoder identity encodeFile x.files)
107107 , ("forks_url", Jenc.string x.forksURL)
108108 , ("git_pull_url", Jenc.string x.gitPullURL)
109109 , ("git_push_url", Jenc.string x.gitPushURL)
@@ -163,6 +163,14 @@ encodeLanguage x = case x of
163163
164164 --- encoder helpers
165165
166+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
167+makeDictEncoder f m r =
168+ r
169+ |> Dict.toList
170+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
171+ |> String.join ","
172+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
173+
166174 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
167175 makeNullableEncoder f m =
168176 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -138,7 +138,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
138138 if (val === null || typeof val !== "object" || Array.isArray(val)) {
139139 return invalidValue(l(ref || "object"), val, key, parent);
140140 }
141- const result: any = {};
141+ const result: any = Object.create(null);
142142 Object.getOwnPropertyNames(props).forEach(key => {
143143 const prop = props[key];
144144 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -149,7 +149,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
149149 result[key] = transform(val[key], additional, getProps, key, ref);
150150 }
151151 });
152- return result;
152+ return Object.setPrototypeOf(result, Object.prototype);
153153 }
154154
155155 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 if (val === null || typeof val !== "object" || Array.isArray(val)) {
137137 return invalidValue(l(ref || "object"), val, key, parent);
138138 }
139- const result: any = {};
139+ const result: any = Object.create(null);
140140 Object.getOwnPropertyNames(props).forEach(key => {
141141 const prop = props[key];
142142 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 result[key] = transform(val[key], additional, getProps, key, ref);
148148 }
149149 });
150- return result;
150+ return Object.setPrototypeOf(result, Object.prototype);
151151 }
152152
153153 if (typ === "any") return val;
Test case

test/inputs/json/misc/7fbfb.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -169,6 +169,14 @@ encodeFluffyQuickType x =
169169
170170 --- encoder helpers
171171
172+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
173+makeDictEncoder f m r =
174+ r
175+ |> Dict.toList
176+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
177+ |> String.join ","
178+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
179+
172180 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
173181 makeNullableEncoder f m =
174182 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 if (val === null || typeof val !== "object" || Array.isArray(val)) {
136136 return invalidValue(l(ref || "object"), val, key, parent);
137137 }
138- const result: any = {};
138+ const result: any = Object.create(null);
139139 Object.getOwnPropertyNames(props).forEach(key => {
140140 const prop = props[key];
141141 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 result[key] = transform(val[key], additional, getProps, key, ref);
147147 }
148148 });
149- return result;
149+ return Object.setPrototypeOf(result, Object.prototype);
150150 }
151151
152152 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 if (val === null || typeof val !== "object" || Array.isArray(val)) {
132132 return invalidValue(l(ref || "object"), val, key, parent);
133133 }
134- const result: any = {};
134+ const result: any = Object.create(null);
135135 Object.getOwnPropertyNames(props).forEach(key => {
136136 const prop = props[key];
137137 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 result[key] = transform(val[key], additional, getProps, key, ref);
143143 }
144144 });
145- return result;
145+ return Object.setPrototypeOf(result, Object.prototype);
146146 }
147147
148148 if (typ === "any") return val;
Test case

test/inputs/json/misc/80aff.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -117,6 +117,14 @@ encodeResult x =
117117
118118 --- encoder helpers
119119
120+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
121+makeDictEncoder f m r =
122+ r
123+ |> Dict.toList
124+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
125+ |> String.join ","
126+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
127+
120128 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
121129 makeNullableEncoder f m =
122130 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 if (val === null || typeof val !== "object" || Array.isArray(val)) {
127127 return invalidValue(l(ref || "object"), val, key, parent);
128128 }
129- const result: any = {};
129+ const result: any = Object.create(null);
130130 Object.getOwnPropertyNames(props).forEach(key => {
131131 const prop = props[key];
132132 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -137,7 +137,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
137137 result[key] = transform(val[key], additional, getProps, key, ref);
138138 }
139139 });
140- return result;
140+ return Object.setPrototypeOf(result, Object.prototype);
141141 }
142142
143143 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 if (val === null || typeof val !== "object" || Array.isArray(val)) {
124124 return invalidValue(l(ref || "object"), val, key, parent);
125125 }
126- const result: any = {};
126+ const result: any = Object.create(null);
127127 Object.getOwnPropertyNames(props).forEach(key => {
128128 const prop = props[key];
129129 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -134,7 +134,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
134134 result[key] = transform(val[key], additional, getProps, key, ref);
135135 }
136136 });
137- return result;
137+ return Object.setPrototypeOf(result, Object.prototype);
138138 }
139139
140140 if (typ === "any") return val;
Test case

test/inputs/json/misc/82509.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Test case

test/inputs/json/misc/8592b.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -505,6 +505,14 @@ encodeKind x = case x of
505505
506506 --- encoder helpers
507507
508+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
509+makeDictEncoder f m r =
510+ r
511+ |> Dict.toList
512+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
513+ |> String.join ","
514+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
515+
508516 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
509517 makeNullableEncoder f m =
510518 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -230,7 +230,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
230230 if (val === null || typeof val !== "object" || Array.isArray(val)) {
231231 return invalidValue(l(ref || "object"), val, key, parent);
232232 }
233- const result: any = {};
233+ const result: any = Object.create(null);
234234 Object.getOwnPropertyNames(props).forEach(key => {
235235 const prop = props[key];
236236 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -241,7 +241,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
241241 result[key] = transform(val[key], additional, getProps, key, ref);
242242 }
243243 });
244- return result;
244+ return Object.setPrototypeOf(result, Object.prototype);
245245 }
246246
247247 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -219,7 +219,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
219219 if (val === null || typeof val !== "object" || Array.isArray(val)) {
220220 return invalidValue(l(ref || "object"), val, key, parent);
221221 }
222- const result: any = {};
222+ const result: any = Object.create(null);
223223 Object.getOwnPropertyNames(props).forEach(key => {
224224 const prop = props[key];
225225 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -230,7 +230,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
230230 result[key] = transform(val[key], additional, getProps, key, ref);
231231 }
232232 });
233- return result;
233+ return Object.setPrototypeOf(result, Object.prototype);
234234 }
235235
236236 if (typ === "any") return val;
Test case

test/inputs/json/misc/88130.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -396,6 +396,14 @@ encodeWind x =
396396
397397 --- encoder helpers
398398
399+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
400+makeDictEncoder f m r =
401+ r
402+ |> Dict.toList
403+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
404+ |> String.join ","
405+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
406+
399407 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
400408 makeNullableEncoder f m =
401409 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Test case

test/inputs/json/misc/8a62c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/908db.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -85,6 +85,14 @@ encodeStateState x =
8585
8686 --- encoder helpers
8787
88+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
89+makeDictEncoder f m r =
90+ r
91+ |> Dict.toList
92+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
93+ |> String.join ","
94+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
95+
8896 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8997 makeNullableEncoder f m =
9098 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/json/misc/9617f.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/96f7c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -65,6 +65,14 @@ encodeQuickType x =
6565
6666 --- encoder helpers
6767
68+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
69+makeDictEncoder f m r =
70+ r
71+ |> Dict.toList
72+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
73+ |> String.join ","
74+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
75+
6876 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6977 makeNullableEncoder f m =
7078 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/9847b.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -59,6 +59,14 @@ encodeQuickTypeElement x =
5959
6060 --- encoder helpers
6161
62+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
63+makeDictEncoder f m r =
64+ r
65+ |> Dict.toList
66+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
67+ |> String.join ","
68+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
69+
6270 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6371 makeNullableEncoder f m =
6472 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/json/misc/9929c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -396,6 +396,14 @@ encodeWind x =
396396
397397 --- encoder helpers
398398
399+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
400+makeDictEncoder f m r =
401+ r
402+ |> Dict.toList
403+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
404+ |> String.join ","
405+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
406+
399407 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
400408 makeNullableEncoder f m =
401409 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Test case

test/inputs/json/misc/996bd.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -226,6 +226,14 @@ encodeTitle x = case x of
226226
227227 --- encoder helpers
228228
229+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
230+makeDictEncoder f m r =
231+ r
232+ |> Dict.toList
233+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
234+ |> String.join ","
235+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
236+
229237 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
230238 makeNullableEncoder f m =
231239 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 if (val === null || typeof val !== "object" || Array.isArray(val)) {
152152 return invalidValue(l(ref || "object"), val, key, parent);
153153 }
154- const result: any = {};
154+ const result: any = Object.create(null);
155155 Object.getOwnPropertyNames(props).forEach(key => {
156156 const prop = props[key];
157157 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -162,7 +162,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
162162 result[key] = transform(val[key], additional, getProps, key, ref);
163163 }
164164 });
165- return result;
165+ return Object.setPrototypeOf(result, Object.prototype);
166166 }
167167
168168 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/9a503.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -160,6 +160,14 @@ encodeText x =
160160
161161 --- encoder helpers
162162
163+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
164+makeDictEncoder f m r =
165+ r
166+ |> Dict.toList
167+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
168+ |> String.join ","
169+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
170+
163171 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
164172 makeNullableEncoder f m =
165173 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -137,7 +137,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
137137 if (val === null || typeof val !== "object" || Array.isArray(val)) {
138138 return invalidValue(l(ref || "object"), val, key, parent);
139139 }
140- const result: any = {};
140+ const result: any = Object.create(null);
141141 Object.getOwnPropertyNames(props).forEach(key => {
142142 const prop = props[key];
143143 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -148,7 +148,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
148148 result[key] = transform(val[key], additional, getProps, key, ref);
149149 }
150150 });
151- return result;
151+ return Object.setPrototypeOf(result, Object.prototype);
152152 }
153153
154154 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -134,7 +134,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
134134 if (val === null || typeof val !== "object" || Array.isArray(val)) {
135135 return invalidValue(l(ref || "object"), val, key, parent);
136136 }
137- const result: any = {};
137+ const result: any = Object.create(null);
138138 Object.getOwnPropertyNames(props).forEach(key => {
139139 const prop = props[key];
140140 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -145,7 +145,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
145145 result[key] = transform(val[key], additional, getProps, key, ref);
146146 }
147147 });
148- return result;
148+ return Object.setPrototypeOf(result, Object.prototype);
149149 }
150150
151151 if (typ === "any") return val;
Test case

test/inputs/json/misc/9ac3b.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -169,6 +169,14 @@ encodeTitle x = case x of
169169
170170 --- encoder helpers
171171
172+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
173+makeDictEncoder f m r =
174+ r
175+ |> Dict.toList
176+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
177+ |> String.join ","
178+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
179+
172180 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
173181 makeNullableEncoder f m =
174182 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -138,7 +138,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
138138 if (val === null || typeof val !== "object" || Array.isArray(val)) {
139139 return invalidValue(l(ref || "object"), val, key, parent);
140140 }
141- const result: any = {};
141+ const result: any = Object.create(null);
142142 Object.getOwnPropertyNames(props).forEach(key => {
143143 const prop = props[key];
144144 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -149,7 +149,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
149149 result[key] = transform(val[key], additional, getProps, key, ref);
150150 }
151151 });
152- return result;
152+ return Object.setPrototypeOf(result, Object.prototype);
153153 }
154154
155155 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 if (val === null || typeof val !== "object" || Array.isArray(val)) {
132132 return invalidValue(l(ref || "object"), val, key, parent);
133133 }
134- const result: any = {};
134+ const result: any = Object.create(null);
135135 Object.getOwnPropertyNames(props).forEach(key => {
136136 const prop = props[key];
137137 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 result[key] = transform(val[key], additional, getProps, key, ref);
143143 }
144144 });
145- return result;
145+ return Object.setPrototypeOf(result, Object.prototype);
146146 }
147147
148148 if (typ === "any") return val;
Test case

test/inputs/json/misc/9eed5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -157,6 +157,14 @@ encodeText x =
157157
158158 --- encoder helpers
159159
160+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
161+makeDictEncoder f m r =
162+ r
163+ |> Dict.toList
164+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
165+ |> String.join ","
166+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
167+
160168 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
161169 makeNullableEncoder f m =
162170 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 if (val === null || typeof val !== "object" || Array.isArray(val)) {
137137 return invalidValue(l(ref || "object"), val, key, parent);
138138 }
139- const result: any = {};
139+ const result: any = Object.create(null);
140140 Object.getOwnPropertyNames(props).forEach(key => {
141141 const prop = props[key];
142142 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 result[key] = transform(val[key], additional, getProps, key, ref);
148148 }
149149 });
150- return result;
150+ return Object.setPrototypeOf(result, Object.prototype);
151151 }
152152
153153 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -134,7 +134,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
134134 if (val === null || typeof val !== "object" || Array.isArray(val)) {
135135 return invalidValue(l(ref || "object"), val, key, parent);
136136 }
137- const result: any = {};
137+ const result: any = Object.create(null);
138138 Object.getOwnPropertyNames(props).forEach(key => {
139139 const prop = props[key];
140140 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -145,7 +145,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
145145 result[key] = transform(val[key], additional, getProps, key, ref);
146146 }
147147 });
148- return result;
148+ return Object.setPrototypeOf(result, Object.prototype);
149149 }
150150
151151 if (typ === "any") return val;
Test case

test/inputs/json/misc/a0496.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -133,6 +133,14 @@ encodeErrors x =
133133
134134 --- encoder helpers
135135
136+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
137+makeDictEncoder f m r =
138+ r
139+ |> Dict.toList
140+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
141+ |> String.join ","
142+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
143+
136144 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
137145 makeNullableEncoder f m =
138146 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 if (val === null || typeof val !== "object" || Array.isArray(val)) {
129129 return invalidValue(l(ref || "object"), val, key, parent);
130130 }
131- const result: any = {};
131+ const result: any = Object.create(null);
132132 Object.getOwnPropertyNames(props).forEach(key => {
133133 const prop = props[key];
134134 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -139,7 +139,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
139139 result[key] = transform(val[key], additional, getProps, key, ref);
140140 }
141141 });
142- return result;
142+ return Object.setPrototypeOf(result, Object.prototype);
143143 }
144144
145145 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 if (val === null || typeof val !== "object" || Array.isArray(val)) {
126126 return invalidValue(l(ref || "object"), val, key, parent);
127127 }
128- const result: any = {};
128+ const result: any = Object.create(null);
129129 Object.getOwnPropertyNames(props).forEach(key => {
130130 const prop = props[key];
131131 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 result[key] = transform(val[key], additional, getProps, key, ref);
137137 }
138138 });
139- return result;
139+ return Object.setPrototypeOf(result, Object.prototype);
140140 }
141141
142142 if (typ === "any") return val;
Test case

test/inputs/json/misc/a1eca.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -396,6 +396,14 @@ encodeWind x =
396396
397397 --- encoder helpers
398398
399+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
400+makeDictEncoder f m r =
401+ r
402+ |> Dict.toList
403+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
404+ |> String.join ","
405+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
406+
399407 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
400408 makeNullableEncoder f m =
401409 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Test case

test/inputs/json/misc/a3d8c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -470,6 +470,14 @@ encodeOwner x =
470470
471471 --- encoder helpers
472472
473+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
474+makeDictEncoder f m r =
475+ r
476+ |> Dict.toList
477+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
478+ |> String.join ","
479+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
480+
473481 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
474482 makeNullableEncoder f m =
475483 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -223,7 +223,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
223223 if (val === null || typeof val !== "object" || Array.isArray(val)) {
224224 return invalidValue(l(ref || "object"), val, key, parent);
225225 }
226- const result: any = {};
226+ const result: any = Object.create(null);
227227 Object.getOwnPropertyNames(props).forEach(key => {
228228 const prop = props[key];
229229 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -234,7 +234,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
234234 result[key] = transform(val[key], additional, getProps, key, ref);
235235 }
236236 });
237- return result;
237+ return Object.setPrototypeOf(result, Object.prototype);
238238 }
239239
240240 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -217,7 +217,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
217217 if (val === null || typeof val !== "object" || Array.isArray(val)) {
218218 return invalidValue(l(ref || "object"), val, key, parent);
219219 }
220- const result: any = {};
220+ const result: any = Object.create(null);
221221 Object.getOwnPropertyNames(props).forEach(key => {
222222 const prop = props[key];
223223 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -228,7 +228,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
228228 result[key] = transform(val[key], additional, getProps, key, ref);
229229 }
230230 });
231- return result;
231+ return Object.setPrototypeOf(result, Object.prototype);
232232 }
233233
234234 if (typ === "any") return val;
Test case

test/inputs/json/misc/a45b0.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -88,6 +88,14 @@ encodeCountry x = case x of
8888
8989 --- encoder helpers
9090
91+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
92+makeDictEncoder f m r =
93+ r
94+ |> Dict.toList
95+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
96+ |> String.join ","
97+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
98+
9199 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
92100 makeNullableEncoder f m =
93101 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/json/misc/a71df.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/a9691.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/ab0d1.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -88,6 +88,14 @@ encodeCountry x = case x of
8888
8989 --- encoder helpers
9090
91+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
92+makeDictEncoder f m r =
93+ r
94+ |> Dict.toList
95+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
96+ |> String.join ","
97+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
98+
9199 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
92100 makeNullableEncoder f m =
93101 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/json/misc/abb4b.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/ac944.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/ad8be.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -307,6 +307,14 @@ encodeTitle x = case x of
307307
308308 --- encoder helpers
309309
310+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
311+makeDictEncoder f m r =
312+ r
313+ |> Dict.toList
314+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
315+ |> String.join ","
316+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
317+
310318 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
311319 makeNullableEncoder f m =
312320 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -174,7 +174,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
174174 if (val === null || typeof val !== "object" || Array.isArray(val)) {
175175 return invalidValue(l(ref || "object"), val, key, parent);
176176 }
177- const result: any = {};
177+ const result: any = Object.create(null);
178178 Object.getOwnPropertyNames(props).forEach(key => {
179179 const prop = props[key];
180180 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -185,7 +185,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
185185 result[key] = transform(val[key], additional, getProps, key, ref);
186186 }
187187 });
188- return result;
188+ return Object.setPrototypeOf(result, Object.prototype);
189189 }
190190
191191 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 if (val === null || typeof val !== "object" || Array.isArray(val)) {
148148 return invalidValue(l(ref || "object"), val, key, parent);
149149 }
150- const result: any = {};
150+ const result: any = Object.create(null);
151151 Object.getOwnPropertyNames(props).forEach(key => {
152152 const prop = props[key];
153153 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -158,7 +158,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
158158 result[key] = transform(val[key], additional, getProps, key, ref);
159159 }
160160 });
161- return result;
161+ return Object.setPrototypeOf(result, Object.prototype);
162162 }
163163
164164 if (typ === "any") return val;
Test case

test/inputs/json/misc/ae7f0.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -407,6 +407,14 @@ encodeKind x = case x of
407407
408408 --- encoder helpers
409409
410+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
411+makeDictEncoder f m r =
412+ r
413+ |> Dict.toList
414+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
415+ |> String.join ","
416+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
417+
410418 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
411419 makeNullableEncoder f m =
412420 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -204,7 +204,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
204204 if (val === null || typeof val !== "object" || Array.isArray(val)) {
205205 return invalidValue(l(ref || "object"), val, key, parent);
206206 }
207- const result: any = {};
207+ const result: any = Object.create(null);
208208 Object.getOwnPropertyNames(props).forEach(key => {
209209 const prop = props[key];
210210 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -215,7 +215,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
215215 result[key] = transform(val[key], additional, getProps, key, ref);
216216 }
217217 });
218- return result;
218+ return Object.setPrototypeOf(result, Object.prototype);
219219 }
220220
221221 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -195,7 +195,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
195195 if (val === null || typeof val !== "object" || Array.isArray(val)) {
196196 return invalidValue(l(ref || "object"), val, key, parent);
197197 }
198- const result: any = {};
198+ const result: any = Object.create(null);
199199 Object.getOwnPropertyNames(props).forEach(key => {
200200 const prop = props[key];
201201 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -206,7 +206,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
206206 result[key] = transform(val[key], additional, getProps, key, ref);
207207 }
208208 });
209- return result;
209+ return Object.setPrototypeOf(result, Object.prototype);
210210 }
211211
212212 if (typ === "any") return val;
Test case

test/inputs/json/misc/ae9ca.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -240,6 +240,14 @@ encodeWard x = case x of
240240
241241 --- encoder helpers
242242
243+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
244+makeDictEncoder f m r =
245+ r
246+ |> Dict.toList
247+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
248+ |> String.join ","
249+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
250+
243251 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
244252 makeNullableEncoder f m =
245253 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -153,7 +153,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
153153 if (val === null || typeof val !== "object" || Array.isArray(val)) {
154154 return invalidValue(l(ref || "object"), val, key, parent);
155155 }
156- const result: any = {};
156+ const result: any = Object.create(null);
157157 Object.getOwnPropertyNames(props).forEach(key => {
158158 const prop = props[key];
159159 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -164,7 +164,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
164164 result[key] = transform(val[key], additional, getProps, key, ref);
165165 }
166166 });
167- return result;
167+ return Object.setPrototypeOf(result, Object.prototype);
168168 }
169169
170170 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -143,7 +143,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
143143 if (val === null || typeof val !== "object" || Array.isArray(val)) {
144144 return invalidValue(l(ref || "object"), val, key, parent);
145145 }
146- const result: any = {};
146+ const result: any = Object.create(null);
147147 Object.getOwnPropertyNames(props).forEach(key => {
148148 const prop = props[key];
149149 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -154,7 +154,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
154154 result[key] = transform(val[key], additional, getProps, key, ref);
155155 }
156156 });
157- return result;
157+ return Object.setPrototypeOf(result, Object.prototype);
158158 }
159159
160160 if (typ === "any") return val;
Test case

test/inputs/json/misc/af2d1.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -474,6 +474,14 @@ encodeStatus x = case x of
474474
475475 --- encoder helpers
476476
477+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
478+makeDictEncoder f m r =
479+ r
480+ |> Dict.toList
481+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
482+ |> String.join ","
483+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
484+
477485 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
478486 makeNullableEncoder f m =
479487 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -215,7 +215,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
215215 if (val === null || typeof val !== "object" || Array.isArray(val)) {
216216 return invalidValue(l(ref || "object"), val, key, parent);
217217 }
218- const result: any = {};
218+ const result: any = Object.create(null);
219219 Object.getOwnPropertyNames(props).forEach(key => {
220220 const prop = props[key];
221221 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -226,7 +226,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
226226 result[key] = transform(val[key], additional, getProps, key, ref);
227227 }
228228 });
229- return result;
229+ return Object.setPrototypeOf(result, Object.prototype);
230230 }
231231
232232 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -193,7 +193,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
193193 if (val === null || typeof val !== "object" || Array.isArray(val)) {
194194 return invalidValue(l(ref || "object"), val, key, parent);
195195 }
196- const result: any = {};
196+ const result: any = Object.create(null);
197197 Object.getOwnPropertyNames(props).forEach(key => {
198198 const prop = props[key];
199199 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -204,7 +204,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
204204 result[key] = transform(val[key], additional, getProps, key, ref);
205205 }
206206 });
207- return result;
207+ return Object.setPrototypeOf(result, Object.prototype);
208208 }
209209
210210 if (typ === "any") return val;
Test case

test/inputs/json/misc/b4865.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -162,6 +162,14 @@ encodeNametype x = case x of
162162
163163 --- encoder helpers
164164
165+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
166+makeDictEncoder f m r =
167+ r
168+ |> Dict.toList
169+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
170+ |> String.join ","
171+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
172+
165173 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
166174 makeNullableEncoder f m =
167175 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 if (val === null || typeof val !== "object" || Array.isArray(val)) {
136136 return invalidValue(l(ref || "object"), val, key, parent);
137137 }
138- const result: any = {};
138+ const result: any = Object.create(null);
139139 Object.getOwnPropertyNames(props).forEach(key => {
140140 const prop = props[key];
141141 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 result[key] = transform(val[key], additional, getProps, key, ref);
147147 }
148148 });
149- return result;
149+ return Object.setPrototypeOf(result, Object.prototype);
150150 }
151151
152152 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 if (val === null || typeof val !== "object" || Array.isArray(val)) {
132132 return invalidValue(l(ref || "object"), val, key, parent);
133133 }
134- const result: any = {};
134+ const result: any = Object.create(null);
135135 Object.getOwnPropertyNames(props).forEach(key => {
136136 const prop = props[key];
137137 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 result[key] = transform(val[key], additional, getProps, key, ref);
143143 }
144144 });
145- return result;
145+ return Object.setPrototypeOf(result, Object.prototype);
146146 }
147147
148148 if (typ === "any") return val;
Test case

test/inputs/json/misc/b6f2c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/b6fe5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -59,6 +59,14 @@ encodeQuickType x =
5959
6060 --- encoder helpers
6161
62+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
63+makeDictEncoder f m r =
64+ r
65+ |> Dict.toList
66+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
67+ |> String.join ","
68+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
69+
6270 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6371 makeNullableEncoder f m =
6472 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/json/misc/b9f64.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Test case

test/inputs/json/misc/bb1ec.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/be234.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -636,6 +636,14 @@ encodeKind x = case x of
636636
637637 --- encoder helpers
638638
639+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
640+makeDictEncoder f m r =
641+ r
642+ |> Dict.toList
643+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
644+ |> String.join ","
645+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
646+
639647 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
640648 makeNullableEncoder f m =
641649 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -269,7 +269,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
269269 if (val === null || typeof val !== "object" || Array.isArray(val)) {
270270 return invalidValue(l(ref || "object"), val, key, parent);
271271 }
272- const result: any = {};
272+ const result: any = Object.create(null);
273273 Object.getOwnPropertyNames(props).forEach(key => {
274274 const prop = props[key];
275275 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -280,7 +280,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
280280 result[key] = transform(val[key], additional, getProps, key, ref);
281281 }
282282 });
283- return result;
283+ return Object.setPrototypeOf(result, Object.prototype);
284284 }
285285
286286 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -256,7 +256,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
256256 if (val === null || typeof val !== "object" || Array.isArray(val)) {
257257 return invalidValue(l(ref || "object"), val, key, parent);
258258 }
259- const result: any = {};
259+ const result: any = Object.create(null);
260260 Object.getOwnPropertyNames(props).forEach(key => {
261261 const prop = props[key];
262262 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -267,7 +267,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
267267 result[key] = transform(val[key], additional, getProps, key, ref);
268268 }
269269 });
270- return result;
270+ return Object.setPrototypeOf(result, Object.prototype);
271271 }
272272
273273 if (typ === "any") return val;
Test case

test/inputs/json/misc/c0356.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -60,7 +60,7 @@ quickType =
6060 encodeQuickType : QuickType -> Jenc.Value
6161 encodeQuickType x =
6262 Jenc.object
63- [ ("data", Jenc.dict identity encodeDatum x.data)
63+ [ ("data", makeDictEncoder identity encodeDatum x.data)
6464 , ("description", encodeDescription x.description)
6565 ]
6666
@@ -94,6 +94,14 @@ encodeDescription x =
9494
9595 --- encoder helpers
9696
97+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
98+makeDictEncoder f m r =
99+ r
100+ |> Dict.toList
101+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
102+ |> String.join ","
103+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
104+
97105 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
98106 makeNullableEncoder f m =
99107 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 if (val === null || typeof val !== "object" || Array.isArray(val)) {
120120 return invalidValue(l(ref || "object"), val, key, parent);
121121 }
122- const result: any = {};
122+ const result: any = Object.create(null);
123123 Object.getOwnPropertyNames(props).forEach(key => {
124124 const prop = props[key];
125125 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 result[key] = transform(val[key], additional, getProps, key, ref);
131131 }
132132 });
133- return result;
133+ return Object.setPrototypeOf(result, Object.prototype);
134134 }
135135
136136 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 if (val === null || typeof val !== "object" || Array.isArray(val)) {
120120 return invalidValue(l(ref || "object"), val, key, parent);
121121 }
122- const result: any = {};
122+ const result: any = Object.create(null);
123123 Object.getOwnPropertyNames(props).forEach(key => {
124124 const prop = props[key];
125125 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 result[key] = transform(val[key], additional, getProps, key, ref);
131131 }
132132 });
133- return result;
133+ return Object.setPrototypeOf(result, Object.prototype);
134134 }
135135
136136 if (typ === "any") return val;
Test case

test/inputs/json/misc/c0a3a.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/c3303.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -449,6 +449,14 @@ encodePagination x =
449449
450450 --- encoder helpers
451451
452+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
453+makeDictEncoder f m r =
454+ r
455+ |> Dict.toList
456+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
457+ |> String.join ","
458+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
459+
452460 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
453461 makeNullableEncoder f m =
454462 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -220,7 +220,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
220220 if (val === null || typeof val !== "object" || Array.isArray(val)) {
221221 return invalidValue(l(ref || "object"), val, key, parent);
222222 }
223- const result: any = {};
223+ const result: any = Object.create(null);
224224 Object.getOwnPropertyNames(props).forEach(key => {
225225 const prop = props[key];
226226 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -231,7 +231,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
231231 result[key] = transform(val[key], additional, getProps, key, ref);
232232 }
233233 });
234- return result;
234+ return Object.setPrototypeOf(result, Object.prototype);
235235 }
236236
237237 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -214,7 +214,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
214214 if (val === null || typeof val !== "object" || Array.isArray(val)) {
215215 return invalidValue(l(ref || "object"), val, key, parent);
216216 }
217- const result: any = {};
217+ const result: any = Object.create(null);
218218 Object.getOwnPropertyNames(props).forEach(key => {
219219 const prop = props[key];
220220 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -225,7 +225,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
225225 result[key] = transform(val[key], additional, getProps, key, ref);
226226 }
227227 });
228- return result;
228+ return Object.setPrototypeOf(result, Object.prototype);
229229 }
230230
231231 if (typ === "any") return val;
Test case

test/inputs/json/misc/c6cfd.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeCountry x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/c8c7e.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -169,6 +169,14 @@ encodeFluffyQuickType x =
169169
170170 --- encoder helpers
171171
172+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
173+makeDictEncoder f m r =
174+ r
175+ |> Dict.toList
176+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
177+ |> String.join ","
178+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
179+
172180 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
173181 makeNullableEncoder f m =
174182 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 if (val === null || typeof val !== "object" || Array.isArray(val)) {
136136 return invalidValue(l(ref || "object"), val, key, parent);
137137 }
138- const result: any = {};
138+ const result: any = Object.create(null);
139139 Object.getOwnPropertyNames(props).forEach(key => {
140140 const prop = props[key];
141141 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 result[key] = transform(val[key], additional, getProps, key, ref);
147147 }
148148 });
149- return result;
149+ return Object.setPrototypeOf(result, Object.prototype);
150150 }
151151
152152 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 if (val === null || typeof val !== "object" || Array.isArray(val)) {
132132 return invalidValue(l(ref || "object"), val, key, parent);
133133 }
134- const result: any = {};
134+ const result: any = Object.create(null);
135135 Object.getOwnPropertyNames(props).forEach(key => {
136136 const prop = props[key];
137137 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 result[key] = transform(val[key], additional, getProps, key, ref);
143143 }
144144 });
145- return result;
145+ return Object.setPrototypeOf(result, Object.prototype);
146146 }
147147
148148 if (typ === "any") return val;
Test case

test/inputs/json/misc/cb0cc.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -135,6 +135,14 @@ encodeLaureate x =
135135
136136 --- encoder helpers
137137
138+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
139+makeDictEncoder f m r =
140+ r
141+ |> Dict.toList
142+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
143+ |> String.join ","
144+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
145+
138146 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
139147 makeNullableEncoder f m =
140148 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 if (val === null || typeof val !== "object" || Array.isArray(val)) {
131131 return invalidValue(l(ref || "object"), val, key, parent);
132132 }
133- const result: any = {};
133+ const result: any = Object.create(null);
134134 Object.getOwnPropertyNames(props).forEach(key => {
135135 const prop = props[key];
136136 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -141,7 +141,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
141141 result[key] = transform(val[key], additional, getProps, key, ref);
142142 }
143143 });
144- return result;
144+ return Object.setPrototypeOf(result, Object.prototype);
145145 }
146146
147147 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 if (val === null || typeof val !== "object" || Array.isArray(val)) {
125125 return invalidValue(l(ref || "object"), val, key, parent);
126126 }
127- const result: any = {};
127+ const result: any = Object.create(null);
128128 Object.getOwnPropertyNames(props).forEach(key => {
129129 const prop = props[key];
130130 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 result[key] = transform(val[key], additional, getProps, key, ref);
136136 }
137137 });
138- return result;
138+ return Object.setPrototypeOf(result, Object.prototype);
139139 }
140140
141141 if (typ === "any") return val;
Test case

test/inputs/json/misc/cb81e.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -55,7 +55,7 @@ quickType =
5555 encodeQuickType : QuickType -> Jenc.Value
5656 encodeQuickType x =
5757 Jenc.object
58- [ ("data", Jenc.dict identity Jenc.string x.data)
58+ [ ("data", makeDictEncoder identity Jenc.string x.data)
5959 , ("description", encodeDescription x.description)
6060 ]
6161
@@ -78,6 +78,14 @@ encodeDescription x =
7878
7979 --- encoder helpers
8080
81+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
82+makeDictEncoder f m r =
83+ r
84+ |> Dict.toList
85+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
86+ |> String.join ","
87+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
88+
8189 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8290 makeNullableEncoder f m =
8391 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/json/misc/ccd18.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/cd238.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -161,6 +161,14 @@ encodeMeta x =
161161
162162 --- encoder helpers
163163
164+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
165+makeDictEncoder f m r =
166+ r
167+ |> Dict.toList
168+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
169+ |> String.join ","
170+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
171+
164172 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
165173 makeNullableEncoder f m =
166174 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 if (val === null || typeof val !== "object" || Array.isArray(val)) {
141141 return invalidValue(l(ref || "object"), val, key, parent);
142142 }
143- const result: any = {};
143+ const result: any = Object.create(null);
144144 Object.getOwnPropertyNames(props).forEach(key => {
145145 const prop = props[key];
146146 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -151,7 +151,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
151151 result[key] = transform(val[key], additional, getProps, key, ref);
152152 }
153153 });
154- return result;
154+ return Object.setPrototypeOf(result, Object.prototype);
155155 }
156156
157157 if (typ === "any") return val;
Test case

test/inputs/json/misc/cd463.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/cda6c.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -169,6 +169,14 @@ encodeFluffyQuickType x =
169169
170170 --- encoder helpers
171171
172+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
173+makeDictEncoder f m r =
174+ r
175+ |> Dict.toList
176+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
177+ |> String.join ","
178+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
179+
172180 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
173181 makeNullableEncoder f m =
174182 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 if (val === null || typeof val !== "object" || Array.isArray(val)) {
136136 return invalidValue(l(ref || "object"), val, key, parent);
137137 }
138- const result: any = {};
138+ const result: any = Object.create(null);
139139 Object.getOwnPropertyNames(props).forEach(key => {
140140 const prop = props[key];
141141 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 result[key] = transform(val[key], additional, getProps, key, ref);
147147 }
148148 });
149- return result;
149+ return Object.setPrototypeOf(result, Object.prototype);
150150 }
151151
152152 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 if (val === null || typeof val !== "object" || Array.isArray(val)) {
132132 return invalidValue(l(ref || "object"), val, key, parent);
133133 }
134- const result: any = {};
134+ const result: any = Object.create(null);
135135 Object.getOwnPropertyNames(props).forEach(key => {
136136 const prop = props[key];
137137 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 result[key] = transform(val[key], additional, getProps, key, ref);
143143 }
144144 });
145- return result;
145+ return Object.setPrototypeOf(result, Object.prototype);
146146 }
147147
148148 if (typ === "any") return val;
Test case

test/inputs/json/misc/cf0d8.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -396,6 +396,14 @@ encodeWind x =
396396
397397 --- encoder helpers
398398
399+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
400+makeDictEncoder f m r =
401+ r
402+ |> Dict.toList
403+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
404+ |> String.join ","
405+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
406+
399407 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
400408 makeNullableEncoder f m =
401409 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Test case

test/inputs/json/misc/cfbce.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -51,11 +51,19 @@ encodeQuickType x =
5151 Jenc.object
5252 [ ("base", Jenc.string x.base)
5353 , ("date", Jenc.string x.date)
54- , ("rates", Jenc.dict identity Jenc.float x.rates)
54+ , ("rates", makeDictEncoder identity Jenc.float x.rates)
5555 ]
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/misc/d0908.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeTotalPopulation x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/d23d5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -114,6 +114,14 @@ encodeResult x =
114114
115115 --- encoder helpers
116116
117+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
118+makeDictEncoder f m r =
119+ r
120+ |> Dict.toList
121+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
122+ |> String.join ","
123+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
124+
117125 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
118126 makeNullableEncoder f m =
119127 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 if (val === null || typeof val !== "object" || Array.isArray(val)) {
126126 return invalidValue(l(ref || "object"), val, key, parent);
127127 }
128- const result: any = {};
128+ const result: any = Object.create(null);
129129 Object.getOwnPropertyNames(props).forEach(key => {
130130 const prop = props[key];
131131 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 result[key] = transform(val[key], additional, getProps, key, ref);
137137 }
138138 });
139- return result;
139+ return Object.setPrototypeOf(result, Object.prototype);
140140 }
141141
142142 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 if (val === null || typeof val !== "object" || Array.isArray(val)) {
123123 return invalidValue(l(ref || "object"), val, key, parent);
124124 }
125- const result: any = {};
125+ const result: any = Object.create(null);
126126 Object.getOwnPropertyNames(props).forEach(key => {
127127 const prop = props[key];
128128 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -133,7 +133,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
133133 result[key] = transform(val[key], additional, getProps, key, ref);
134134 }
135135 });
136- return result;
136+ return Object.setPrototypeOf(result, Object.prototype);
137137 }
138138
139139 if (typ === "any") return val;
Test case

test/inputs/json/misc/dbfb3.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -416,6 +416,14 @@ encodeWind x =
416416
417417 --- encoder helpers
418418
419+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
420+makeDictEncoder f m r =
421+ r
422+ |> Dict.toList
423+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
424+ |> String.join ","
425+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
426+
419427 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
420428 makeNullableEncoder f m =
421429 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -209,7 +209,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
209209 if (val === null || typeof val !== "object" || Array.isArray(val)) {
210210 return invalidValue(l(ref || "object"), val, key, parent);
211211 }
212- const result: any = {};
212+ const result: any = Object.create(null);
213213 Object.getOwnPropertyNames(props).forEach(key => {
214214 const prop = props[key];
215215 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -220,7 +220,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
220220 result[key] = transform(val[key], additional, getProps, key, ref);
221221 }
222222 });
223- return result;
223+ return Object.setPrototypeOf(result, Object.prototype);
224224 }
225225
226226 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -207,7 +207,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
207207 if (val === null || typeof val !== "object" || Array.isArray(val)) {
208208 return invalidValue(l(ref || "object"), val, key, parent);
209209 }
210- const result: any = {};
210+ const result: any = Object.create(null);
211211 Object.getOwnPropertyNames(props).forEach(key => {
212212 const prop = props[key];
213213 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -218,7 +218,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
218218 result[key] = transform(val[key], additional, getProps, key, ref);
219219 }
220220 });
221- return result;
221+ return Object.setPrototypeOf(result, Object.prototype);
222222 }
223223
224224 if (typ === "any") return val;
Test case

test/inputs/json/misc/dc44f.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -512,6 +512,14 @@ encodeType x = case x of
512512
513513 --- encoder helpers
514514
515+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
516+makeDictEncoder f m r =
517+ r
518+ |> Dict.toList
519+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
520+ |> String.join ","
521+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
522+
515523 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
516524 makeNullableEncoder f m =
517525 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -233,7 +233,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
233233 if (val === null || typeof val !== "object" || Array.isArray(val)) {
234234 return invalidValue(l(ref || "object"), val, key, parent);
235235 }
236- const result: any = {};
236+ const result: any = Object.create(null);
237237 Object.getOwnPropertyNames(props).forEach(key => {
238238 const prop = props[key];
239239 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -244,7 +244,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
244244 result[key] = transform(val[key], additional, getProps, key, ref);
245245 }
246246 });
247- return result;
247+ return Object.setPrototypeOf(result, Object.prototype);
248248 }
249249
250250 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -175,7 +175,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
175175 if (val === null || typeof val !== "object" || Array.isArray(val)) {
176176 return invalidValue(l(ref || "object"), val, key, parent);
177177 }
178- const result: any = {};
178+ const result: any = Object.create(null);
179179 Object.getOwnPropertyNames(props).forEach(key => {
180180 const prop = props[key];
181181 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -186,7 +186,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
186186 result[key] = transform(val[key], additional, getProps, key, ref);
187187 }
188188 });
189- return result;
189+ return Object.setPrototypeOf(result, Object.prototype);
190190 }
191191
192192 if (typ === "any") return val;
Test case

test/inputs/json/misc/dd1ce.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -512,6 +512,14 @@ encodeType x = case x of
512512
513513 --- encoder helpers
514514
515+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
516+makeDictEncoder f m r =
517+ r
518+ |> Dict.toList
519+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
520+ |> String.join ","
521+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
522+
515523 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
516524 makeNullableEncoder f m =
517525 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -233,7 +233,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
233233 if (val === null || typeof val !== "object" || Array.isArray(val)) {
234234 return invalidValue(l(ref || "object"), val, key, parent);
235235 }
236- const result: any = {};
236+ const result: any = Object.create(null);
237237 Object.getOwnPropertyNames(props).forEach(key => {
238238 const prop = props[key];
239239 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -244,7 +244,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
244244 result[key] = transform(val[key], additional, getProps, key, ref);
245245 }
246246 });
247- return result;
247+ return Object.setPrototypeOf(result, Object.prototype);
248248 }
249249
250250 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -175,7 +175,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
175175 if (val === null || typeof val !== "object" || Array.isArray(val)) {
176176 return invalidValue(l(ref || "object"), val, key, parent);
177177 }
178- const result: any = {};
178+ const result: any = Object.create(null);
179179 Object.getOwnPropertyNames(props).forEach(key => {
180180 const prop = props[key];
181181 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -186,7 +186,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
186186 result[key] = transform(val[key], additional, getProps, key, ref);
187187 }
188188 });
189- return result;
189+ return Object.setPrototypeOf(result, Object.prototype);
190190 }
191191
192192 if (typ === "any") return val;
Test case

test/inputs/json/misc/dec3a.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -257,6 +257,14 @@ encodeLocation x =
257257
258258 --- encoder helpers
259259
260+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
261+makeDictEncoder f m r =
262+ r
263+ |> Dict.toList
264+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
265+ |> String.join ","
266+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
267+
260268 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
261269 makeNullableEncoder f m =
262270 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -168,7 +168,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
168168 if (val === null || typeof val !== "object" || Array.isArray(val)) {
169169 return invalidValue(l(ref || "object"), val, key, parent);
170170 }
171- const result: any = {};
171+ const result: any = Object.create(null);
172172 Object.getOwnPropertyNames(props).forEach(key => {
173173 const prop = props[key];
174174 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -179,7 +179,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
179179 result[key] = transform(val[key], additional, getProps, key, ref);
180180 }
181181 });
182- return result;
182+ return Object.setPrototypeOf(result, Object.prototype);
183183 }
184184
185185 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -168,7 +168,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
168168 if (val === null || typeof val !== "object" || Array.isArray(val)) {
169169 return invalidValue(l(ref || "object"), val, key, parent);
170170 }
171- const result: any = {};
171+ const result: any = Object.create(null);
172172 Object.getOwnPropertyNames(props).forEach(key => {
173173 const prop = props[key];
174174 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -179,7 +179,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
179179 result[key] = transform(val[key], additional, getProps, key, ref);
180180 }
181181 });
182- return result;
182+ return Object.setPrototypeOf(result, Object.prototype);
183183 }
184184
185185 if (typ === "any") return val;
Test case

test/inputs/json/misc/df957.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -396,6 +396,14 @@ encodeWind x =
396396
397397 --- encoder helpers
398398
399+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
400+makeDictEncoder f m r =
401+ r
402+ |> Dict.toList
403+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
404+ |> String.join ","
405+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
406+
399407 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
400408 makeNullableEncoder f m =
401409 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -205,7 +205,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
205205 if (val === null || typeof val !== "object" || Array.isArray(val)) {
206206 return invalidValue(l(ref || "object"), val, key, parent);
207207 }
208- const result: any = {};
208+ const result: any = Object.create(null);
209209 Object.getOwnPropertyNames(props).forEach(key => {
210210 const prop = props[key];
211211 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -216,7 +216,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
216216 result[key] = transform(val[key], additional, getProps, key, ref);
217217 }
218218 });
219- return result;
219+ return Object.setPrototypeOf(result, Object.prototype);
220220 }
221221
222222 if (typ === "any") return val;
Test case

test/inputs/json/misc/e0ac7.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -432,6 +432,14 @@ encodePagination x =
432432
433433 --- encoder helpers
434434
435+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
436+makeDictEncoder f m r =
437+ r
438+ |> Dict.toList
439+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
440+ |> String.join ","
441+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
442+
435443 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
436444 makeNullableEncoder f m =
437445 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -217,7 +217,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
217217 if (val === null || typeof val !== "object" || Array.isArray(val)) {
218218 return invalidValue(l(ref || "object"), val, key, parent);
219219 }
220- const result: any = {};
220+ const result: any = Object.create(null);
221221 Object.getOwnPropertyNames(props).forEach(key => {
222222 const prop = props[key];
223223 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -228,7 +228,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
228228 result[key] = transform(val[key], additional, getProps, key, ref);
229229 }
230230 });
231- return result;
231+ return Object.setPrototypeOf(result, Object.prototype);
232232 }
233233
234234 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -213,7 +213,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
213213 if (val === null || typeof val !== "object" || Array.isArray(val)) {
214214 return invalidValue(l(ref || "object"), val, key, parent);
215215 }
216- const result: any = {};
216+ const result: any = Object.create(null);
217217 Object.getOwnPropertyNames(props).forEach(key => {
218218 const prop = props[key];
219219 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -224,7 +224,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
224224 result[key] = transform(val[key], additional, getProps, key, ref);
225225 }
226226 });
227- return result;
227+ return Object.setPrototypeOf(result, Object.prototype);
228228 }
229229
230230 if (typ === "any") return val;
Test case

test/inputs/json/misc/e2915.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -413,6 +413,14 @@ encodeWind x =
413413
414414 --- encoder helpers
415415
416+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
417+makeDictEncoder f m r =
418+ r
419+ |> Dict.toList
420+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
421+ |> String.join ","
422+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
423+
416424 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
417425 makeNullableEncoder f m =
418426 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -208,7 +208,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
208208 if (val === null || typeof val !== "object" || Array.isArray(val)) {
209209 return invalidValue(l(ref || "object"), val, key, parent);
210210 }
211- const result: any = {};
211+ const result: any = Object.create(null);
212212 Object.getOwnPropertyNames(props).forEach(key => {
213213 const prop = props[key];
214214 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -219,7 +219,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
219219 result[key] = transform(val[key], additional, getProps, key, ref);
220220 }
221221 });
222- return result;
222+ return Object.setPrototypeOf(result, Object.prototype);
223223 }
224224
225225 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -207,7 +207,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
207207 if (val === null || typeof val !== "object" || Array.isArray(val)) {
208208 return invalidValue(l(ref || "object"), val, key, parent);
209209 }
210- const result: any = {};
210+ const result: any = Object.create(null);
211211 Object.getOwnPropertyNames(props).forEach(key => {
212212 const prop = props[key];
213213 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -218,7 +218,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
218218 result[key] = transform(val[key], additional, getProps, key, ref);
219219 }
220220 });
221- return result;
221+ return Object.setPrototypeOf(result, Object.prototype);
222222 }
223223
224224 if (typ === "any") return val;
Test case

test/inputs/json/misc/e2a58.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -59,6 +59,14 @@ encodeQuickTypeElement x =
5959
6060 --- encoder helpers
6161
62+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
63+makeDictEncoder f m r =
64+ r
65+ |> Dict.toList
66+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
67+ |> String.join ","
68+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
69+
6270 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6371 makeNullableEncoder f m =
6472 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/json/misc/e324e.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -166,7 +166,7 @@ rate =
166166 encodeRate : Rate -> Jenc.Value
167167 encodeRate x =
168168 Jenc.object
169- [ ("properties", Jenc.dict identity encodeProperty x.properties)
169+ [ ("properties", makeDictEncoder identity encodeProperty x.properties)
170170 ]
171171
172172 property : Jdec.Decoder Property
@@ -322,6 +322,14 @@ encodeItems x =
322322
323323 --- encoder helpers
324324
325+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
326+makeDictEncoder f m r =
327+ r
328+ |> Dict.toList
329+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
330+ |> String.join ","
331+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
332+
325333 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
326334 makeNullableEncoder f m =
327335 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -179,7 +179,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
179179 if (val === null || typeof val !== "object" || Array.isArray(val)) {
180180 return invalidValue(l(ref || "object"), val, key, parent);
181181 }
182- const result: any = {};
182+ const result: any = Object.create(null);
183183 Object.getOwnPropertyNames(props).forEach(key => {
184184 const prop = props[key];
185185 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -190,7 +190,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
190190 result[key] = transform(val[key], additional, getProps, key, ref);
191191 }
192192 });
193- return result;
193+ return Object.setPrototypeOf(result, Object.prototype);
194194 }
195195
196196 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -178,7 +178,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
178178 if (val === null || typeof val !== "object" || Array.isArray(val)) {
179179 return invalidValue(l(ref || "object"), val, key, parent);
180180 }
181- const result: any = {};
181+ const result: any = Object.create(null);
182182 Object.getOwnPropertyNames(props).forEach(key => {
183183 const prop = props[key];
184184 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -189,7 +189,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
189189 result[key] = transform(val[key], additional, getProps, key, ref);
190190 }
191191 });
192- return result;
192+ return Object.setPrototypeOf(result, Object.prototype);
193193 }
194194
195195 if (typ === "any") return val;
Test case

test/inputs/json/misc/e53b5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -169,6 +169,14 @@ encodeFluffyQuickType x =
169169
170170 --- encoder helpers
171171
172+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
173+makeDictEncoder f m r =
174+ r
175+ |> Dict.toList
176+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
177+ |> String.join ","
178+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
179+
172180 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
173181 makeNullableEncoder f m =
174182 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 if (val === null || typeof val !== "object" || Array.isArray(val)) {
136136 return invalidValue(l(ref || "object"), val, key, parent);
137137 }
138- const result: any = {};
138+ const result: any = Object.create(null);
139139 Object.getOwnPropertyNames(props).forEach(key => {
140140 const prop = props[key];
141141 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 result[key] = transform(val[key], additional, getProps, key, ref);
147147 }
148148 });
149- return result;
149+ return Object.setPrototypeOf(result, Object.prototype);
150150 }
151151
152152 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 if (val === null || typeof val !== "object" || Array.isArray(val)) {
132132 return invalidValue(l(ref || "object"), val, key, parent);
133133 }
134- const result: any = {};
134+ const result: any = Object.create(null);
135135 Object.getOwnPropertyNames(props).forEach(key => {
136136 const prop = props[key];
137137 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -142,7 +142,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
142142 result[key] = transform(val[key], additional, getProps, key, ref);
143143 }
144144 });
145- return result;
145+ return Object.setPrototypeOf(result, Object.prototype);
146146 }
147147
148148 if (typ === "any") return val;
Test case

test/inputs/json/misc/e64a0.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -99,6 +99,14 @@ encodeHeaders x =
9999
100100 --- encoder helpers
101101
102+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
103+makeDictEncoder f m r =
104+ r
105+ |> Dict.toList
106+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
107+ |> String.join ","
108+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
109+
102110 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
103111 makeNullableEncoder f m =
104112 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Test case

test/inputs/json/misc/e8a0b.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -88,6 +88,14 @@ encodeCountry x = case x of
8888
8989 --- encoder helpers
9090
91+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
92+makeDictEncoder f m r =
93+ r
94+ |> Dict.toList
95+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
96+ |> String.join ","
97+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
98+
9199 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
92100 makeNullableEncoder f m =
93101 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/json/misc/e8b04.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -1112,6 +1112,14 @@ encodeViewType x = case x of
11121112
11131113 --- encoder helpers
11141114
1115+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1116+makeDictEncoder f m r =
1117+ r
1118+ |> Dict.toList
1119+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1120+ |> String.join ","
1121+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1122+
11151123 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
11161124 makeNullableEncoder f m =
11171125 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -377,7 +377,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
377377 if (val === null || typeof val !== "object" || Array.isArray(val)) {
378378 return invalidValue(l(ref || "object"), val, key, parent);
379379 }
380- const result: any = {};
380+ const result: any = Object.create(null);
381381 Object.getOwnPropertyNames(props).forEach(key => {
382382 const prop = props[key];
383383 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -388,7 +388,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
388388 result[key] = transform(val[key], additional, getProps, key, ref);
389389 }
390390 });
391- return result;
391+ return Object.setPrototypeOf(result, Object.prototype);
392392 }
393393
394394 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -338,7 +338,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
338338 if (val === null || typeof val !== "object" || Array.isArray(val)) {
339339 return invalidValue(l(ref || "object"), val, key, parent);
340340 }
341- const result: any = {};
341+ const result: any = Object.create(null);
342342 Object.getOwnPropertyNames(props).forEach(key => {
343343 const prop = props[key];
344344 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -349,7 +349,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
349349 result[key] = transform(val[key], additional, getProps, key, ref);
350350 }
351351 });
352- return result;
352+ return Object.setPrototypeOf(result, Object.prototype);
353353 }
354354
355355 if (typ === "any") return val;
Test case

test/inputs/json/misc/ed095.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -36,10 +36,18 @@ quickType : Jdec.Decoder QuickType
3636 quickType = Jdec.dict Jdec.string
3737
3838 quickTypeToString : QuickType -> String
39-quickTypeToString r = Jenc.encode 0 (Jenc.dict identity Jenc.string r)
39+quickTypeToString r = Jenc.encode 0 (makeDictEncoder identity Jenc.string r)
4040
4141 --- encoder helpers
4242
43+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
44+makeDictEncoder f m r =
45+ r
46+ |> Dict.toList
47+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
48+ |> String.join ","
49+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
50+
4351 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
4452 makeNullableEncoder f m =
4553 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Test case

test/inputs/json/misc/f22f5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -390,6 +390,14 @@ encodeKind x = case x of
390390
391391 --- encoder helpers
392392
393+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
394+makeDictEncoder f m r =
395+ r
396+ |> Dict.toList
397+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
398+ |> String.join ","
399+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
400+
393401 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
394402 makeNullableEncoder f m =
395403 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -201,7 +201,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
201201 if (val === null || typeof val !== "object" || Array.isArray(val)) {
202202 return invalidValue(l(ref || "object"), val, key, parent);
203203 }
204- const result: any = {};
204+ const result: any = Object.create(null);
205205 Object.getOwnPropertyNames(props).forEach(key => {
206206 const prop = props[key];
207207 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -212,7 +212,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
212212 result[key] = transform(val[key], additional, getProps, key, ref);
213213 }
214214 });
215- return result;
215+ return Object.setPrototypeOf(result, Object.prototype);
216216 }
217217
218218 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -193,7 +193,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
193193 if (val === null || typeof val !== "object" || Array.isArray(val)) {
194194 return invalidValue(l(ref || "object"), val, key, parent);
195195 }
196- const result: any = {};
196+ const result: any = Object.create(null);
197197 Object.getOwnPropertyNames(props).forEach(key => {
198198 const prop = props[key];
199199 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -204,7 +204,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
204204 result[key] = transform(val[key], additional, getProps, key, ref);
205205 }
206206 });
207- return result;
207+ return Object.setPrototypeOf(result, Object.prototype);
208208 }
209209
210210 if (typ === "any") return val;
Test case

test/inputs/json/misc/f3139.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -59,6 +59,14 @@ encodeQuickTypeElement x =
5959
6060 --- encoder helpers
6161
62+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
63+makeDictEncoder f m r =
64+ r
65+ |> Dict.toList
66+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
67+ |> String.join ","
68+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
69+
6270 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6371 makeNullableEncoder f m =
6472 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/json/misc/f3edf.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -88,6 +88,14 @@ encodeCountry x = case x of
8888
8989 --- encoder helpers
9090
91+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
92+makeDictEncoder f m r =
93+ r
94+ |> Dict.toList
95+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
96+ |> String.join ","
97+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
98+
9199 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
92100 makeNullableEncoder f m =
93101 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/json/misc/f466a.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -88,6 +88,14 @@ encodeCountry x = case x of
8888
8989 --- encoder helpers
9090
91+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
92+makeDictEncoder f m r =
93+ r
94+ |> Dict.toList
95+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
96+ |> String.join ","
97+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
98+
9199 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
92100 makeNullableEncoder f m =
93101 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/json/misc/f6a65.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -461,6 +461,14 @@ encodePagination x =
461461
462462 --- encoder helpers
463463
464+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
465+makeDictEncoder f m r =
466+ r
467+ |> Dict.toList
468+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
469+ |> String.join ","
470+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
471+
464472 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
465473 makeNullableEncoder f m =
466474 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -224,7 +224,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
224224 if (val === null || typeof val !== "object" || Array.isArray(val)) {
225225 return invalidValue(l(ref || "object"), val, key, parent);
226226 }
227- const result: any = {};
227+ const result: any = Object.create(null);
228228 Object.getOwnPropertyNames(props).forEach(key => {
229229 const prop = props[key];
230230 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -235,7 +235,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
235235 result[key] = transform(val[key], additional, getProps, key, ref);
236236 }
237237 });
238- return result;
238+ return Object.setPrototypeOf(result, Object.prototype);
239239 }
240240
241241 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -215,7 +215,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
215215 if (val === null || typeof val !== "object" || Array.isArray(val)) {
216216 return invalidValue(l(ref || "object"), val, key, parent);
217217 }
218- const result: any = {};
218+ const result: any = Object.create(null);
219219 Object.getOwnPropertyNames(props).forEach(key => {
220220 const prop = props[key];
221221 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -226,7 +226,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
226226 result[key] = transform(val[key], additional, getProps, key, ref);
227227 }
228228 });
229- return result;
229+ return Object.setPrototypeOf(result, Object.prototype);
230230 }
231231
232232 if (typ === "any") return val;
Test case

test/inputs/json/misc/f74d5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -467,6 +467,14 @@ encodeOwner x =
467467
468468 --- encoder helpers
469469
470+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
471+makeDictEncoder f m r =
472+ r
473+ |> Dict.toList
474+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
475+ |> String.join ","
476+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
477+
470478 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
471479 makeNullableEncoder f m =
472480 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -223,7 +223,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
223223 if (val === null || typeof val !== "object" || Array.isArray(val)) {
224224 return invalidValue(l(ref || "object"), val, key, parent);
225225 }
226- const result: any = {};
226+ const result: any = Object.create(null);
227227 Object.getOwnPropertyNames(props).forEach(key => {
228228 const prop = props[key];
229229 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -234,7 +234,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
234234 result[key] = transform(val[key], additional, getProps, key, ref);
235235 }
236236 });
237- return result;
237+ return Object.setPrototypeOf(result, Object.prototype);
238238 }
239239
240240 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -217,7 +217,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
217217 if (val === null || typeof val !== "object" || Array.isArray(val)) {
218218 return invalidValue(l(ref || "object"), val, key, parent);
219219 }
220- const result: any = {};
220+ const result: any = Object.create(null);
221221 Object.getOwnPropertyNames(props).forEach(key => {
222222 const prop = props[key];
223223 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -228,7 +228,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
228228 result[key] = transform(val[key], additional, getProps, key, ref);
229229 }
230230 });
231- return result;
231+ return Object.setPrototypeOf(result, Object.prototype);
232232 }
233233
234234 if (typ === "any") return val;
Test case

test/inputs/json/misc/f82d9.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -365,6 +365,14 @@ encodeItems x =
365365
366366 --- encoder helpers
367367
368+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
369+makeDictEncoder f m r =
370+ r
371+ |> Dict.toList
372+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
373+ |> String.join ","
374+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
375+
368376 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
369377 makeNullableEncoder f m =
370378 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -192,7 +192,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
192192 if (val === null || typeof val !== "object" || Array.isArray(val)) {
193193 return invalidValue(l(ref || "object"), val, key, parent);
194194 }
195- const result: any = {};
195+ const result: any = Object.create(null);
196196 Object.getOwnPropertyNames(props).forEach(key => {
197197 const prop = props[key];
198198 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -203,7 +203,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
203203 result[key] = transform(val[key], additional, getProps, key, ref);
204204 }
205205 });
206- return result;
206+ return Object.setPrototypeOf(result, Object.prototype);
207207 }
208208
209209 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -191,7 +191,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
191191 if (val === null || typeof val !== "object" || Array.isArray(val)) {
192192 return invalidValue(l(ref || "object"), val, key, parent);
193193 }
194- const result: any = {};
194+ const result: any = Object.create(null);
195195 Object.getOwnPropertyNames(props).forEach(key => {
196196 const prop = props[key];
197197 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -202,7 +202,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
202202 result[key] = transform(val[key], additional, getProps, key, ref);
203203 }
204204 });
205- return result;
205+ return Object.setPrototypeOf(result, Object.prototype);
206206 }
207207
208208 if (typ === "any") return val;
Test case

test/inputs/json/misc/f974d.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -62,6 +62,14 @@ encodeQuickType x =
6262
6363 --- encoder helpers
6464
65+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
66+makeDictEncoder f m r =
67+ r
68+ |> Dict.toList
69+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
70+ |> String.join ","
71+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
72+
6573 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6674 makeNullableEncoder f m =
6775 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/misc/faff5.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeResponse x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/misc/fcca3.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -819,6 +819,14 @@ encodeExpression x =
819819
820820 --- encoder helpers
821821
822+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
823+makeDictEncoder f m r =
824+ r
825+ |> Dict.toList
826+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
827+ |> String.join ","
828+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
829+
822830 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
823831 makeNullableEncoder f m =
824832 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -320,7 +320,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
320320 if (val === null || typeof val !== "object" || Array.isArray(val)) {
321321 return invalidValue(l(ref || "object"), val, key, parent);
322322 }
323- const result: any = {};
323+ const result: any = Object.create(null);
324324 Object.getOwnPropertyNames(props).forEach(key => {
325325 const prop = props[key];
326326 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -331,7 +331,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
331331 result[key] = transform(val[key], additional, getProps, key, ref);
332332 }
333333 });
334- return result;
334+ return Object.setPrototypeOf(result, Object.prototype);
335335 }
336336
337337 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -317,7 +317,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
317317 if (val === null || typeof val !== "object" || Array.isArray(val)) {
318318 return invalidValue(l(ref || "object"), val, key, parent);
319319 }
320- const result: any = {};
320+ const result: any = Object.create(null);
321321 Object.getOwnPropertyNames(props).forEach(key => {
322322 const prop = props[key];
323323 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -328,7 +328,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
328328 result[key] = transform(val[key], additional, getProps, key, ref);
329329 }
330330 });
331- return result;
331+ return Object.setPrototypeOf(result, Object.prototype);
332332 }
333333
334334 if (typ === "any") return val;
Test case

test/inputs/json/misc/fd329.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -61,7 +61,7 @@ quickType =
6161 encodeQuickType : QuickType -> Jenc.Value
6262 encodeQuickType x =
6363 Jenc.object
64- [ ("data", Jenc.dict identity encodeDatum x.data)
64+ [ ("data", makeDictEncoder identity encodeDatum x.data)
6565 , ("description", encodeDescription x.description)
6666 ]
6767
@@ -97,6 +97,14 @@ encodeDescription x =
9797
9898 --- encoder helpers
9999
100+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
101+makeDictEncoder f m r =
102+ r
103+ |> Dict.toList
104+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
105+ |> String.join ","
106+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
107+
100108 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
101109 makeNullableEncoder f m =
102110 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Test case

test/inputs/json/priority/blns-object.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -1847,6 +1847,14 @@ encodeC x =
18471847
18481848 --- encoder helpers
18491849
1850+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1851+makeDictEncoder f m r =
1852+ r
1853+ |> Dict.toList
1854+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1855+ |> String.join ","
1856+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1857+
18501858 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
18511859 makeNullableEncoder f m =
18521860 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -702,7 +702,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
702702 if (val === null || typeof val !== "object" || Array.isArray(val)) {
703703 return invalidValue(l(ref || "object"), val, key, parent);
704704 }
705- const result: any = {};
705+ const result: any = Object.create(null);
706706 Object.getOwnPropertyNames(props).forEach(key => {
707707 const prop = props[key];
708708 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -713,7 +713,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
713713 result[key] = transform(val[key], additional, getProps, key, ref);
714714 }
715715 });
716- return result;
716+ return Object.setPrototypeOf(result, Object.prototype);
717717 }
718718
719719 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -702,7 +702,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
702702 if (val === null || typeof val !== "object" || Array.isArray(val)) {
703703 return invalidValue(l(ref || "object"), val, key, parent);
704704 }
705- const result: any = {};
705+ const result: any = Object.create(null);
706706 Object.getOwnPropertyNames(props).forEach(key => {
707707 const prop = props[key];
708708 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -713,7 +713,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
713713 result[key] = transform(val[key], additional, getProps, key, ref);
714714 }
715715 });
716- return result;
716+ return Object.setPrototypeOf(result, Object.prototype);
717717 }
718718
719719 if (typ === "any") return val;
Test case

test/inputs/json/priority/bug2037.json

4 generated files · +17 −9
Melmdefault / QuickType.elm+11 −3
@@ -60,7 +60,7 @@ quickType =
6060 encodeQuickType : QuickType -> Jenc.Value
6161 encodeQuickType x =
6262 Jenc.object
63- [ ("mission_specs", Jenc.dict identity encodeMissionSpec x.missionSpecs)
63+ [ ("mission_specs", makeDictEncoder identity encodeMissionSpec x.missionSpecs)
6464 ]
6565
6666 missionSpec : Jdec.Decoder MissionSpec
@@ -71,7 +71,7 @@ missionSpec =
7171 encodeMissionSpec : MissionSpec -> Jenc.Value
7272 encodeMissionSpec x =
7373 Jenc.object
74- [ ("objectives", Jenc.dict identity encodeObjective x.objectives)
74+ [ ("objectives", makeDictEncoder identity encodeObjective x.objectives)
7575 ]
7676
7777 objective : Jdec.Decoder Objective
@@ -82,7 +82,7 @@ objective =
8282 encodeObjective : Objective -> Jenc.Value
8383 encodeObjective x =
8484 Jenc.object
85- [ ("rewards", Jenc.dict identity encodeReward x.rewards)
85+ [ ("rewards", makeDictEncoder identity encodeReward x.rewards)
8686 ]
8787
8888 reward : Jdec.Decoder Reward
@@ -97,6 +97,14 @@ encodeReward x =
9797
9898 --- encoder helpers
9999
100+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
101+makeDictEncoder f m r =
102+ r
103+ |> Dict.toList
104+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
105+ |> String.join ","
106+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
107+
100108 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
101109 makeNullableEncoder f m =
102110 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 if (val === null || typeof val !== "object" || Array.isArray(val)) {
119119 return invalidValue(l(ref || "object"), val, key, parent);
120120 }
121- const result: any = {};
121+ const result: any = Object.create(null);
122122 Object.getOwnPropertyNames(props).forEach(key => {
123123 const prop = props[key];
124124 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -129,7 +129,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
129129 result[key] = transform(val[key], additional, getProps, key, ref);
130130 }
131131 });
132- return result;
132+ return Object.setPrototypeOf(result, Object.prototype);
133133 }
134134
135135 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/json/priority/bug2521.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeOption x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/priority/bug2590.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -72,6 +72,14 @@ encodeInvoice x =
7272
7373 --- encoder helpers
7474
75+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
76+makeDictEncoder f m r =
77+ r
78+ |> Dict.toList
79+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
80+ |> String.join ","
81+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
82+
7583 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7684 makeNullableEncoder f m =
7785 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Test case

test/inputs/json/priority/bug2663.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -56,6 +56,14 @@ encodeQuickType x =
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/priority/bug2793.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -87,6 +87,14 @@ encodeLabels x =
8787
8888 --- encoder helpers
8989
90+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
91+makeDictEncoder f m r =
92+ r
93+ |> Dict.toList
94+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
95+ |> String.join ","
96+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
97+
9098 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
9199 makeNullableEncoder f m =
92100 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Test case

test/inputs/json/priority/bug427.json

3 generated files · +6 −6
Mflowdefault / TopLevel.js+2 −2
@@ -718,7 +718,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
718718 if (val === null || typeof val !== "object" || Array.isArray(val)) {
719719 return invalidValue(l(ref || "object"), val, key, parent);
720720 }
721- const result: any = {};
721+ const result: any = Object.create(null);
722722 Object.getOwnPropertyNames(props).forEach(key => {
723723 const prop = props[key];
724724 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -729,7 +729,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
729729 result[key] = transform(val[key], additional, getProps, key, ref);
730730 }
731731 });
732- return result;
732+ return Object.setPrototypeOf(result, Object.prototype);
733733 }
734734
735735 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -664,7 +664,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
664664 if (val === null || typeof val !== "object" || Array.isArray(val)) {
665665 return invalidValue(l(ref || "object"), val, key, parent);
666666 }
667- const result: any = {};
667+ const result: any = Object.create(null);
668668 Object.getOwnPropertyNames(props).forEach(key => {
669669 const prop = props[key];
670670 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -675,7 +675,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
675675 result[key] = transform(val[key], additional, getProps, key, ref);
676676 }
677677 });
678- return result;
678+ return Object.setPrototypeOf(result, Object.prototype);
679679 }
680680
681681 if (typ === "any") return val;
Test case

test/inputs/json/priority/bug790.json

3 generated files · +6 −6
Mflowdefault / TopLevel.js+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/json/priority/bug855-short.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -45,7 +45,7 @@ quickType : Jdec.Decoder QuickType
4545 quickType = Jdec.dict quickTypeValue
4646
4747 quickTypeToString : QuickType -> String
48-quickTypeToString r = Jenc.encode 0 (Jenc.dict identity encodeQuickTypeValue r)
48+quickTypeToString r = Jenc.encode 0 (makeDictEncoder identity encodeQuickTypeValue r)
4949
5050 quickTypeValue : Jdec.Decoder QuickTypeValue
5151 quickTypeValue =
@@ -68,6 +68,14 @@ encodeQuickTypeValue x =
6868
6969 --- encoder helpers
7070
71+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
72+makeDictEncoder f m r =
73+ r
74+ |> Dict.toList
75+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
76+ |> String.join ","
77+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
78+
7179 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7280 makeNullableEncoder f m =
7381 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/priority/bug863.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -374,6 +374,14 @@ encodeFluffyQuickType x =
374374
375375 --- encoder helpers
376376
377+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
378+makeDictEncoder f m r =
379+ r
380+ |> Dict.toList
381+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
382+ |> String.join ","
383+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
384+
377385 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
378386 makeNullableEncoder f m =
379387 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -193,7 +193,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
193193 if (val === null || typeof val !== "object" || Array.isArray(val)) {
194194 return invalidValue(l(ref || "object"), val, key, parent);
195195 }
196- const result: any = {};
196+ const result: any = Object.create(null);
197197 Object.getOwnPropertyNames(props).forEach(key => {
198198 const prop = props[key];
199199 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -204,7 +204,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
204204 result[key] = transform(val[key], additional, getProps, key, ref);
205205 }
206206 });
207- return result;
207+ return Object.setPrototypeOf(result, Object.prototype);
208208 }
209209
210210 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -177,7 +177,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
177177 if (val === null || typeof val !== "object" || Array.isArray(val)) {
178178 return invalidValue(l(ref || "object"), val, key, parent);
179179 }
180- const result: any = {};
180+ const result: any = Object.create(null);
181181 Object.getOwnPropertyNames(props).forEach(key => {
182182 const prop = props[key];
183183 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -188,7 +188,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
188188 result[key] = transform(val[key], additional, getProps, key, ref);
189189 }
190190 });
191- return result;
191+ return Object.setPrototypeOf(result, Object.prototype);
192192 }
193193
194194 if (typ === "any") return val;
Test case

test/inputs/json/priority/coin-pairs.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -59,7 +59,7 @@ quickType =
5959 encodeQuickType : QuickType -> Jenc.Value
6060 encodeQuickType x =
6161 Jenc.object
62- [ ("pairs", Jenc.dict identity encodePair x.pairs)
62+ [ ("pairs", makeDictEncoder identity encodePair x.pairs)
6363 , ("server_time", Jenc.int x.serverTime)
6464 ]
6565
@@ -90,6 +90,14 @@ encodePair x =
9090
9191 --- encoder helpers
9292
93+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
94+makeDictEncoder f m r =
95+ r
96+ |> Dict.toList
97+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
98+ |> String.join ","
99+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
100+
93101 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
94102 makeNullableEncoder f m =
95103 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 if (val === null || typeof val !== "object" || Array.isArray(val)) {
120120 return invalidValue(l(ref || "object"), val, key, parent);
121121 }
122- const result: any = {};
122+ const result: any = Object.create(null);
123123 Object.getOwnPropertyNames(props).forEach(key => {
124124 const prop = props[key];
125125 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 result[key] = transform(val[key], additional, getProps, key, ref);
131131 }
132132 });
133- return result;
133+ return Object.setPrototypeOf(result, Object.prototype);
134134 }
135135
136136 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 if (val === null || typeof val !== "object" || Array.isArray(val)) {
120120 return invalidValue(l(ref || "object"), val, key, parent);
121121 }
122- const result: any = {};
122+ const result: any = Object.create(null);
123123 Object.getOwnPropertyNames(props).forEach(key => {
124124 const prop = props[key];
125125 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 result[key] = transform(val[key], additional, getProps, key, ref);
131131 }
132132 });
133- return result;
133+ return Object.setPrototypeOf(result, Object.prototype);
134134 }
135135
136136 if (typ === "any") return val;
Test case

test/inputs/json/priority/combinations1.json

22 generated files · +74 −58
Melmarray-type-array--eed288b23e27 / QuickType.elm+17 −9
@@ -642,7 +642,7 @@ encodeQuickType x =
642642 , ("fuzzy", Jenc.array encodeFuzzy x.fuzzy)
643643 , ("gardenwards", Jenc.array encodeGardenward x.gardenwards)
644644 , ("generalissimo", Jenc.array encodeGeneralissimo x.generalissimo)
645- , ("habeas", Jenc.array (makeNullableEncoder (Jenc.dict identity Jenc.int)) x.habeas)
645+ , ("habeas", Jenc.array (makeNullableEncoder (makeDictEncoder identity Jenc.int)) x.habeas)
646646 , ("hemicrystalline", Jenc.array encodeHemicrystalline x.hemicrystalline)
647647 , ("hemocoele", Jenc.array encodeHemocoeleElement x.hemocoele)
648648 , ("hoister", Jenc.array encodeHoister x.hoister)
@@ -916,7 +916,7 @@ consilience =
916916 encodeConsilience : Consilience -> Jenc.Value
917917 encodeConsilience x = case x of
918918 DoubleInConsilience y -> Jenc.float y
919- IntegerMapInConsilience y -> Jenc.dict identity Jenc.int y
919+ IntegerMapInConsilience y -> makeDictEncoder identity Jenc.int y
920920
921921 constructor : Jdec.Decoder Constructor
922922 constructor =
@@ -928,7 +928,7 @@ constructor =
928928 encodeConstructor : Constructor -> Jenc.Value
929929 encodeConstructor x = case x of
930930 BoolInConstructor y -> Jenc.bool y
931- UnionMapInConstructor y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
931+ UnionMapInConstructor y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
932932
933933 continuative : Jdec.Decoder Continuative
934934 continuative =
@@ -940,7 +940,7 @@ continuative =
940940 encodeContinuative : Continuative -> Jenc.Value
941941 encodeContinuative x = case x of
942942 StringInContinuative y -> Jenc.string y
943- IntegerMapInContinuative y -> Jenc.dict identity Jenc.int y
943+ IntegerMapInContinuative y -> makeDictEncoder identity Jenc.int y
944944
945945 credulityElement : Jdec.Decoder CredulityElement
946946 credulityElement =
@@ -1017,7 +1017,7 @@ encodeCreviced : Creviced -> Jenc.Value
10171017 encodeCreviced x = case x of
10181018 BoolInCreviced y -> Jenc.bool y
10191019 StringInCreviced y -> Jenc.string y
1020- IntegerMapInCreviced y -> Jenc.dict identity Jenc.int y
1020+ IntegerMapInCreviced y -> makeDictEncoder identity Jenc.int y
10211021
10221022 deruralizeElement : Jdec.Decoder DeruralizeElement
10231023 deruralizeElement =
@@ -1171,7 +1171,7 @@ encodeEleutheromania : Eleutheromania -> Jenc.Value
11711171 encodeEleutheromania x = case x of
11721172 StringInEleutheromania y -> Jenc.string y
11731173 DoubleInEleutheromania y -> Jenc.float y
1174- IntegerMapInEleutheromania y -> Jenc.dict identity Jenc.int y
1174+ IntegerMapInEleutheromania y -> makeDictEncoder identity Jenc.int y
11751175
11761176 encrust : Jdec.Decoder Encrust
11771177 encrust =
@@ -1469,7 +1469,7 @@ fuzzy =
14691469 encodeFuzzy : Fuzzy -> Jenc.Value
14701470 encodeFuzzy x = case x of
14711471 IntegerInFuzzy y -> Jenc.int y
1472- UnionMapInFuzzy y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1472+ UnionMapInFuzzy y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
14731473
14741474 gardenward : Jdec.Decoder Gardenward
14751475 gardenward =
@@ -1497,7 +1497,7 @@ encodeGeneralissimo : Generalissimo -> Jenc.Value
14971497 encodeGeneralissimo x = case x of
14981498 BoolInGeneralissimo y -> Jenc.bool y
14991499 NullInGeneralissimo -> Jenc.null
1500- IntegerMapInGeneralissimo y -> Jenc.dict identity Jenc.int y
1500+ IntegerMapInGeneralissimo y -> makeDictEncoder identity Jenc.int y
15011501
15021502 hemicrystalline : Jdec.Decoder Hemicrystalline
15031503 hemicrystalline =
@@ -1695,10 +1695,18 @@ jacutinga =
16951695 encodeJacutinga : Jacutinga -> Jenc.Value
16961696 encodeJacutinga x = case x of
16971697 IntegerArrayInJacutinga y -> Jenc.array Jenc.int y
1698- UnionMapInJacutinga y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1698+ UnionMapInJacutinga y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
16991699
17001700 --- encoder helpers
17011701
1702+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1703+makeDictEncoder f m r =
1704+ r
1705+ |> Dict.toList
1706+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1707+ |> String.join ","
1708+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1709+
17021710 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
17031711 makeNullableEncoder f m =
17041712 case m of
Melmdefault / QuickType.elm+17 −9
@@ -641,7 +641,7 @@ encodeQuickType x =
641641 , ("fuzzy", Jenc.list encodeFuzzy x.fuzzy)
642642 , ("gardenwards", Jenc.list encodeGardenward x.gardenwards)
643643 , ("generalissimo", Jenc.list encodeGeneralissimo x.generalissimo)
644- , ("habeas", Jenc.list (makeNullableEncoder (Jenc.dict identity Jenc.int)) x.habeas)
644+ , ("habeas", Jenc.list (makeNullableEncoder (makeDictEncoder identity Jenc.int)) x.habeas)
645645 , ("hemicrystalline", Jenc.list encodeHemicrystalline x.hemicrystalline)
646646 , ("hemocoele", Jenc.list encodeHemocoeleElement x.hemocoele)
647647 , ("hoister", Jenc.list encodeHoister x.hoister)
@@ -915,7 +915,7 @@ consilience =
915915 encodeConsilience : Consilience -> Jenc.Value
916916 encodeConsilience x = case x of
917917 DoubleInConsilience y -> Jenc.float y
918- IntegerMapInConsilience y -> Jenc.dict identity Jenc.int y
918+ IntegerMapInConsilience y -> makeDictEncoder identity Jenc.int y
919919
920920 constructor : Jdec.Decoder Constructor
921921 constructor =
@@ -927,7 +927,7 @@ constructor =
927927 encodeConstructor : Constructor -> Jenc.Value
928928 encodeConstructor x = case x of
929929 BoolInConstructor y -> Jenc.bool y
930- UnionMapInConstructor y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
930+ UnionMapInConstructor y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
931931
932932 continuative : Jdec.Decoder Continuative
933933 continuative =
@@ -939,7 +939,7 @@ continuative =
939939 encodeContinuative : Continuative -> Jenc.Value
940940 encodeContinuative x = case x of
941941 StringInContinuative y -> Jenc.string y
942- IntegerMapInContinuative y -> Jenc.dict identity Jenc.int y
942+ IntegerMapInContinuative y -> makeDictEncoder identity Jenc.int y
943943
944944 credulityElement : Jdec.Decoder CredulityElement
945945 credulityElement =
@@ -1016,7 +1016,7 @@ encodeCreviced : Creviced -> Jenc.Value
10161016 encodeCreviced x = case x of
10171017 BoolInCreviced y -> Jenc.bool y
10181018 StringInCreviced y -> Jenc.string y
1019- IntegerMapInCreviced y -> Jenc.dict identity Jenc.int y
1019+ IntegerMapInCreviced y -> makeDictEncoder identity Jenc.int y
10201020
10211021 deruralizeElement : Jdec.Decoder DeruralizeElement
10221022 deruralizeElement =
@@ -1170,7 +1170,7 @@ encodeEleutheromania : Eleutheromania -> Jenc.Value
11701170 encodeEleutheromania x = case x of
11711171 StringInEleutheromania y -> Jenc.string y
11721172 DoubleInEleutheromania y -> Jenc.float y
1173- IntegerMapInEleutheromania y -> Jenc.dict identity Jenc.int y
1173+ IntegerMapInEleutheromania y -> makeDictEncoder identity Jenc.int y
11741174
11751175 encrust : Jdec.Decoder Encrust
11761176 encrust =
@@ -1468,7 +1468,7 @@ fuzzy =
14681468 encodeFuzzy : Fuzzy -> Jenc.Value
14691469 encodeFuzzy x = case x of
14701470 IntegerInFuzzy y -> Jenc.int y
1471- UnionMapInFuzzy y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1471+ UnionMapInFuzzy y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
14721472
14731473 gardenward : Jdec.Decoder Gardenward
14741474 gardenward =
@@ -1496,7 +1496,7 @@ encodeGeneralissimo : Generalissimo -> Jenc.Value
14961496 encodeGeneralissimo x = case x of
14971497 BoolInGeneralissimo y -> Jenc.bool y
14981498 NullInGeneralissimo -> Jenc.null
1499- IntegerMapInGeneralissimo y -> Jenc.dict identity Jenc.int y
1499+ IntegerMapInGeneralissimo y -> makeDictEncoder identity Jenc.int y
15001500
15011501 hemicrystalline : Jdec.Decoder Hemicrystalline
15021502 hemicrystalline =
@@ -1694,10 +1694,18 @@ jacutinga =
16941694 encodeJacutinga : Jacutinga -> Jenc.Value
16951695 encodeJacutinga x = case x of
16961696 IntegerArrayInJacutinga y -> Jenc.list Jenc.int y
1697- UnionMapInJacutinga y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1697+ UnionMapInJacutinga y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
16981698
16991699 --- encoder helpers
17001700
1701+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1702+makeDictEncoder f m r =
1703+ r
1704+ |> Dict.toList
1705+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1706+ |> String.join ","
1707+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1708+
17011709 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
17021710 makeNullableEncoder f m =
17031711 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mflownice-property-names-true--f4d7920ee2ce / TopLevel.js+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mflowprefer-unions-false--a5053c0a486d / TopLevel.js+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mflowprefer-unknown-false--f1ab9e45d823 / TopLevel.js+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mflowruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.js+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = val[key];
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mjavascriptconverters-top-level--67aa452ed509 / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptraw-type-any--474b307c39db / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = val[key];
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptacronym-style-pascal--d9e0c1bd777a / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mtypescriptconverters-all-objects--3a443babd1cb / TopLevel.ts+2 −2
@@ -603,7 +603,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
603603 if (val === null || typeof val !== "object" || Array.isArray(val)) {
604604 return invalidValue(l(ref || "object"), val, key, parent);
605605 }
606- const result: any = {};
606+ const result: any = Object.create(null);
607607 Object.getOwnPropertyNames(props).forEach(key => {
608608 const prop = props[key];
609609 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -614,7 +614,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
614614 result[key] = transform(val[key], additional, getProps, key, ref);
615615 }
616616 });
617- return result;
617+ return Object.setPrototypeOf(result, Object.prototype);
618618 }
619619
620620 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mtypescriptnice-property-names-true--f4d7920ee2ce / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mtypescriptprefer-const-values-true--6b26e4d1265c / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mtypescriptprefer-types-true--df33e18681f9 / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mtypescriptprefer-unions-false--a5053c0a486d / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mtypescriptprefer-unknown-false--f1ab9e45d823 / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mtypescriptraw-type-any--474b307c39db / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mtypescriptreadonly-true--24da4fc107df / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = transform(val[key], additional, getProps, key, ref);
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Mtypescriptruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.ts+2 −2
@@ -499,7 +499,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
499499 if (val === null || typeof val !== "object" || Array.isArray(val)) {
500500 return invalidValue(l(ref || "object"), val, key, parent);
501501 }
502- const result: any = {};
502+ const result: any = Object.create(null);
503503 Object.getOwnPropertyNames(props).forEach(key => {
504504 const prop = props[key];
505505 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -510,7 +510,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
510510 result[key] = val[key];
511511 }
512512 });
513- return result;
513+ return Object.setPrototypeOf(result, Object.prototype);
514514 }
515515
516516 if (typ === "any") return val;
Test case

test/inputs/json/priority/combinations2.json

22 generated files · +80 −64
Melmarray-type-array--eed288b23e27 / QuickType.elm+20 −12
@@ -579,13 +579,13 @@ encodeQuickType x =
579579 , ("amphithyron", Jenc.array (makeNullableEncoder encodeAmphithyron) x.amphithyron)
580580 , ("Andriana", Jenc.array (makeNullableEncoder Jenc.string) x.andriana)
581581 , ("ankee", Jenc.array encodeAnkeeElement x.ankee)
582- , ("annihilator", Jenc.array (makeNullableEncoder (Jenc.dict identity (makeNullableEncoder Jenc.int))) x.annihilator)
582+ , ("annihilator", Jenc.array (makeNullableEncoder (makeDictEncoder identity (makeNullableEncoder Jenc.int))) x.annihilator)
583583 , ("annulose", always Jenc.null x.annulose)
584584 , ("Ansarie", Jenc.array encodeAnsarieElement x.ansarie)
585585 , ("aphasia", Jenc.array encodeAphasia x.aphasia)
586586 , ("asprawl", Jenc.array encodeAsprawl x.asprawl)
587587 , ("attractive", Jenc.array (makeNullableEncoder Jenc.bool) x.attractive)
588- , ("barksome", Jenc.dict identity Jenc.int x.barksome)
588+ , ("barksome", makeDictEncoder identity Jenc.int x.barksome)
589589 , ("bedesman", Jenc.array encodeBedesman x.bedesman)
590590 , ("belard", Jenc.array encodeBelard x.belard)
591591 , ("bocking", Jenc.array encodeBocking x.bocking)
@@ -612,7 +612,7 @@ encodeQuickType x =
612612 , ("School", Jenc.array encodeSchool x.school)
613613 , ("Shakespearolater", Jenc.array encodeShakespearolater x.shakespearolater)
614614 , ("Svan", Jenc.array Jenc.float x.svan)
615- , ("Wayao", Jenc.dict identity Jenc.float x.wayao)
615+ , ("Wayao", makeDictEncoder identity Jenc.float x.wayao)
616616 ]
617617
618618 abranchiata : Jdec.Decoder Abranchiata
@@ -641,7 +641,7 @@ encodeAcademe : Academe -> Jenc.Value
641641 encodeAcademe x = case x of
642642 IntegerArrayInAcademe y -> Jenc.array Jenc.int y
643643 IntegerInAcademe y -> Jenc.int y
644- IntegerMapInAcademe y -> Jenc.dict identity Jenc.int y
644+ IntegerMapInAcademe y -> makeDictEncoder identity Jenc.int y
645645
646646 acquirable : Jdec.Decoder Acquirable
647647 acquirable =
@@ -653,7 +653,7 @@ acquirable =
653653 encodeAcquirable : Acquirable -> Jenc.Value
654654 encodeAcquirable x = case x of
655655 UnionArrayInAcquirable y -> Jenc.array (makeNullableEncoder Jenc.int) y
656- IntegerMapInAcquirable y -> Jenc.dict identity Jenc.int y
656+ IntegerMapInAcquirable y -> makeDictEncoder identity Jenc.int y
657657
658658 aerometry : Jdec.Decoder Aerometry
659659 aerometry =
@@ -1034,7 +1034,7 @@ encodeBocking : Bocking -> Jenc.Value
10341034 encodeBocking x = case x of
10351035 IntegerArrayInBocking y -> Jenc.array Jenc.int y
10361036 BoolInBocking y -> Jenc.bool y
1037- IntegerMapInBocking y -> Jenc.dict identity Jenc.int y
1037+ IntegerMapInBocking y -> makeDictEncoder identity Jenc.int y
10381038
10391039 brawlingly : Jdec.Decoder Brawlingly
10401040 brawlingly =
@@ -1046,7 +1046,7 @@ brawlingly =
10461046 encodeBrawlingly : Brawlingly -> Jenc.Value
10471047 encodeBrawlingly x = case x of
10481048 NullArrayInBrawlingly y -> Jenc.array (always Jenc.null) y
1049- UnionMapInBrawlingly y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1049+ UnionMapInBrawlingly y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
10501050
10511051 brookie : Jdec.Decoder Brookie
10521052 brookie =
@@ -1098,7 +1098,7 @@ encodeCatallactic : Catallactic -> Jenc.Value
10981098 encodeCatallactic x = case x of
10991099 NullArrayInCatallactic y -> Jenc.array (always Jenc.null) y
11001100 BoolInCatallactic y -> Jenc.bool y
1101- IntegerMapInCatallactic y -> Jenc.dict identity Jenc.int y
1101+ IntegerMapInCatallactic y -> makeDictEncoder identity Jenc.int y
11021102
11031103 cemental : Jdec.Decoder Cemental
11041104 cemental =
@@ -1112,7 +1112,7 @@ encodeCemental : Cemental -> Jenc.Value
11121112 encodeCemental x = case x of
11131113 IntegerArrayInCemental y -> Jenc.array Jenc.int y
11141114 DoubleInCemental y -> Jenc.float y
1115- IntegerMapInCemental y -> Jenc.dict identity Jenc.int y
1115+ IntegerMapInCemental y -> makeDictEncoder identity Jenc.int y
11161116
11171117 chytridiaceaeElement : Jdec.Decoder ChytridiaceaeElement
11181118 chytridiaceaeElement =
@@ -1284,7 +1284,7 @@ eupatorium =
12841284 encodeEupatorium : Eupatorium -> Jenc.Value
12851285 encodeEupatorium x = case x of
12861286 NullArrayInEupatorium y -> Jenc.array (always Jenc.null) y
1287- IntegerMapInEupatorium y -> Jenc.dict identity Jenc.int y
1287+ IntegerMapInEupatorium y -> makeDictEncoder identity Jenc.int y
12881288
12891289 gryphosaurusElement : Jdec.Decoder GryphosaurusElement
12901290 gryphosaurusElement =
@@ -1359,7 +1359,7 @@ koryak =
13591359 encodeKoryak : Koryak -> Jenc.Value
13601360 encodeKoryak x = case x of
13611361 StringInKoryak y -> Jenc.string y
1362- UnionMapInKoryak y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1362+ UnionMapInKoryak y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
13631363
13641364 laviniaElement : Jdec.Decoder LaviniaElement
13651365 laviniaElement =
@@ -1547,7 +1547,7 @@ encodeSchool : School -> Jenc.Value
15471547 encodeSchool x = case x of
15481548 IntegerInSchool y -> Jenc.int y
15491549 NullInSchool -> Jenc.null
1550- IntegerMapInSchool y -> Jenc.dict identity Jenc.int y
1550+ IntegerMapInSchool y -> makeDictEncoder identity Jenc.int y
15511551
15521552 shakespearolater : Jdec.Decoder Shakespearolater
15531553 shakespearolater =
@@ -1565,6 +1565,14 @@ encodeShakespearolater x = case x of
15651565
15661566 --- encoder helpers
15671567
1568+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1569+makeDictEncoder f m r =
1570+ r
1571+ |> Dict.toList
1572+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1573+ |> String.join ","
1574+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1575+
15681576 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
15691577 makeNullableEncoder f m =
15701578 case m of
Melmdefault / QuickType.elm+20 −12
@@ -578,13 +578,13 @@ encodeQuickType x =
578578 , ("amphithyron", Jenc.list (makeNullableEncoder encodeAmphithyron) x.amphithyron)
579579 , ("Andriana", Jenc.list (makeNullableEncoder Jenc.string) x.andriana)
580580 , ("ankee", Jenc.list encodeAnkeeElement x.ankee)
581- , ("annihilator", Jenc.list (makeNullableEncoder (Jenc.dict identity (makeNullableEncoder Jenc.int))) x.annihilator)
581+ , ("annihilator", Jenc.list (makeNullableEncoder (makeDictEncoder identity (makeNullableEncoder Jenc.int))) x.annihilator)
582582 , ("annulose", always Jenc.null x.annulose)
583583 , ("Ansarie", Jenc.list encodeAnsarieElement x.ansarie)
584584 , ("aphasia", Jenc.list encodeAphasia x.aphasia)
585585 , ("asprawl", Jenc.list encodeAsprawl x.asprawl)
586586 , ("attractive", Jenc.list (makeNullableEncoder Jenc.bool) x.attractive)
587- , ("barksome", Jenc.dict identity Jenc.int x.barksome)
587+ , ("barksome", makeDictEncoder identity Jenc.int x.barksome)
588588 , ("bedesman", Jenc.list encodeBedesman x.bedesman)
589589 , ("belard", Jenc.list encodeBelard x.belard)
590590 , ("bocking", Jenc.list encodeBocking x.bocking)
@@ -611,7 +611,7 @@ encodeQuickType x =
611611 , ("School", Jenc.list encodeSchool x.school)
612612 , ("Shakespearolater", Jenc.list encodeShakespearolater x.shakespearolater)
613613 , ("Svan", Jenc.list Jenc.float x.svan)
614- , ("Wayao", Jenc.dict identity Jenc.float x.wayao)
614+ , ("Wayao", makeDictEncoder identity Jenc.float x.wayao)
615615 ]
616616
617617 abranchiata : Jdec.Decoder Abranchiata
@@ -640,7 +640,7 @@ encodeAcademe : Academe -> Jenc.Value
640640 encodeAcademe x = case x of
641641 IntegerArrayInAcademe y -> Jenc.list Jenc.int y
642642 IntegerInAcademe y -> Jenc.int y
643- IntegerMapInAcademe y -> Jenc.dict identity Jenc.int y
643+ IntegerMapInAcademe y -> makeDictEncoder identity Jenc.int y
644644
645645 acquirable : Jdec.Decoder Acquirable
646646 acquirable =
@@ -652,7 +652,7 @@ acquirable =
652652 encodeAcquirable : Acquirable -> Jenc.Value
653653 encodeAcquirable x = case x of
654654 UnionArrayInAcquirable y -> Jenc.list (makeNullableEncoder Jenc.int) y
655- IntegerMapInAcquirable y -> Jenc.dict identity Jenc.int y
655+ IntegerMapInAcquirable y -> makeDictEncoder identity Jenc.int y
656656
657657 aerometry : Jdec.Decoder Aerometry
658658 aerometry =
@@ -1033,7 +1033,7 @@ encodeBocking : Bocking -> Jenc.Value
10331033 encodeBocking x = case x of
10341034 IntegerArrayInBocking y -> Jenc.list Jenc.int y
10351035 BoolInBocking y -> Jenc.bool y
1036- IntegerMapInBocking y -> Jenc.dict identity Jenc.int y
1036+ IntegerMapInBocking y -> makeDictEncoder identity Jenc.int y
10371037
10381038 brawlingly : Jdec.Decoder Brawlingly
10391039 brawlingly =
@@ -1045,7 +1045,7 @@ brawlingly =
10451045 encodeBrawlingly : Brawlingly -> Jenc.Value
10461046 encodeBrawlingly x = case x of
10471047 NullArrayInBrawlingly y -> Jenc.list (always Jenc.null) y
1048- UnionMapInBrawlingly y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1048+ UnionMapInBrawlingly y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
10491049
10501050 brookie : Jdec.Decoder Brookie
10511051 brookie =
@@ -1097,7 +1097,7 @@ encodeCatallactic : Catallactic -> Jenc.Value
10971097 encodeCatallactic x = case x of
10981098 NullArrayInCatallactic y -> Jenc.list (always Jenc.null) y
10991099 BoolInCatallactic y -> Jenc.bool y
1100- IntegerMapInCatallactic y -> Jenc.dict identity Jenc.int y
1100+ IntegerMapInCatallactic y -> makeDictEncoder identity Jenc.int y
11011101
11021102 cemental : Jdec.Decoder Cemental
11031103 cemental =
@@ -1111,7 +1111,7 @@ encodeCemental : Cemental -> Jenc.Value
11111111 encodeCemental x = case x of
11121112 IntegerArrayInCemental y -> Jenc.list Jenc.int y
11131113 DoubleInCemental y -> Jenc.float y
1114- IntegerMapInCemental y -> Jenc.dict identity Jenc.int y
1114+ IntegerMapInCemental y -> makeDictEncoder identity Jenc.int y
11151115
11161116 chytridiaceaeElement : Jdec.Decoder ChytridiaceaeElement
11171117 chytridiaceaeElement =
@@ -1283,7 +1283,7 @@ eupatorium =
12831283 encodeEupatorium : Eupatorium -> Jenc.Value
12841284 encodeEupatorium x = case x of
12851285 NullArrayInEupatorium y -> Jenc.list (always Jenc.null) y
1286- IntegerMapInEupatorium y -> Jenc.dict identity Jenc.int y
1286+ IntegerMapInEupatorium y -> makeDictEncoder identity Jenc.int y
12871287
12881288 gryphosaurusElement : Jdec.Decoder GryphosaurusElement
12891289 gryphosaurusElement =
@@ -1358,7 +1358,7 @@ koryak =
13581358 encodeKoryak : Koryak -> Jenc.Value
13591359 encodeKoryak x = case x of
13601360 StringInKoryak y -> Jenc.string y
1361- UnionMapInKoryak y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1361+ UnionMapInKoryak y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
13621362
13631363 laviniaElement : Jdec.Decoder LaviniaElement
13641364 laviniaElement =
@@ -1546,7 +1546,7 @@ encodeSchool : School -> Jenc.Value
15461546 encodeSchool x = case x of
15471547 IntegerInSchool y -> Jenc.int y
15481548 NullInSchool -> Jenc.null
1549- IntegerMapInSchool y -> Jenc.dict identity Jenc.int y
1549+ IntegerMapInSchool y -> makeDictEncoder identity Jenc.int y
15501550
15511551 shakespearolater : Jdec.Decoder Shakespearolater
15521552 shakespearolater =
@@ -1564,6 +1564,14 @@ encodeShakespearolater x = case x of
15641564
15651565 --- encoder helpers
15661566
1567+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1568+makeDictEncoder f m r =
1569+ r
1570+ |> Dict.toList
1571+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1572+ |> String.join ","
1573+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1574+
15671575 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
15681576 makeNullableEncoder f m =
15691577 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mflownice-property-names-true--f4d7920ee2ce / TopLevel.js+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mflowprefer-unions-false--a5053c0a486d / TopLevel.js+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mflowprefer-unknown-false--f1ab9e45d823 / TopLevel.js+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mflowruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.js+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = val[key];
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mjavascriptconverters-top-level--67aa452ed509 / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptraw-type-any--474b307c39db / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = val[key];
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptacronym-style-pascal--d9e0c1bd777a / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mtypescriptconverters-all-objects--3a443babd1cb / TopLevel.ts+2 −2
@@ -531,7 +531,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
531531 if (val === null || typeof val !== "object" || Array.isArray(val)) {
532532 return invalidValue(l(ref || "object"), val, key, parent);
533533 }
534- const result: any = {};
534+ const result: any = Object.create(null);
535535 Object.getOwnPropertyNames(props).forEach(key => {
536536 const prop = props[key];
537537 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -542,7 +542,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
542542 result[key] = transform(val[key], additional, getProps, key, ref);
543543 }
544544 });
545- return result;
545+ return Object.setPrototypeOf(result, Object.prototype);
546546 }
547547
548548 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mtypescriptnice-property-names-true--f4d7920ee2ce / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mtypescriptprefer-const-values-true--6b26e4d1265c / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mtypescriptprefer-types-true--df33e18681f9 / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mtypescriptprefer-unions-false--a5053c0a486d / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mtypescriptprefer-unknown-false--f1ab9e45d823 / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mtypescriptraw-type-any--474b307c39db / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mtypescriptreadonly-true--24da4fc107df / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = transform(val[key], additional, getProps, key, ref);
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Mtypescriptruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.ts+2 −2
@@ -451,7 +451,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
451451 if (val === null || typeof val !== "object" || Array.isArray(val)) {
452452 return invalidValue(l(ref || "object"), val, key, parent);
453453 }
454- const result: any = {};
454+ const result: any = Object.create(null);
455455 Object.getOwnPropertyNames(props).forEach(key => {
456456 const prop = props[key];
457457 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -462,7 +462,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
462462 result[key] = val[key];
463463 }
464464 });
465- return result;
465+ return Object.setPrototypeOf(result, Object.prototype);
466466 }
467467
468468 if (typ === "any") return val;
Test case

test/inputs/json/priority/combinations3.json

22 generated files · +70 −54
Melmarray-type-array--eed288b23e27 / QuickType.elm+15 −7
@@ -714,7 +714,7 @@ encodeQuickType x =
714714 , ("prefreshman", Jenc.array encodePrefreshmanElement x.prefreshman)
715715 , ("prehensility", Jenc.array encodePrehensility x.prehensility)
716716 , ("prevoidance", Jenc.array encodePrevoidance x.prevoidance)
717- , ("probant", Jenc.array (Jenc.dict identity (makeNullableEncoder Jenc.int)) x.probant)
717+ , ("probant", Jenc.array (makeDictEncoder identity (makeNullableEncoder Jenc.int)) x.probant)
718718 , ("protext", Jenc.array encodeProtext x.protext)
719719 ]
720720
@@ -789,7 +789,7 @@ kongoni =
789789 encodeKongoni : Kongoni -> Jenc.Value
790790 encodeKongoni x = case x of
791791 IntegerArrayInKongoni y -> Jenc.array Jenc.int y
792- IntegerMapInKongoni y -> Jenc.dict identity Jenc.int y
792+ IntegerMapInKongoni y -> makeDictEncoder identity Jenc.int y
793793
794794 ladronismElement : Jdec.Decoder LadronismElement
795795 ladronismElement =
@@ -1462,7 +1462,7 @@ paleographically =
14621462 encodePaleographically : Paleographically -> Jenc.Value
14631463 encodePaleographically x = case x of
14641464 DoubleInPaleographically y -> Jenc.float y
1465- UnionMapInPaleographically y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1465+ UnionMapInPaleographically y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
14661466
14671467 pamphletwise : Jdec.Decoder Pamphletwise
14681468 pamphletwise =
@@ -1476,7 +1476,7 @@ encodePamphletwise : Pamphletwise -> Jenc.Value
14761476 encodePamphletwise x = case x of
14771477 IntegerInPamphletwise y -> Jenc.int y
14781478 StringInPamphletwise y -> Jenc.string y
1479- IntegerMapInPamphletwise y -> Jenc.dict identity Jenc.int y
1479+ IntegerMapInPamphletwise y -> makeDictEncoder identity Jenc.int y
14801480
14811481 pediatric : Jdec.Decoder Pediatric
14821482 pediatric =
@@ -1613,7 +1613,7 @@ placuntiti =
16131613 encodePlacuntiti : Placuntiti -> Jenc.Value
16141614 encodePlacuntiti x = case x of
16151615 IntegerInPlacuntiti y -> Jenc.int y
1616- IntegerMapInPlacuntiti y -> Jenc.dict identity Jenc.int y
1616+ IntegerMapInPlacuntiti y -> makeDictEncoder identity Jenc.int y
16171617
16181618 plectopterous : Jdec.Decoder Plectopterous
16191619 plectopterous =
@@ -1625,7 +1625,7 @@ plectopterous =
16251625 encodePlectopterous : Plectopterous -> Jenc.Value
16261626 encodePlectopterous x = case x of
16271627 DoubleInPlectopterous y -> Jenc.float y
1628- IntegerMapInPlectopterous y -> Jenc.dict identity Jenc.int y
1628+ IntegerMapInPlectopterous y -> makeDictEncoder identity Jenc.int y
16291629
16301630 pneumocele : Jdec.Decoder Pneumocele
16311631 pneumocele =
@@ -1710,7 +1710,7 @@ encodePoormaster : Poormaster -> Jenc.Value
17101710 encodePoormaster x = case x of
17111711 IntegerArrayInPoormaster y -> Jenc.array Jenc.int y
17121712 NullInPoormaster -> Jenc.null
1713- IntegerMapInPoormaster y -> Jenc.dict identity Jenc.int y
1713+ IntegerMapInPoormaster y -> makeDictEncoder identity Jenc.int y
17141714
17151715 potwhiskyElement : Jdec.Decoder PotwhiskyElement
17161716 potwhiskyElement =
@@ -1896,6 +1896,14 @@ encodeProtext x = case x of
18961896
18971897 --- encoder helpers
18981898
1899+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1900+makeDictEncoder f m r =
1901+ r
1902+ |> Dict.toList
1903+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1904+ |> String.join ","
1905+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1906+
18991907 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
19001908 makeNullableEncoder f m =
19011909 case m of
Melmdefault / QuickType.elm+15 −7
@@ -713,7 +713,7 @@ encodeQuickType x =
713713 , ("prefreshman", Jenc.list encodePrefreshmanElement x.prefreshman)
714714 , ("prehensility", Jenc.list encodePrehensility x.prehensility)
715715 , ("prevoidance", Jenc.list encodePrevoidance x.prevoidance)
716- , ("probant", Jenc.list (Jenc.dict identity (makeNullableEncoder Jenc.int)) x.probant)
716+ , ("probant", Jenc.list (makeDictEncoder identity (makeNullableEncoder Jenc.int)) x.probant)
717717 , ("protext", Jenc.list encodeProtext x.protext)
718718 ]
719719
@@ -788,7 +788,7 @@ kongoni =
788788 encodeKongoni : Kongoni -> Jenc.Value
789789 encodeKongoni x = case x of
790790 IntegerArrayInKongoni y -> Jenc.list Jenc.int y
791- IntegerMapInKongoni y -> Jenc.dict identity Jenc.int y
791+ IntegerMapInKongoni y -> makeDictEncoder identity Jenc.int y
792792
793793 ladronismElement : Jdec.Decoder LadronismElement
794794 ladronismElement =
@@ -1461,7 +1461,7 @@ paleographically =
14611461 encodePaleographically : Paleographically -> Jenc.Value
14621462 encodePaleographically x = case x of
14631463 DoubleInPaleographically y -> Jenc.float y
1464- UnionMapInPaleographically y -> Jenc.dict identity (makeNullableEncoder Jenc.int) y
1464+ UnionMapInPaleographically y -> makeDictEncoder identity (makeNullableEncoder Jenc.int) y
14651465
14661466 pamphletwise : Jdec.Decoder Pamphletwise
14671467 pamphletwise =
@@ -1475,7 +1475,7 @@ encodePamphletwise : Pamphletwise -> Jenc.Value
14751475 encodePamphletwise x = case x of
14761476 IntegerInPamphletwise y -> Jenc.int y
14771477 StringInPamphletwise y -> Jenc.string y
1478- IntegerMapInPamphletwise y -> Jenc.dict identity Jenc.int y
1478+ IntegerMapInPamphletwise y -> makeDictEncoder identity Jenc.int y
14791479
14801480 pediatric : Jdec.Decoder Pediatric
14811481 pediatric =
@@ -1612,7 +1612,7 @@ placuntiti =
16121612 encodePlacuntiti : Placuntiti -> Jenc.Value
16131613 encodePlacuntiti x = case x of
16141614 IntegerInPlacuntiti y -> Jenc.int y
1615- IntegerMapInPlacuntiti y -> Jenc.dict identity Jenc.int y
1615+ IntegerMapInPlacuntiti y -> makeDictEncoder identity Jenc.int y
16161616
16171617 plectopterous : Jdec.Decoder Plectopterous
16181618 plectopterous =
@@ -1624,7 +1624,7 @@ plectopterous =
16241624 encodePlectopterous : Plectopterous -> Jenc.Value
16251625 encodePlectopterous x = case x of
16261626 DoubleInPlectopterous y -> Jenc.float y
1627- IntegerMapInPlectopterous y -> Jenc.dict identity Jenc.int y
1627+ IntegerMapInPlectopterous y -> makeDictEncoder identity Jenc.int y
16281628
16291629 pneumocele : Jdec.Decoder Pneumocele
16301630 pneumocele =
@@ -1709,7 +1709,7 @@ encodePoormaster : Poormaster -> Jenc.Value
17091709 encodePoormaster x = case x of
17101710 IntegerArrayInPoormaster y -> Jenc.list Jenc.int y
17111711 NullInPoormaster -> Jenc.null
1712- IntegerMapInPoormaster y -> Jenc.dict identity Jenc.int y
1712+ IntegerMapInPoormaster y -> makeDictEncoder identity Jenc.int y
17131713
17141714 potwhiskyElement : Jdec.Decoder PotwhiskyElement
17151715 potwhiskyElement =
@@ -1895,6 +1895,14 @@ encodeProtext x = case x of
18951895
18961896 --- encoder helpers
18971897
1898+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1899+makeDictEncoder f m r =
1900+ r
1901+ |> Dict.toList
1902+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1903+ |> String.join ","
1904+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1905+
18981906 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
18991907 makeNullableEncoder f m =
19001908 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mflownice-property-names-true--f4d7920ee2ce / TopLevel.js+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mflowprefer-unions-false--a5053c0a486d / TopLevel.js+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mflowprefer-unknown-false--f1ab9e45d823 / TopLevel.js+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mflowruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.js+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = val[key];
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mjavascriptconverters-top-level--67aa452ed509 / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptraw-type-any--474b307c39db / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = val[key];
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptacronym-style-pascal--d9e0c1bd777a / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mtypescriptconverters-all-objects--3a443babd1cb / TopLevel.ts+2 −2
@@ -667,7 +667,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
667667 if (val === null || typeof val !== "object" || Array.isArray(val)) {
668668 return invalidValue(l(ref || "object"), val, key, parent);
669669 }
670- const result: any = {};
670+ const result: any = Object.create(null);
671671 Object.getOwnPropertyNames(props).forEach(key => {
672672 const prop = props[key];
673673 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -678,7 +678,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
678678 result[key] = transform(val[key], additional, getProps, key, ref);
679679 }
680680 });
681- return result;
681+ return Object.setPrototypeOf(result, Object.prototype);
682682 }
683683
684684 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mtypescriptnice-property-names-true--f4d7920ee2ce / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mtypescriptprefer-const-values-true--6b26e4d1265c / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mtypescriptprefer-types-true--df33e18681f9 / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mtypescriptprefer-unions-false--a5053c0a486d / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mtypescriptprefer-unknown-false--f1ab9e45d823 / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mtypescriptraw-type-any--474b307c39db / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mtypescriptreadonly-true--24da4fc107df / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = transform(val[key], additional, getProps, key, ref);
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Mtypescriptruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.ts+2 −2
@@ -555,7 +555,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
555555 if (val === null || typeof val !== "object" || Array.isArray(val)) {
556556 return invalidValue(l(ref || "object"), val, key, parent);
557557 }
558- const result: any = {};
558+ const result: any = Object.create(null);
559559 Object.getOwnPropertyNames(props).forEach(key => {
560560 const prop = props[key];
561561 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -566,7 +566,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
566566 result[key] = val[key];
567567 }
568568 });
569- return result;
569+ return Object.setPrototypeOf(result, Object.prototype);
570570 }
571571
572572 if (typ === "any") return val;
Test case

test/inputs/json/priority/combinations4.json

22 generated files · +78 −62
Melmarray-type-array--eed288b23e27 / QuickType.elm+19 −11
@@ -830,7 +830,7 @@ encodeQuickType x =
830830 , ("untasked", Jenc.array encodeUntasked x.untasked)
831831 , ("unvarying", Jenc.array encodeUnvarying x.unvarying)
832832 , ("vehemently", Jenc.array encodeVehemently x.vehemently)
833- , ("warriorship", Jenc.dict identity Jenc.bool x.warriorship)
833+ , ("warriorship", makeDictEncoder identity Jenc.bool x.warriorship)
834834 , ("whitepot", Jenc.array encodeWhitepot x.whitepot)
835835 , ("wrothy", Jenc.array encodeWrothyElement x.wrothy)
836836 ]
@@ -1014,7 +1014,7 @@ querier =
10141014 encodeQuerier : Querier -> Jenc.Value
10151015 encodeQuerier x = case x of
10161016 BoolInQuerier y -> Jenc.bool y
1017- IntegerMapInQuerier y -> Jenc.dict identity Jenc.int y
1017+ IntegerMapInQuerier y -> makeDictEncoder identity Jenc.int y
10181018
10191019 rebarbative : Jdec.Decoder Rebarbative
10201020 rebarbative =
@@ -1312,7 +1312,7 @@ encodeSaprophilous : Saprophilous -> Jenc.Value
13121312 encodeSaprophilous x = case x of
13131313 NullInSaprophilous -> Jenc.null
13141314 StringInSaprophilous y -> Jenc.string y
1315- IntegerMapInSaprophilous y -> Jenc.dict identity Jenc.int y
1315+ IntegerMapInSaprophilous y -> makeDictEncoder identity Jenc.int y
13161316
13171317 saxtenElement : Jdec.Decoder SaxtenElement
13181318 saxtenElement =
@@ -1446,7 +1446,7 @@ encodeScoffer : Scoffer -> Jenc.Value
14461446 encodeScoffer x = case x of
14471447 NullArrayInScoffer y -> Jenc.array (always Jenc.null) y
14481448 NullInScoffer -> Jenc.null
1449- IntegerMapInScoffer y -> Jenc.dict identity Jenc.int y
1449+ IntegerMapInScoffer y -> makeDictEncoder identity Jenc.int y
14501450
14511451 scrampum : Jdec.Decoder Scrampum
14521452 scrampum =
@@ -1632,7 +1632,7 @@ encodeStimulability : Stimulability -> Jenc.Value
16321632 encodeStimulability x = case x of
16331633 BoolInStimulability y -> Jenc.bool y
16341634 IntegerInStimulability y -> Jenc.int y
1635- IntegerMapInStimulability y -> Jenc.dict identity Jenc.int y
1635+ IntegerMapInStimulability y -> makeDictEncoder identity Jenc.int y
16361636
16371637 strangleable : Jdec.Decoder Strangleable
16381638 strangleable =
@@ -1852,7 +1852,7 @@ encodeUnbeginning : Unbeginning -> Jenc.Value
18521852 encodeUnbeginning x = case x of
18531853 NullArrayInUnbeginning y -> Jenc.array (always Jenc.null) y
18541854 StringInUnbeginning y -> Jenc.string y
1855- IntegerMapInUnbeginning y -> Jenc.dict identity Jenc.int y
1855+ IntegerMapInUnbeginning y -> makeDictEncoder identity Jenc.int y
18561856
18571857 undesirability : Jdec.Decoder Undesirability
18581858 undesirability =
@@ -1866,7 +1866,7 @@ encodeUndesirability : Undesirability -> Jenc.Value
18661866 encodeUndesirability x = case x of
18671867 IntegerArrayInUndesirability y -> Jenc.array Jenc.int y
18681868 StringInUndesirability y -> Jenc.string y
1869- IntegerMapInUndesirability y -> Jenc.dict identity Jenc.int y
1869+ IntegerMapInUndesirability y -> makeDictEncoder identity Jenc.int y
18701870
18711871 unerasing : Jdec.Decoder Unerasing
18721872 unerasing =
@@ -1880,7 +1880,7 @@ encodeUnerasing : Unerasing -> Jenc.Value
18801880 encodeUnerasing x = case x of
18811881 NullArrayInUnerasing y -> Jenc.array (always Jenc.null) y
18821882 IntegerInUnerasing y -> Jenc.int y
1883- IntegerMapInUnerasing y -> Jenc.dict identity Jenc.int y
1883+ IntegerMapInUnerasing y -> makeDictEncoder identity Jenc.int y
18841884
18851885 unguentarium : Jdec.Decoder Unguentarium
18861886 unguentarium =
@@ -1979,7 +1979,7 @@ encodeUnmortgaged : Unmortgaged -> Jenc.Value
19791979 encodeUnmortgaged x = case x of
19801980 NullInUnmortgaged -> Jenc.null
19811981 DoubleInUnmortgaged y -> Jenc.float y
1982- IntegerMapInUnmortgaged y -> Jenc.dict identity Jenc.int y
1982+ IntegerMapInUnmortgaged y -> makeDictEncoder identity Jenc.int y
19831983
19841984 unobstructed : Jdec.Decoder Unobstructed
19851985 unobstructed =
@@ -2098,7 +2098,7 @@ encodeUntasked : Untasked -> Jenc.Value
20982098 encodeUntasked x = case x of
20992099 NullArrayInUntasked y -> Jenc.array (always Jenc.null) y
21002100 DoubleInUntasked y -> Jenc.float y
2101- IntegerMapInUntasked y -> Jenc.dict identity Jenc.int y
2101+ IntegerMapInUntasked y -> makeDictEncoder identity Jenc.int y
21022102
21032103 unvarying : Jdec.Decoder Unvarying
21042104 unvarying =
@@ -2112,7 +2112,7 @@ encodeUnvarying : Unvarying -> Jenc.Value
21122112 encodeUnvarying x = case x of
21132113 BoolInUnvarying y -> Jenc.bool y
21142114 DoubleInUnvarying y -> Jenc.float y
2115- IntegerMapInUnvarying y -> Jenc.dict identity Jenc.int y
2115+ IntegerMapInUnvarying y -> makeDictEncoder identity Jenc.int y
21162116
21172117 vehemently : Jdec.Decoder Vehemently
21182118 vehemently =
@@ -2203,6 +2203,14 @@ encodeWrothyClass x =
22032203
22042204 --- encoder helpers
22052205
2206+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
2207+makeDictEncoder f m r =
2208+ r
2209+ |> Dict.toList
2210+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
2211+ |> String.join ","
2212+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
2213+
22062214 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
22072215 makeNullableEncoder f m =
22082216 case m of
Melmdefault / QuickType.elm+19 −11
@@ -829,7 +829,7 @@ encodeQuickType x =
829829 , ("untasked", Jenc.list encodeUntasked x.untasked)
830830 , ("unvarying", Jenc.list encodeUnvarying x.unvarying)
831831 , ("vehemently", Jenc.list encodeVehemently x.vehemently)
832- , ("warriorship", Jenc.dict identity Jenc.bool x.warriorship)
832+ , ("warriorship", makeDictEncoder identity Jenc.bool x.warriorship)
833833 , ("whitepot", Jenc.list encodeWhitepot x.whitepot)
834834 , ("wrothy", Jenc.list encodeWrothyElement x.wrothy)
835835 ]
@@ -1013,7 +1013,7 @@ querier =
10131013 encodeQuerier : Querier -> Jenc.Value
10141014 encodeQuerier x = case x of
10151015 BoolInQuerier y -> Jenc.bool y
1016- IntegerMapInQuerier y -> Jenc.dict identity Jenc.int y
1016+ IntegerMapInQuerier y -> makeDictEncoder identity Jenc.int y
10171017
10181018 rebarbative : Jdec.Decoder Rebarbative
10191019 rebarbative =
@@ -1311,7 +1311,7 @@ encodeSaprophilous : Saprophilous -> Jenc.Value
13111311 encodeSaprophilous x = case x of
13121312 NullInSaprophilous -> Jenc.null
13131313 StringInSaprophilous y -> Jenc.string y
1314- IntegerMapInSaprophilous y -> Jenc.dict identity Jenc.int y
1314+ IntegerMapInSaprophilous y -> makeDictEncoder identity Jenc.int y
13151315
13161316 saxtenElement : Jdec.Decoder SaxtenElement
13171317 saxtenElement =
@@ -1445,7 +1445,7 @@ encodeScoffer : Scoffer -> Jenc.Value
14451445 encodeScoffer x = case x of
14461446 NullArrayInScoffer y -> Jenc.list (always Jenc.null) y
14471447 NullInScoffer -> Jenc.null
1448- IntegerMapInScoffer y -> Jenc.dict identity Jenc.int y
1448+ IntegerMapInScoffer y -> makeDictEncoder identity Jenc.int y
14491449
14501450 scrampum : Jdec.Decoder Scrampum
14511451 scrampum =
@@ -1631,7 +1631,7 @@ encodeStimulability : Stimulability -> Jenc.Value
16311631 encodeStimulability x = case x of
16321632 BoolInStimulability y -> Jenc.bool y
16331633 IntegerInStimulability y -> Jenc.int y
1634- IntegerMapInStimulability y -> Jenc.dict identity Jenc.int y
1634+ IntegerMapInStimulability y -> makeDictEncoder identity Jenc.int y
16351635
16361636 strangleable : Jdec.Decoder Strangleable
16371637 strangleable =
@@ -1851,7 +1851,7 @@ encodeUnbeginning : Unbeginning -> Jenc.Value
18511851 encodeUnbeginning x = case x of
18521852 NullArrayInUnbeginning y -> Jenc.list (always Jenc.null) y
18531853 StringInUnbeginning y -> Jenc.string y
1854- IntegerMapInUnbeginning y -> Jenc.dict identity Jenc.int y
1854+ IntegerMapInUnbeginning y -> makeDictEncoder identity Jenc.int y
18551855
18561856 undesirability : Jdec.Decoder Undesirability
18571857 undesirability =
@@ -1865,7 +1865,7 @@ encodeUndesirability : Undesirability -> Jenc.Value
18651865 encodeUndesirability x = case x of
18661866 IntegerArrayInUndesirability y -> Jenc.list Jenc.int y
18671867 StringInUndesirability y -> Jenc.string y
1868- IntegerMapInUndesirability y -> Jenc.dict identity Jenc.int y
1868+ IntegerMapInUndesirability y -> makeDictEncoder identity Jenc.int y
18691869
18701870 unerasing : Jdec.Decoder Unerasing
18711871 unerasing =
@@ -1879,7 +1879,7 @@ encodeUnerasing : Unerasing -> Jenc.Value
18791879 encodeUnerasing x = case x of
18801880 NullArrayInUnerasing y -> Jenc.list (always Jenc.null) y
18811881 IntegerInUnerasing y -> Jenc.int y
1882- IntegerMapInUnerasing y -> Jenc.dict identity Jenc.int y
1882+ IntegerMapInUnerasing y -> makeDictEncoder identity Jenc.int y
18831883
18841884 unguentarium : Jdec.Decoder Unguentarium
18851885 unguentarium =
@@ -1978,7 +1978,7 @@ encodeUnmortgaged : Unmortgaged -> Jenc.Value
19781978 encodeUnmortgaged x = case x of
19791979 NullInUnmortgaged -> Jenc.null
19801980 DoubleInUnmortgaged y -> Jenc.float y
1981- IntegerMapInUnmortgaged y -> Jenc.dict identity Jenc.int y
1981+ IntegerMapInUnmortgaged y -> makeDictEncoder identity Jenc.int y
19821982
19831983 unobstructed : Jdec.Decoder Unobstructed
19841984 unobstructed =
@@ -2097,7 +2097,7 @@ encodeUntasked : Untasked -> Jenc.Value
20972097 encodeUntasked x = case x of
20982098 NullArrayInUntasked y -> Jenc.list (always Jenc.null) y
20992099 DoubleInUntasked y -> Jenc.float y
2100- IntegerMapInUntasked y -> Jenc.dict identity Jenc.int y
2100+ IntegerMapInUntasked y -> makeDictEncoder identity Jenc.int y
21012101
21022102 unvarying : Jdec.Decoder Unvarying
21032103 unvarying =
@@ -2111,7 +2111,7 @@ encodeUnvarying : Unvarying -> Jenc.Value
21112111 encodeUnvarying x = case x of
21122112 BoolInUnvarying y -> Jenc.bool y
21132113 DoubleInUnvarying y -> Jenc.float y
2114- IntegerMapInUnvarying y -> Jenc.dict identity Jenc.int y
2114+ IntegerMapInUnvarying y -> makeDictEncoder identity Jenc.int y
21152115
21162116 vehemently : Jdec.Decoder Vehemently
21172117 vehemently =
@@ -2202,6 +2202,14 @@ encodeWrothyClass x =
22022202
22032203 --- encoder helpers
22042204
2205+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
2206+makeDictEncoder f m r =
2207+ r
2208+ |> Dict.toList
2209+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
2210+ |> String.join ","
2211+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
2212+
22052213 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
22062214 makeNullableEncoder f m =
22072215 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mflownice-property-names-true--f4d7920ee2ce / TopLevel.js+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mflowprefer-unions-false--a5053c0a486d / TopLevel.js+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mflowprefer-unknown-false--f1ab9e45d823 / TopLevel.js+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mflowruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.js+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = val[key];
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mjavascriptconverters-top-level--67aa452ed509 / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptraw-type-any--474b307c39db / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = val[key];
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptacronym-style-pascal--d9e0c1bd777a / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mtypescriptconverters-all-objects--3a443babd1cb / TopLevel.ts+2 −2
@@ -753,7 +753,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
753753 if (val === null || typeof val !== "object" || Array.isArray(val)) {
754754 return invalidValue(l(ref || "object"), val, key, parent);
755755 }
756- const result: any = {};
756+ const result: any = Object.create(null);
757757 Object.getOwnPropertyNames(props).forEach(key => {
758758 const prop = props[key];
759759 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -764,7 +764,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
764764 result[key] = transform(val[key], additional, getProps, key, ref);
765765 }
766766 });
767- return result;
767+ return Object.setPrototypeOf(result, Object.prototype);
768768 }
769769
770770 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mtypescriptnice-property-names-true--f4d7920ee2ce / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mtypescriptprefer-const-values-true--6b26e4d1265c / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mtypescriptprefer-types-true--df33e18681f9 / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mtypescriptprefer-unions-false--a5053c0a486d / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mtypescriptprefer-unknown-false--f1ab9e45d823 / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mtypescriptraw-type-any--474b307c39db / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mtypescriptreadonly-true--24da4fc107df / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = transform(val[key], additional, getProps, key, ref);
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Mtypescriptruntime-typecheck-ignore-unknown-properties-true--d792c40f022e / TopLevel.ts+2 −2
@@ -625,7 +625,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
625625 if (val === null || typeof val !== "object" || Array.isArray(val)) {
626626 return invalidValue(l(ref || "object"), val, key, parent);
627627 }
628- const result: any = {};
628+ const result: any = Object.create(null);
629629 Object.getOwnPropertyNames(props).forEach(key => {
630630 const prop = props[key];
631631 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -636,7 +636,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
636636 result[key] = val[key];
637637 }
638638 });
639- return result;
639+ return Object.setPrototypeOf(result, Object.prototype);
640640 }
641641
642642 if (typ === "any") return val;
Test case

test/inputs/json/priority/combined-enum.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -92,6 +92,14 @@ encodeX x = case x of
9292
9393 --- encoder helpers
9494
95+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
96+makeDictEncoder f m r =
97+ r
98+ |> Dict.toList
99+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
100+ |> String.join ","
101+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
102+
95103 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
96104 makeNullableEncoder f m =
97105 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/json/priority/direct-recursive.json

3 generated files · +6 −6
Mflowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/priority/empty-enum.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -66,6 +66,14 @@ encodeFoo x =
6666
6767 --- encoder helpers
6868
69+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
70+makeDictEncoder f m r =
71+ r
72+ |> Dict.toList
73+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
74+ |> String.join ","
75+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
76+
6977 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7078 makeNullableEncoder f m =
7179 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/priority/identifiers.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -169,6 +169,14 @@ encodeThisIsAToughOne x =
169169
170170 --- encoder helpers
171171
172+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
173+makeDictEncoder f m r =
174+ r
175+ |> Dict.toList
176+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
177+ |> String.join ","
178+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
179+
172180 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
173181 makeNullableEncoder f m =
174182 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -138,7 +138,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
138138 if (val === null || typeof val !== "object" || Array.isArray(val)) {
139139 return invalidValue(l(ref || "object"), val, key, parent);
140140 }
141- const result: any = {};
141+ const result: any = Object.create(null);
142142 Object.getOwnPropertyNames(props).forEach(key => {
143143 const prop = props[key];
144144 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -149,7 +149,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
149149 result[key] = transform(val[key], additional, getProps, key, ref);
150150 }
151151 });
152- return result;
152+ return Object.setPrototypeOf(result, Object.prototype);
153153 }
154154
155155 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 if (val === null || typeof val !== "object" || Array.isArray(val)) {
136136 return invalidValue(l(ref || "object"), val, key, parent);
137137 }
138- const result: any = {};
138+ const result: any = Object.create(null);
139139 Object.getOwnPropertyNames(props).forEach(key => {
140140 const prop = props[key];
141141 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 result[key] = transform(val[key], additional, getProps, key, ref);
147147 }
148148 });
149- return result;
149+ return Object.setPrototypeOf(result, Object.prototype);
150150 }
151151
152152 if (typ === "any") return val;
Test case

test/inputs/json/priority/issue2680-object-array.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -56,6 +56,14 @@ encodeQuickTypeElement x =
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/priority/issue2680-scalar-array.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -40,6 +40,14 @@ quickTypeToString r = Jenc.encode 0 (Jenc.list Jenc.int r)
4040
4141 --- encoder helpers
4242
43+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
44+makeDictEncoder f m r =
45+ r
46+ |> Dict.toList
47+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
48+ |> String.join ","
49+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
50+
4351 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
4452 makeNullableEncoder f m =
4553 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Test case

test/inputs/json/priority/keywords.json

5 generated files · +16 −8
Melmdefault / QuickType.elm+8 −0
@@ -6606,6 +6606,14 @@ encodeYield x =
66066606
66076607 --- encoder helpers
66086608
6609+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
6610+makeDictEncoder f m r =
6611+ r
6612+ |> Dict.toList
6613+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
6614+ |> String.join ","
6615+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
6616+
66096617 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
66106618 makeNullableEncoder f m =
66116619 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -1831,7 +1831,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
18311831 if (val === null || typeof val !== "object" || Array.isArray(val)) {
18321832 return invalidValue(l(ref || "object"), val, key, parent);
18331833 }
1834- const result: any = {};
1834+ const result: any = Object.create(null);
18351835 Object.getOwnPropertyNames(props).forEach(key => {
18361836 const prop = props[key];
18371837 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -1842,7 +1842,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
18421842 result[key] = transform(val[key], additional, getProps, key, ref);
18431843 }
18441844 });
1845- return result;
1845+ return Object.setPrototypeOf(result, Object.prototype);
18461846 }
18471847
18481848 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -1829,7 +1829,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
18291829 if (val === null || typeof val !== "object" || Array.isArray(val)) {
18301830 return invalidValue(l(ref || "object"), val, key, parent);
18311831 }
1832- const result: any = {};
1832+ const result: any = Object.create(null);
18331833 Object.getOwnPropertyNames(props).forEach(key => {
18341834 const prop = props[key];
18351835 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -1840,7 +1840,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
18401840 result[key] = transform(val[key], additional, getProps, key, ref);
18411841 }
18421842 });
1843- return result;
1843+ return Object.setPrototypeOf(result, Object.prototype);
18441844 }
18451845
18461846 if (typ === "any") return val;
Mtypescriptprefer-types-true--df33e18681f9 / TopLevel.ts+2 −2
@@ -1829,7 +1829,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
18291829 if (val === null || typeof val !== "object" || Array.isArray(val)) {
18301830 return invalidValue(l(ref || "object"), val, key, parent);
18311831 }
1832- const result: any = {};
1832+ const result: any = Object.create(null);
18331833 Object.getOwnPropertyNames(props).forEach(key => {
18341834 const prop = props[key];
18351835 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -1840,7 +1840,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
18401840 result[key] = transform(val[key], additional, getProps, key, ref);
18411841 }
18421842 });
1843- return result;
1843+ return Object.setPrototypeOf(result, Object.prototype);
18441844 }
18451845
18461846 if (typ === "any") return val;
Test case

test/inputs/json/priority/kotlin-enum-class-case-collision.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -76,6 +76,14 @@ encodeCategoryEnum x = case x of
7676
7777 --- encoder helpers
7878
79+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
80+makeDictEncoder f m r =
81+ r
82+ |> Dict.toList
83+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
84+ |> String.join ","
85+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
86+
7987 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8088 makeNullableEncoder f m =
8189 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/priority/list.json

3 generated files · +6 −6
Mflowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/json/priority/name-style.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -68,6 +68,14 @@ encodeQuickType x =
6868
6969 --- encoder helpers
7070
71+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
72+makeDictEncoder f m r =
73+ r
74+ |> Dict.toList
75+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
76+ |> String.join ","
77+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
78+
7179 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7280 makeNullableEncoder f m =
7381 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Test case

test/inputs/json/priority/nbl-stats.json

4 generated files · +26 −18
Melmdefault / QuickType.elm+20 −12
@@ -436,9 +436,9 @@ encodeQuickType x =
436436 , ("periodLengthREGULAR", Jenc.int x.periodLengthREGULAR)
437437 , ("periodType", encodePerType x.periodType)
438438 , ("periodsMax", Jenc.int x.periodsMax)
439- , ("scorers", Jenc.dict identity (Jenc.list encodeScorer) x.scorers)
439+ , ("scorers", makeDictEncoder identity (Jenc.list encodeScorer) x.scorers)
440440 , ("timeline", Jenc.list identity x.timeline)
441- , ("tm", Jenc.dict identity encodeTm x.tm)
441+ , ("tm", makeDictEncoder identity encodeTm x.tm)
442442 , ("totalTimeAdded", Jenc.int x.totalTimeAdded)
443443 , ("totallds", encodeTotallds x.totallds)
444444 ]
@@ -878,7 +878,7 @@ encodeTm x =
878878 , ("p2_score", Jenc.int x.p2Score)
879879 , ("p3_score", Jenc.int x.p3Score)
880880 , ("p4_score", Jenc.int x.p4Score)
881- , ("pl", Jenc.dict identity encodePl x.pl)
881+ , ("pl", makeDictEncoder identity encodePl x.pl)
882882 , ("score", Jenc.int x.score)
883883 , ("scoring", Jenc.list encodeScorer x.scoring)
884884 , ("shortName", Jenc.string x.shortName)
@@ -945,11 +945,11 @@ lds =
945945 encodeLds : Lds -> Jenc.Value
946946 encodeLds x =
947947 Jenc.object
948- [ ("sAssists", Jenc.dict identity encodeScorer x.sAssists)
948+ [ ("sAssists", makeDictEncoder identity encodeScorer x.sAssists)
949949 , ("sBlocks", encodeSBlocks x.sBlocks)
950- , ("sPoints", Jenc.dict identity encodeScorer x.sPoints)
951- , ("sReboundsTotal", Jenc.dict identity encodeScorer x.sReboundsTotal)
952- , ("sSteals", Jenc.dict identity encodeScorer x.sSteals)
950+ , ("sPoints", makeDictEncoder identity encodeScorer x.sPoints)
951+ , ("sReboundsTotal", makeDictEncoder identity encodeScorer x.sReboundsTotal)
952+ , ("sSteals", makeDictEncoder identity encodeScorer x.sSteals)
953953 ]
954954
955955 sBlocks : Jdec.Decoder SBlocks
@@ -1163,15 +1163,23 @@ totallds =
11631163 encodeTotallds : Totallds -> Jenc.Value
11641164 encodeTotallds x =
11651165 Jenc.object
1166- [ ("sAssists", Jenc.dict identity encodeScorer x.sAssists)
1167- , ("sBlocks", Jenc.dict identity encodeScorer x.sBlocks)
1168- , ("sPoints", Jenc.dict identity encodeScorer x.sPoints)
1169- , ("sReboundsTotal", Jenc.dict identity encodeScorer x.sReboundsTotal)
1170- , ("sSteals", Jenc.dict identity encodeScorer x.sSteals)
1166+ [ ("sAssists", makeDictEncoder identity encodeScorer x.sAssists)
1167+ , ("sBlocks", makeDictEncoder identity encodeScorer x.sBlocks)
1168+ , ("sPoints", makeDictEncoder identity encodeScorer x.sPoints)
1169+ , ("sReboundsTotal", makeDictEncoder identity encodeScorer x.sReboundsTotal)
1170+ , ("sSteals", makeDictEncoder identity encodeScorer x.sSteals)
11711171 ]
11721172
11731173 --- encoder helpers
11741174
1175+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1176+makeDictEncoder f m r =
1177+ r
1178+ |> Dict.toList
1179+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1180+ |> String.join ","
1181+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1182+
11751183 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
11761184 makeNullableEncoder f m =
11771185 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -439,7 +439,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
439439 if (val === null || typeof val !== "object" || Array.isArray(val)) {
440440 return invalidValue(l(ref || "object"), val, key, parent);
441441 }
442- const result: any = {};
442+ const result: any = Object.create(null);
443443 Object.getOwnPropertyNames(props).forEach(key => {
444444 const prop = props[key];
445445 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -450,7 +450,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
450450 result[key] = transform(val[key], additional, getProps, key, ref);
451451 }
452452 });
453- return result;
453+ return Object.setPrototypeOf(result, Object.prototype);
454454 }
455455
456456 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -384,7 +384,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
384384 if (val === null || typeof val !== "object" || Array.isArray(val)) {
385385 return invalidValue(l(ref || "object"), val, key, parent);
386386 }
387- const result: any = {};
387+ const result: any = Object.create(null);
388388 Object.getOwnPropertyNames(props).forEach(key => {
389389 const prop = props[key];
390390 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -395,7 +395,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
395395 result[key] = transform(val[key], additional, getProps, key, ref);
396396 }
397397 });
398- return result;
398+ return Object.setPrototypeOf(result, Object.prototype);
399399 }
400400
401401 if (typ === "any") return val;
Test case

test/inputs/json/priority/nested-objects.json

5 generated files · +18 −10
Melmdefault / QuickType.elm+10 −2
@@ -47,12 +47,20 @@ quickType =
4747 encodeQuickType : QuickType -> Jenc.Value
4848 encodeQuickType x =
4949 Jenc.object
50- [ ("a", Jenc.dict identity Jenc.int x.a)
51- , ("b", Jenc.dict identity Jenc.int x.b)
50+ [ ("a", makeDictEncoder identity Jenc.int x.a)
51+ , ("b", makeDictEncoder identity Jenc.int x.b)
5252 ]
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mjavascriptconverters-all-objects--3a443babd1cb / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/json/priority/no-classes.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -40,6 +40,14 @@ quickTypeToString r = Jenc.encode 0 (Jenc.int r)
4040
4141 --- encoder helpers
4242
43+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
44+makeDictEncoder f m r =
45+ r
46+ |> Dict.toList
47+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
48+ |> String.join ","
49+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
50+
4351 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
4452 makeNullableEncoder f m =
4553 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Test case

test/inputs/json/priority/nst-test-suite.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -533,6 +533,14 @@ encodeYObjectWithNewlinesJSON x =
533533
534534 --- encoder helpers
535535
536+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
537+makeDictEncoder f m r =
538+ r
539+ |> Dict.toList
540+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
541+ |> String.join ","
542+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
543+
536544 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
537545 makeNullableEncoder f m =
538546 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -247,7 +247,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
247247 if (val === null || typeof val !== "object" || Array.isArray(val)) {
248248 return invalidValue(l(ref || "object"), val, key, parent);
249249 }
250- const result: any = {};
250+ const result: any = Object.create(null);
251251 Object.getOwnPropertyNames(props).forEach(key => {
252252 const prop = props[key];
253253 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -258,7 +258,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
258258 result[key] = transform(val[key], additional, getProps, key, ref);
259259 }
260260 });
261- return result;
261+ return Object.setPrototypeOf(result, Object.prototype);
262262 }
263263
264264 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -244,7 +244,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
244244 if (val === null || typeof val !== "object" || Array.isArray(val)) {
245245 return invalidValue(l(ref || "object"), val, key, parent);
246246 }
247- const result: any = {};
247+ const result: any = Object.create(null);
248248 Object.getOwnPropertyNames(props).forEach(key => {
249249 const prop = props[key];
250250 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -255,7 +255,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
255255 result[key] = transform(val[key], additional, getProps, key, ref);
256256 }
257257 });
258- return result;
258+ return Object.setPrototypeOf(result, Object.prototype);
259259 }
260260
261261 if (typ === "any") return val;
Test case

test/inputs/json/priority/number-map.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -45,11 +45,19 @@ quickType =
4545 encodeQuickType : QuickType -> Jenc.Value
4646 encodeQuickType x =
4747 Jenc.object
48- [ ("foo", Jenc.dict identity Jenc.float x.foo)
48+ [ ("foo", makeDictEncoder identity Jenc.float x.foo)
4949 ]
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Test case

test/inputs/json/priority/omit-empty.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeResult x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/priority/optional-union.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -73,6 +73,14 @@ encodeA x = case x of
7373
7474 --- encoder helpers
7575
76+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
77+makeDictEncoder f m r =
78+ r
79+ |> Dict.toList
80+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
81+ |> String.join ","
82+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
83+
7684 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7785 makeNullableEncoder f m =
7886 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/priority/php-mixed-union.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -92,6 +92,14 @@ encodeMixedClass x =
9292
9393 --- encoder helpers
9494
95+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
96+makeDictEncoder f m r =
97+ r
98+ |> Dict.toList
99+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
100+ |> String.join ","
101+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
102+
95103 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
96104 makeNullableEncoder f m =
97105 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Test case

test/inputs/json/priority/php-validation.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -62,6 +62,14 @@ encodeQuickType x =
6262
6363 --- encoder helpers
6464
65+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
66+makeDictEncoder f m r =
67+ r
68+ |> Dict.toList
69+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
70+ |> String.join ","
71+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
72+
6573 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6674 makeNullableEncoder f m =
6775 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/priority/recursive.json

3 generated files · +6 −6
Mflowdefault / TopLevel.js+2 −2
@@ -226,7 +226,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
226226 if (val === null || typeof val !== "object" || Array.isArray(val)) {
227227 return invalidValue(l(ref || "object"), val, key, parent);
228228 }
229- const result: any = {};
229+ const result: any = Object.create(null);
230230 Object.getOwnPropertyNames(props).forEach(key => {
231231 const prop = props[key];
232232 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -237,7 +237,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
237237 result[key] = transform(val[key], additional, getProps, key, ref);
238238 }
239239 });
240- return result;
240+ return Object.setPrototypeOf(result, Object.prototype);
241241 }
242242
243243 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -226,7 +226,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
226226 if (val === null || typeof val !== "object" || Array.isArray(val)) {
227227 return invalidValue(l(ref || "object"), val, key, parent);
228228 }
229- const result: any = {};
229+ const result: any = Object.create(null);
230230 Object.getOwnPropertyNames(props).forEach(key => {
231231 const prop = props[key];
232232 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -237,7 +237,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
237237 result[key] = transform(val[key], additional, getProps, key, ref);
238238 }
239239 });
240- return result;
240+ return Object.setPrototypeOf(result, Object.prototype);
241241 }
242242
243243 if (typ === "any") return val;
Test case

test/inputs/json/priority/simple-identifiers.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -74,6 +74,14 @@ encodeQuickType x =
7474
7575 --- encoder helpers
7676
77+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
78+makeDictEncoder f m r =
79+ r
80+ |> Dict.toList
81+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
82+ |> String.join ","
83+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
84+
7785 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7886 makeNullableEncoder f m =
7987 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/json/priority/union-constructor-clash.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -86,6 +86,14 @@ encodeUnion x = case x of
8686
8787 --- encoder helpers
8888
89+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
90+makeDictEncoder f m r =
91+ r
92+ |> Dict.toList
93+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
94+ |> String.join ","
95+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
96+
8997 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
9098 makeNullableEncoder f m =
9199 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/json/priority/unions.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -112,6 +112,14 @@ encodeZClass x =
112112
113113 --- encoder helpers
114114
115+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
116+makeDictEncoder f m r =
117+ r
118+ |> Dict.toList
119+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
120+ |> String.join ","
121+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
122+
115123 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
116124 makeNullableEncoder f m =
117125 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Test case

test/inputs/json/priority/url.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -53,6 +53,14 @@ encodeQuickType x =
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/json/priority/uuids.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -65,6 +65,14 @@ encodeQuickType x =
6565
6666 --- encoder helpers
6767
68+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
69+makeDictEncoder f m r =
70+ r
71+ |> Dict.toList
72+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
73+ |> String.join ","
74+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
75+
6876 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6977 makeNullableEncoder f m =
7078 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/json/samples/bitcoin-block.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -62,6 +62,14 @@ encodeQuickType x =
6262
6363 --- encoder helpers
6464
65+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
66+makeDictEncoder f m r =
67+ r
68+ |> Dict.toList
69+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
70+ |> String.join ","
71+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
72+
6573 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6674 makeNullableEncoder f m =
6775 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/samples/copy-with-property.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -53,6 +53,14 @@ encodeQuickType x =
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/json/samples/getting-started.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -53,6 +53,14 @@ encodeQuickType x =
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/json/samples/github-events.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -986,6 +986,14 @@ encodeQuickTypeRepo x =
986986
987987 --- encoder helpers
988988
989+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
990+makeDictEncoder f m r =
991+ r
992+ |> Dict.toList
993+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
994+ |> String.join ","
995+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
996+
989997 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
990998 makeNullableEncoder f m =
991999 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -395,7 +395,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
395395 if (val === null || typeof val !== "object" || Array.isArray(val)) {
396396 return invalidValue(l(ref || "object"), val, key, parent);
397397 }
398- const result: any = {};
398+ const result: any = Object.create(null);
399399 Object.getOwnPropertyNames(props).forEach(key => {
400400 const prop = props[key];
401401 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -406,7 +406,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
406406 result[key] = transform(val[key], additional, getProps, key, ref);
407407 }
408408 });
409- return result;
409+ return Object.setPrototypeOf(result, Object.prototype);
410410 }
411411
412412 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -393,7 +393,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
393393 if (val === null || typeof val !== "object" || Array.isArray(val)) {
394394 return invalidValue(l(ref || "object"), val, key, parent);
395395 }
396- const result: any = {};
396+ const result: any = Object.create(null);
397397 Object.getOwnPropertyNames(props).forEach(key => {
398398 const prop = props[key];
399399 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -404,7 +404,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
404404 result[key] = transform(val[key], additional, getProps, key, ref);
405405 }
406406 });
407- return result;
407+ return Object.setPrototypeOf(result, Object.prototype);
408408 }
409409
410410 if (typ === "any") return val;
Test case

test/inputs/json/samples/kitchen-sink.json

4 generated files · +16 −8
Melmdefault / QuickType.elm+10 −2
@@ -105,10 +105,10 @@ encodeQuickType x =
105105 , ("differentThings", Jenc.list encodeDifferentThingElement x.differentThings)
106106 , ("doubleValue", Jenc.float x.doubleValue)
107107 , ("intValue", Jenc.int x.intValue)
108- , ("mapValue", Jenc.dict identity (makeNullableEncoder Jenc.int) x.mapValue)
108+ , ("mapValue", makeDictEncoder identity (makeNullableEncoder Jenc.int) x.mapValue)
109109 , ("name with spaces", always Jenc.null x.nameWithSpaces)
110110 , ("nullValue", always Jenc.null x.nullValue)
111- , ("nullableMapValue", Jenc.dict identity (makeNullableEncoder Jenc.int) x.nullableMapValue)
111+ , ("nullableMapValue", makeDictEncoder identity (makeNullableEncoder Jenc.int) x.nullableMapValue)
112112 , ("people", Jenc.list encodePersonElement x.people)
113113 , ("person", encodePurplePerson x.person)
114114 , ("stringValue", Jenc.string x.stringValue)
@@ -183,6 +183,14 @@ encodePurplePerson x =
183183
184184 --- encoder helpers
185185
186+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
187+makeDictEncoder f m r =
188+ r
189+ |> Dict.toList
190+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
191+ |> String.join ","
192+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
193+
186194 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
187195 makeNullableEncoder f m =
188196 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -139,7 +139,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
139139 if (val === null || typeof val !== "object" || Array.isArray(val)) {
140140 return invalidValue(l(ref || "object"), val, key, parent);
141141 }
142- const result: any = {};
142+ const result: any = Object.create(null);
143143 Object.getOwnPropertyNames(props).forEach(key => {
144144 const prop = props[key];
145145 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -150,7 +150,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
150150 result[key] = transform(val[key], additional, getProps, key, ref);
151151 }
152152 });
153- return result;
153+ return Object.setPrototypeOf(result, Object.prototype);
154154 }
155155
156156 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -139,7 +139,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
139139 if (val === null || typeof val !== "object" || Array.isArray(val)) {
140140 return invalidValue(l(ref || "object"), val, key, parent);
141141 }
142- const result: any = {};
142+ const result: any = Object.create(null);
143143 Object.getOwnPropertyNames(props).forEach(key => {
144144 const prop = props[key];
145145 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -150,7 +150,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
150150 result[key] = transform(val[key], additional, getProps, key, ref);
151151 }
152152 });
153- return result;
153+ return Object.setPrototypeOf(result, Object.prototype);
154154 }
155155
156156 if (typ === "any") return val;
Test case

test/inputs/json/samples/null-safe.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -97,6 +97,14 @@ encodeAddress x =
9797
9898 --- encoder helpers
9999
100+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
101+makeDictEncoder f m r =
102+ r
103+ |> Dict.toList
104+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
105+ |> String.join ","
106+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
107+
100108 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
101109 makeNullableEncoder f m =
102110 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Test case

test/inputs/json/samples/objc-control-characters.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -76,6 +76,14 @@ encodeValue x = case x of
7676
7777 --- encoder helpers
7878
79+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
80+makeDictEncoder f m r =
81+ r
82+ |> Dict.toList
83+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
84+ |> String.join ","
85+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
86+
7987 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8088 makeNullableEncoder f m =
8189 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/json/samples/pokedex.json

5 generated files · +16 −8
Melmdefault / QuickType.elm+8 −0
@@ -230,6 +230,14 @@ encodeType x = case x of
230230
231231 --- encoder helpers
232232
233+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
234+makeDictEncoder f m r =
235+ r
236+ |> Dict.toList
237+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
238+ |> String.join ","
239+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
240+
233241 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
234242 makeNullableEncoder f m =
235243 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -159,7 +159,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
159159 if (val === null || typeof val !== "object" || Array.isArray(val)) {
160160 return invalidValue(l(ref || "object"), val, key, parent);
161161 }
162- const result: any = {};
162+ const result: any = Object.create(null);
163163 Object.getOwnPropertyNames(props).forEach(key => {
164164 const prop = props[key];
165165 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -170,7 +170,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
170170 result[key] = transform(val[key], additional, getProps, key, ref);
171171 }
172172 });
173- return result;
173+ return Object.setPrototypeOf(result, Object.prototype);
174174 }
175175
176176 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 if (val === null || typeof val !== "object" || Array.isArray(val)) {
137137 return invalidValue(l(ref || "object"), val, key, parent);
138138 }
139- const result: any = {};
139+ const result: any = Object.create(null);
140140 Object.getOwnPropertyNames(props).forEach(key => {
141141 const prop = props[key];
142142 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 result[key] = transform(val[key], additional, getProps, key, ref);
148148 }
149149 });
150- return result;
150+ return Object.setPrototypeOf(result, Object.prototype);
151151 }
152152
153153 if (typ === "any") return val;
Mtypescriptprefer-types-true--df33e18681f9 / TopLevel.ts+2 −2
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 if (val === null || typeof val !== "object" || Array.isArray(val)) {
137137 return invalidValue(l(ref || "object"), val, key, parent);
138138 }
139- const result: any = {};
139+ const result: any = Object.create(null);
140140 Object.getOwnPropertyNames(props).forEach(key => {
141141 const prop = props[key];
142142 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 result[key] = transform(val[key], additional, getProps, key, ref);
148148 }
149149 });
150- return result;
150+ return Object.setPrototypeOf(result, Object.prototype);
151151 }
152152
153153 if (typ === "any") return val;
Test case

test/inputs/json/samples/reddit.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -575,6 +575,14 @@ encodeKind x = case x of
575575
576576 --- encoder helpers
577577
578+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
579+makeDictEncoder f m r =
580+ r
581+ |> Dict.toList
582+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
583+ |> String.join ","
584+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
585+
578586 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
579587 makeNullableEncoder f m =
580588 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -248,7 +248,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
248248 if (val === null || typeof val !== "object" || Array.isArray(val)) {
249249 return invalidValue(l(ref || "object"), val, key, parent);
250250 }
251- const result: any = {};
251+ const result: any = Object.create(null);
252252 Object.getOwnPropertyNames(props).forEach(key => {
253253 const prop = props[key];
254254 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -259,7 +259,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
259259 result[key] = transform(val[key], additional, getProps, key, ref);
260260 }
261261 });
262- return result;
262+ return Object.setPrototypeOf(result, Object.prototype);
263263 }
264264
265265 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -233,7 +233,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
233233 if (val === null || typeof val !== "object" || Array.isArray(val)) {
234234 return invalidValue(l(ref || "object"), val, key, parent);
235235 }
236- const result: any = {};
236+ const result: any = Object.create(null);
237237 Object.getOwnPropertyNames(props).forEach(key => {
238238 const prop = props[key];
239239 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -244,7 +244,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
244244 result[key] = transform(val[key], additional, getProps, key, ref);
245245 }
246246 });
247- return result;
247+ return Object.setPrototypeOf(result, Object.prototype);
248248 }
249249
250250 if (typ === "any") return val;
Test case

test/inputs/json/samples/simple-object.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -56,6 +56,14 @@ encodeQuickType x =
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/json/samples/spotify-album.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -288,6 +288,14 @@ encodeItem x =
288288
289289 --- encoder helpers
290290
291+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
292+makeDictEncoder f m r =
293+ r
294+ |> Dict.toList
295+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
296+ |> String.join ","
297+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
298+
291299 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
292300 makeNullableEncoder f m =
293301 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -177,7 +177,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
177177 if (val === null || typeof val !== "object" || Array.isArray(val)) {
178178 return invalidValue(l(ref || "object"), val, key, parent);
179179 }
180- const result: any = {};
180+ const result: any = Object.create(null);
181181 Object.getOwnPropertyNames(props).forEach(key => {
182182 const prop = props[key];
183183 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -188,7 +188,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
188188 result[key] = transform(val[key], additional, getProps, key, ref);
189189 }
190190 });
191- return result;
191+ return Object.setPrototypeOf(result, Object.prototype);
192192 }
193193
194194 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -177,7 +177,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
177177 if (val === null || typeof val !== "object" || Array.isArray(val)) {
178178 return invalidValue(l(ref || "object"), val, key, parent);
179179 }
180- const result: any = {};
180+ const result: any = Object.create(null);
181181 Object.getOwnPropertyNames(props).forEach(key => {
182182 const prop = props[key];
183183 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -188,7 +188,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
188188 result[key] = transform(val[key], additional, getProps, key, ref);
189189 }
190190 });
191- return result;
191+ return Object.setPrototypeOf(result, Object.prototype);
192192 }
193193
194194 if (typ === "any") return val;
Test case

test/inputs/json/samples/us-avg-temperatures.json

4 generated files · +15 −7
Melmdefault / QuickType.elm+9 −1
@@ -61,7 +61,7 @@ quickType =
6161 encodeQuickType : QuickType -> Jenc.Value
6262 encodeQuickType x =
6363 Jenc.object
64- [ ("data", Jenc.dict identity encodeDatum x.data)
64+ [ ("data", makeDictEncoder identity encodeDatum x.data)
6565 , ("description", encodeDescription x.description)
6666 ]
6767
@@ -97,6 +97,14 @@ encodeDescription x =
9797
9898 --- encoder helpers
9999
100+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
101+makeDictEncoder f m r =
102+ r
103+ |> Dict.toList
104+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
105+ |> String.join ","
106+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
107+
100108 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
101109 makeNullableEncoder f m =
102110 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Test case

test/inputs/json/samples/us-senators.json

4 generated files · +14 −6
Melmdefault / QuickType.elm+8 −0
@@ -469,6 +469,14 @@ encodeTitle x = case x of
469469
470470 --- encoder helpers
471471
472+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
473+makeDictEncoder f m r =
474+ r
475+ |> Dict.toList
476+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
477+ |> String.join ","
478+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
479+
472480 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
473481 makeNullableEncoder f m =
474482 case m of
Mflowdefault / TopLevel.js+2 −2
@@ -212,7 +212,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
212212 if (val === null || typeof val !== "object" || Array.isArray(val)) {
213213 return invalidValue(l(ref || "object"), val, key, parent);
214214 }
215- const result: any = {};
215+ const result: any = Object.create(null);
216216 Object.getOwnPropertyNames(props).forEach(key => {
217217 const prop = props[key];
218218 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -223,7 +223,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
223223 result[key] = transform(val[key], additional, getProps, key, ref);
224224 }
225225 });
226- return result;
226+ return Object.setPrototypeOf(result, Object.prototype);
227227 }
228228
229229 if (typ === "any") return val;
Mjavascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mtypescriptdefault / TopLevel.ts+2 −2
@@ -189,7 +189,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
189189 if (val === null || typeof val !== "object" || Array.isArray(val)) {
190190 return invalidValue(l(ref || "object"), val, key, parent);
191191 }
192- const result: any = {};
192+ const result: any = Object.create(null);
193193 Object.getOwnPropertyNames(props).forEach(key => {
194194 const prop = props[key];
195195 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -200,7 +200,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
200200 result[key] = transform(val[key], additional, getProps, key, ref);
201201 }
202202 });
203- return result;
203+ return Object.setPrototypeOf(result, Object.prototype);
204204 }
205205
206206 if (typ === "any") return val;
Test case

test/inputs/schema/accessors.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -99,6 +99,14 @@ encodeUnion x = case x of
9999
100100 --- encoder helpers
101101
102+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
103+makeDictEncoder f m r =
104+ r
105+ |> Dict.toList
106+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
107+ |> String.join ","
108+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
109+
102110 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
103111 makeNullableEncoder f m =
104112 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/schema/all-of-additional-properties-false.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -102,6 +102,14 @@ encodeType x = case x of
102102
103103 --- encoder helpers
104104
105+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
106+makeDictEncoder f m r =
107+ r
108+ |> Dict.toList
109+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
110+ |> String.join ","
111+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
112+
105113 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
106114 makeNullableEncoder f m =
107115 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 if (val === null || typeof val !== "object" || Array.isArray(val)) {
120120 return invalidValue(l(ref || "object"), val, key, parent);
121121 }
122- const result: any = {};
122+ const result: any = Object.create(null);
123123 Object.getOwnPropertyNames(props).forEach(key => {
124124 const prop = props[key];
125125 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 result[key] = transform(val[key], additional, getProps, key, ref);
131131 }
132132 });
133- return result;
133+ return Object.setPrototypeOf(result, Object.prototype);
134134 }
135135
136136 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/schema/any.schema

4 generated files · +15 −7
Mschema-elmdefault / QuickType.elm+9 −1
@@ -48,11 +48,19 @@ encodeQuickType : QuickType -> Jenc.Value
4848 encodeQuickType x =
4949 Jenc.object
5050 [ ("foo", identity x.foo)
51- , ("values", Jenc.dict identity identity x.values)
51+ , ("values", makeDictEncoder identity identity x.values)
5252 ]
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/schema/bool-string.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -85,6 +85,14 @@ encodeUnionWithBool x = case x of
8585
8686 --- encoder helpers
8787
88+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
89+makeDictEncoder f m r =
90+ r
91+ |> Dict.toList
92+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
93+ |> String.join ","
94+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
95+
8896 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8997 makeNullableEncoder f m =
9098 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/schema/boolean-subschema.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -59,6 +59,14 @@ encodeQuickType x =
5959
6060 --- encoder helpers
6161
62+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
63+makeDictEncoder f m r =
64+ r
65+ |> Dict.toList
66+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
67+ |> String.join ","
68+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
69+
6270 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6371 makeNullableEncoder f m =
6472 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/camelCase.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -53,6 +53,14 @@ encodeQuickType x =
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/schema/class-map-union.schema

4 generated files · +15 −7
Mschema-elmdefault / QuickType.elm+9 −1
@@ -57,7 +57,7 @@ quickType =
5757 encodeQuickType : QuickType -> Jenc.Value
5858 encodeQuickType x =
5959 Jenc.object
60- [ ("union", makeNullableEncoder (Jenc.dict identity encodeUnionValue) x.union)
60+ [ ("union", makeNullableEncoder (makeDictEncoder identity encodeUnionValue) x.union)
6161 ]
6262
6363 unionValue : Jdec.Decoder UnionValue
@@ -89,6 +89,14 @@ encodeUnionClass x =
8989
9090 --- encoder helpers
9191
92+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
93+makeDictEncoder f m r =
94+ r
95+ |> Dict.toList
96+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
97+ |> String.join ","
98+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
99+
92100 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
93101 makeNullableEncoder f m =
94102 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 if (val === null || typeof val !== "object" || Array.isArray(val)) {
125125 return invalidValue(l(ref || "object"), val, key, parent);
126126 }
127- const result: any = {};
127+ const result: any = Object.create(null);
128128 Object.getOwnPropertyNames(props).forEach(key => {
129129 const prop = props[key];
130130 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 result[key] = transform(val[key], additional, getProps, key, ref);
136136 }
137137 });
138- return result;
138+ return Object.setPrototypeOf(result, Object.prototype);
139139 }
140140
141141 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 if (val === null || typeof val !== "object" || Array.isArray(val)) {
125125 return invalidValue(l(ref || "object"), val, key, parent);
126126 }
127- const result: any = {};
127+ const result: any = Object.create(null);
128128 Object.getOwnPropertyNames(props).forEach(key => {
129129 const prop = props[key];
130130 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -135,7 +135,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
135135 result[key] = transform(val[key], additional, getProps, key, ref);
136136 }
137137 });
138- return result;
138+ return Object.setPrototypeOf(result, Object.prototype);
139139 }
140140
141141 if (typ === "any") return val;
Test case

test/inputs/schema/class-with-additional.schema

4 generated files · +15 −7
Mschema-elmdefault / QuickType.elm+9 −1
@@ -50,7 +50,7 @@ quickType =
5050 encodeQuickType : QuickType -> Jenc.Value
5151 encodeQuickType x =
5252 Jenc.object
53- [ ("map", makeNullableEncoder (Jenc.dict identity encodeMap) x.map)
53+ [ ("map", makeNullableEncoder (makeDictEncoder identity encodeMap) x.map)
5454 ]
5555
5656 map : Jdec.Decoder Map
@@ -67,6 +67,14 @@ encodeMap x = case x of
6767
6868 --- encoder helpers
6969
70+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
71+makeDictEncoder f m r =
72+ r
73+ |> Dict.toList
74+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
75+ |> String.join ","
76+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
77+
7078 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7179 makeNullableEncoder f m =
7280 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/schema/comment-injection-enum-nested-comment.schema

5 generated files · +16 −8
Mcomment-injection-typescriptdefault / TopLevel.ts+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Mschema-elmdefault / QuickType.elm+8 −0
@@ -78,6 +78,14 @@ encodeKind x = case x of
7878
7979 --- encoder helpers
8080
81+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
82+makeDictEncoder f m r =
83+ r
84+ |> Dict.toList
85+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
86+ |> String.join ","
87+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
88+
8189 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8290 makeNullableEncoder f m =
8391 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 if (val === null || typeof val !== "object" || Array.isArray(val)) {
123123 return invalidValue(l(ref || "object"), val, key, parent);
124124 }
125- const result: any = {};
125+ const result: any = Object.create(null);
126126 Object.getOwnPropertyNames(props).forEach(key => {
127127 const prop = props[key];
128128 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -133,7 +133,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
133133 result[key] = transform(val[key], additional, getProps, key, ref);
134134 }
135135 });
136- return result;
136+ return Object.setPrototypeOf(result, Object.prototype);
137137 }
138138
139139 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Test case

test/inputs/schema/comment-injection-enum.schema

5 generated files · +16 −8
Mcomment-injection-typescriptdefault / TopLevel.ts+2 −2
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 if (val === null || typeof val !== "object" || Array.isArray(val)) {
128128 return invalidValue(l(ref || "object"), val, key, parent);
129129 }
130- const result: any = {};
130+ const result: any = Object.create(null);
131131 Object.getOwnPropertyNames(props).forEach(key => {
132132 const prop = props[key];
133133 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -138,7 +138,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
138138 result[key] = transform(val[key], additional, getProps, key, ref);
139139 }
140140 });
141- return result;
141+ return Object.setPrototypeOf(result, Object.prototype);
142142 }
143143
144144 if (typ === "any") return val;
Mschema-elmdefault / QuickType.elm+8 −0
@@ -84,6 +84,14 @@ encodeKind x = case x of
8484
8585 --- encoder helpers
8686
87+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
88+makeDictEncoder f m r =
89+ r
90+ |> Dict.toList
91+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
92+ |> String.join ","
93+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
94+
8795 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8896 makeNullableEncoder f m =
8997 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 if (val === null || typeof val !== "object" || Array.isArray(val)) {
129129 return invalidValue(l(ref || "object"), val, key, parent);
130130 }
131- const result: any = {};
131+ const result: any = Object.create(null);
132132 Object.getOwnPropertyNames(props).forEach(key => {
133133 const prop = props[key];
134134 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -139,7 +139,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
139139 result[key] = transform(val[key], additional, getProps, key, ref);
140140 }
141141 });
142- return result;
142+ return Object.setPrototypeOf(result, Object.prototype);
143143 }
144144
145145 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 if (val === null || typeof val !== "object" || Array.isArray(val)) {
128128 return invalidValue(l(ref || "object"), val, key, parent);
129129 }
130- const result: any = {};
130+ const result: any = Object.create(null);
131131 Object.getOwnPropertyNames(props).forEach(key => {
132132 const prop = props[key];
133133 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -138,7 +138,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
138138 result[key] = transform(val[key], additional, getProps, key, ref);
139139 }
140140 });
141- return result;
141+ return Object.setPrototypeOf(result, Object.prototype);
142142 }
143143
144144 if (typ === "any") return val;
Test case

test/inputs/schema/comment-injection-nested-comment.schema

5 generated files · +16 −8
Mcomment-injection-typescriptdefault / TopLevel.ts+2 −2
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 if (val === null || typeof val !== "object" || Array.isArray(val)) {
120120 return invalidValue(l(ref || "object"), val, key, parent);
121121 }
122- const result: any = {};
122+ const result: any = Object.create(null);
123123 Object.getOwnPropertyNames(props).forEach(key => {
124124 const prop = props[key];
125125 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 result[key] = transform(val[key], additional, getProps, key, ref);
131131 }
132132 });
133- return result;
133+ return Object.setPrototypeOf(result, Object.prototype);
134134 }
135135
136136 if (typ === "any") return val;
Mschema-elmdefault / QuickType.elm+8 −0
@@ -61,6 +61,14 @@ encodeQuickType x =
6161
6262 --- encoder helpers
6363
64+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
65+makeDictEncoder f m r =
66+ r
67+ |> Dict.toList
68+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
69+ |> String.join ","
70+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
71+
6472 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6573 makeNullableEncoder f m =
6674 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 if (val === null || typeof val !== "object" || Array.isArray(val)) {
120120 return invalidValue(l(ref || "object"), val, key, parent);
121121 }
122- const result: any = {};
122+ const result: any = Object.create(null);
123123 Object.getOwnPropertyNames(props).forEach(key => {
124124 const prop = props[key];
125125 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 result[key] = transform(val[key], additional, getProps, key, ref);
131131 }
132132 });
133- return result;
133+ return Object.setPrototypeOf(result, Object.prototype);
134134 }
135135
136136 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 if (val === null || typeof val !== "object" || Array.isArray(val)) {
120120 return invalidValue(l(ref || "object"), val, key, parent);
121121 }
122- const result: any = {};
122+ const result: any = Object.create(null);
123123 Object.getOwnPropertyNames(props).forEach(key => {
124124 const prop = props[key];
125125 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -130,7 +130,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
130130 result[key] = transform(val[key], additional, getProps, key, ref);
131131 }
132132 });
133- return result;
133+ return Object.setPrototypeOf(result, Object.prototype);
134134 }
135135
136136 if (typ === "any") return val;
Test case

test/inputs/schema/comment-injection.schema

5 generated files · +16 −8
Mcomment-injection-typescriptdefault / TopLevel.ts+2 −2
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 if (val === null || typeof val !== "object" || Array.isArray(val)) {
148148 return invalidValue(l(ref || "object"), val, key, parent);
149149 }
150- const result: any = {};
150+ const result: any = Object.create(null);
151151 Object.getOwnPropertyNames(props).forEach(key => {
152152 const prop = props[key];
153153 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -158,7 +158,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
158158 result[key] = transform(val[key], additional, getProps, key, ref);
159159 }
160160 });
161- return result;
161+ return Object.setPrototypeOf(result, Object.prototype);
162162 }
163163
164164 if (typ === "any") return val;
Mschema-elmdefault / QuickType.elm+8 −0
@@ -95,6 +95,14 @@ encodeQuickType x =
9595
9696 --- encoder helpers
9797
98+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
99+makeDictEncoder f m r =
100+ r
101+ |> Dict.toList
102+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
103+ |> String.join ","
104+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
105+
98106 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
99107 makeNullableEncoder f m =
100108 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 if (val === null || typeof val !== "object" || Array.isArray(val)) {
148148 return invalidValue(l(ref || "object"), val, key, parent);
149149 }
150- const result: any = {};
150+ const result: any = Object.create(null);
151151 Object.getOwnPropertyNames(props).forEach(key => {
152152 const prop = props[key];
153153 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -158,7 +158,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
158158 result[key] = transform(val[key], additional, getProps, key, ref);
159159 }
160160 });
161- return result;
161+ return Object.setPrototypeOf(result, Object.prototype);
162162 }
163163
164164 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 if (val === null || typeof val !== "object" || Array.isArray(val)) {
148148 return invalidValue(l(ref || "object"), val, key, parent);
149149 }
150- const result: any = {};
150+ const result: any = Object.create(null);
151151 Object.getOwnPropertyNames(props).forEach(key => {
152152 const prop = props[key];
153153 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -158,7 +158,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
158158 result[key] = transform(val[key], additional, getProps, key, ref);
159159 }
160160 });
161- return result;
161+ return Object.setPrototypeOf(result, Object.prototype);
162162 }
163163
164164 if (typ === "any") return val;
Test case

test/inputs/schema/const-non-string.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -79,6 +79,14 @@ encodeKind x = case x of
7979
8080 --- encoder helpers
8181
82+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
83+makeDictEncoder f m r =
84+ r
85+ |> Dict.toList
86+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
87+ |> String.join ","
88+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
89+
8290 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8391 makeNullableEncoder f m =
8492 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/schema/constructor.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -82,6 +82,14 @@ encodeConstructor x =
8282
8383 --- encoder helpers
8484
85+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
86+makeDictEncoder f m r =
87+ r
88+ |> Dict.toList
89+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
90+ |> String.join ","
91+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
92+
8593 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8694 makeNullableEncoder f m =
8795 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/cut-enum.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/date-time-or-string.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -53,6 +53,14 @@ encodeQuickType x =
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Test case

test/inputs/schema/date-time.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -79,6 +79,14 @@ encodeComplexUnionArray x = case x of
7979
8080 --- encoder helpers
8181
82+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
83+makeDictEncoder f m r =
84+ r
85+ |> Dict.toList
86+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
87+ |> String.join ","
88+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
89+
8290 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8391 makeNullableEncoder f m =
8492 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/schema/default-value.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -52,6 +52,14 @@ encodeQuickType x =
5252
5353 --- encoder helpers
5454
55+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
56+makeDictEncoder f m r =
57+ r
58+ |> Dict.toList
59+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
60+ |> String.join ","
61+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
62+
5563 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5664 makeNullableEncoder f m =
5765 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/description-with-double-quotes.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -52,6 +52,14 @@ encodeQuickType x =
5252
5353 --- encoder helpers
5454
55+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
56+makeDictEncoder f m r =
57+ r
58+ |> Dict.toList
59+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
60+ |> String.join ","
61+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
62+
5563 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5664 makeNullableEncoder f m =
5765 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/schema/description.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -151,6 +151,14 @@ encodeUnion x = case x of
151151
152152 --- encoder helpers
153153
154+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
155+makeDictEncoder f m r =
156+ r
157+ |> Dict.toList
158+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
159+ |> String.join ","
160+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
161+
154162 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
155163 makeNullableEncoder f m =
156164 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -146,7 +146,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
146146 if (val === null || typeof val !== "object" || Array.isArray(val)) {
147147 return invalidValue(l(ref || "object"), val, key, parent);
148148 }
149- const result: any = {};
149+ const result: any = Object.create(null);
150150 Object.getOwnPropertyNames(props).forEach(key => {
151151 const prop = props[key];
152152 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -157,7 +157,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
157157 result[key] = transform(val[key], additional, getProps, key, ref);
158158 }
159159 });
160- return result;
160+ return Object.setPrototypeOf(result, Object.prototype);
161161 }
162162
163163 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -144,7 +144,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
144144 if (val === null || typeof val !== "object" || Array.isArray(val)) {
145145 return invalidValue(l(ref || "object"), val, key, parent);
146146 }
147- const result: any = {};
147+ const result: any = Object.create(null);
148148 Object.getOwnPropertyNames(props).forEach(key => {
149149 const prop = props[key];
150150 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -155,7 +155,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
155155 result[key] = transform(val[key], additional, getProps, key, ref);
156156 }
157157 });
158- return result;
158+ return Object.setPrototypeOf(result, Object.prototype);
159159 }
160160
161161 if (typ === "any") return val;
Test case

test/inputs/schema/direct-union.schema

4 generated files · +16 −8
Mschema-elmdefault / QuickType.elm+10 −2
@@ -61,7 +61,7 @@ quickType =
6161 encodeQuickType : QuickType -> Jenc.Value
6262 encodeQuickType x =
6363 Jenc.object
64- [ ("stuff", Jenc.dict identity encodeThing x.stuff)
64+ [ ("stuff", makeDictEncoder identity encodeThing x.stuff)
6565 ]
6666
6767 thing : Jdec.Decoder Thing
@@ -97,10 +97,18 @@ encodeAnything x = case x of
9797 NullInAnything -> Jenc.null
9898 StringInAnything y -> Jenc.string y
9999 DoubleInAnything y -> Jenc.float y
100- AnythingMapInAnything y -> Jenc.dict identity identity y
100+ AnythingMapInAnything y -> makeDictEncoder identity identity y
101101
102102 --- encoder helpers
103103
104+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
105+makeDictEncoder f m r =
106+ r
107+ |> Dict.toList
108+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
109+ |> String.join ","
110+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
111+
104112 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
105113 makeNullableEncoder f m =
106114 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/schema/empty-object.schema

4 generated files · +15 −7
Mschema-elmdefault / QuickType.elm+9 −1
@@ -36,10 +36,18 @@ quickType : Jdec.Decoder QuickType
3636 quickType = Jdec.dict Jdec.value
3737
3838 quickTypeToString : QuickType -> String
39-quickTypeToString r = Jenc.encode 0 (Jenc.dict identity identity r)
39+quickTypeToString r = Jenc.encode 0 (makeDictEncoder identity identity r)
4040
4141 --- encoder helpers
4242
43+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
44+makeDictEncoder f m r =
45+ r
46+ |> Dict.toList
47+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
48+ |> String.join ","
49+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
50+
4351 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
4452 makeNullableEncoder f m =
4553 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Test case

test/inputs/schema/enum-large.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -150,6 +150,14 @@ encodePriority x = case x of
150150
151151 --- encoder helpers
152152
153+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
154+makeDictEncoder f m r =
155+ r
156+ |> Dict.toList
157+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
158+ |> String.join ","
159+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
160+
153161 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
154162 makeNullableEncoder f m =
155163 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -136,7 +136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
136136 if (val === null || typeof val !== "object" || Array.isArray(val)) {
137137 return invalidValue(l(ref || "object"), val, key, parent);
138138 }
139- const result: any = {};
139+ const result: any = Object.create(null);
140140 Object.getOwnPropertyNames(props).forEach(key => {
141141 const prop = props[key];
142142 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -147,7 +147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
147147 result[key] = transform(val[key], additional, getProps, key, ref);
148148 }
149149 });
150- return result;
150+ return Object.setPrototypeOf(result, Object.prototype);
151151 }
152152
153153 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Test case

test/inputs/schema/enum-with-null.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -70,6 +70,14 @@ encodeEnum x = case x of
7070
7171 --- encoder helpers
7272
73+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
74+makeDictEncoder f m r =
75+ r
76+ |> Dict.toList
77+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
78+ |> String.join ","
79+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
80+
7381 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7482 makeNullableEncoder f m =
7583 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/schema/enum-with-values.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -85,6 +85,14 @@ encodeWeekdays x = case x of
8585
8686 --- encoder helpers
8787
88+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
89+makeDictEncoder f m r =
90+ r
91+ |> Dict.toList
92+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
93+ |> String.join ","
94+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
95+
8896 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8997 makeNullableEncoder f m =
9098 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/enum.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -148,6 +148,14 @@ encodeLvc x = case x of
148148
149149 --- encoder helpers
150150
151+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
152+makeDictEncoder f m r =
153+ r
154+ |> Dict.toList
155+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
156+ |> String.join ","
157+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
158+
151159 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
152160 makeNullableEncoder f m =
153161 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -129,7 +129,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
129129 if (val === null || typeof val !== "object" || Array.isArray(val)) {
130130 return invalidValue(l(ref || "object"), val, key, parent);
131131 }
132- const result: any = {};
132+ const result: any = Object.create(null);
133133 Object.getOwnPropertyNames(props).forEach(key => {
134134 const prop = props[key];
135135 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -140,7 +140,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
140140 result[key] = transform(val[key], additional, getProps, key, ref);
141141 }
142142 });
143- return result;
143+ return Object.setPrototypeOf(result, Object.prototype);
144144 }
145145
146146 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 if (val === null || typeof val !== "object" || Array.isArray(val)) {
121121 return invalidValue(l(ref || "object"), val, key, parent);
122122 }
123- const result: any = {};
123+ const result: any = Object.create(null);
124124 Object.getOwnPropertyNames(props).forEach(key => {
125125 const prop = props[key];
126126 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -131,7 +131,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
131131 result[key] = transform(val[key], additional, getProps, key, ref);
132132 }
133133 });
134- return result;
134+ return Object.setPrototypeOf(result, Object.prototype);
135135 }
136136
137137 if (typ === "any") return val;
Test case

test/inputs/schema/fractional-bounds.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/go-schema-pattern-properties.schema

4 generated files · +15 −7
Mschema-elmdefault / QuickType.elm+9 −1
@@ -45,11 +45,19 @@ quickType =
4545 encodeQuickType : QuickType -> Jenc.Value
4646 encodeQuickType x =
4747 Jenc.object
48- [ ("map", Jenc.dict identity Jenc.int x.map)
48+ [ ("map", makeDictEncoder identity Jenc.int x.map)
4949 ]
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/haskell-enum-forbidden.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -70,6 +70,14 @@ encodeHealth x = case x of
7070
7171 --- encoder helpers
7272
73+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
74+makeDictEncoder f m r =
75+ r
76+ |> Dict.toList
77+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
78+ |> String.join ","
79+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
80+
7381 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7482 makeNullableEncoder f m =
7583 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/id-no-address.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/id-root.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/ie-suffix-singularization.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeCookie x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/schema/implicit-all-of.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -56,6 +56,14 @@ encodeQuickType x =
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/implicit-class-array-union.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -98,6 +98,14 @@ encodeFooClass x =
9898
9999 --- encoder helpers
100100
101+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
102+makeDictEncoder f m r =
103+ r
104+ |> Dict.toList
105+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
106+ |> String.join ","
107+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
108+
101109 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
102110 makeNullableEncoder f m =
103111 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/schema/implicit-one-of.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -56,6 +56,14 @@ encodeQuickType x =
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/integer-before-number.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -53,6 +53,14 @@ encodeQuickType x = case x of
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/integer-float-union.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -67,6 +67,14 @@ encodeNumber x = case x of
6767
6868 --- encoder helpers
6969
70+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
71+makeDictEncoder f m r =
72+ r
73+ |> Dict.toList
74+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
75+ |> String.join ","
76+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
77+
7078 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7179 makeNullableEncoder f m =
7280 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/integer-string.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -85,6 +85,14 @@ encodeUnionWithInt x = case x of
8585
8686 --- encoder helpers
8787
88+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
89+makeDictEncoder f m r =
90+ r
91+ |> Dict.toList
92+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
93+ |> String.join ","
94+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
95+
8896 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8997 makeNullableEncoder f m =
9098 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/schema/integer-type.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -74,6 +74,14 @@ encodeQuickType x =
7474
7575 --- encoder helpers
7676
77+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
78+makeDictEncoder f m r =
79+ r
80+ |> Dict.toList
81+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
82+ |> String.join ","
83+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
84+
7785 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7886 makeNullableEncoder f m =
7987 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 if (val === null || typeof val !== "object" || Array.isArray(val)) {
117117 return invalidValue(l(ref || "object"), val, key, parent);
118118 }
119- const result: any = {};
119+ const result: any = Object.create(null);
120120 Object.getOwnPropertyNames(props).forEach(key => {
121121 const prop = props[key];
122122 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -127,7 +127,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
127127 result[key] = transform(val[key], additional, getProps, key, ref);
128128 }
129129 });
130- return result;
130+ return Object.setPrototypeOf(result, Object.prototype);
131131 }
132132
133133 if (typ === "any") return val;
Test case

test/inputs/schema/intersection-nested.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Test case

test/inputs/schema/intersection.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -69,6 +69,14 @@ encodeIntersection x =
6969
7070 --- encoder helpers
7171
72+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
73+makeDictEncoder f m r =
74+ r
75+ |> Dict.toList
76+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
77+ |> String.join ","
78+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
79+
7280 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7381 makeNullableEncoder f m =
7482 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Test case

test/inputs/schema/issue2680-top-level-array.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -40,6 +40,14 @@ quickTypeToString r = Jenc.encode 0 (Jenc.list Jenc.int r)
4040
4141 --- encoder helpers
4242
43+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
44+makeDictEncoder f m r =
45+ r
46+ |> Dict.toList
47+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
48+ |> String.join ","
49+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
50+
4351 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
4452 makeNullableEncoder f m =
4553 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Test case

test/inputs/schema/keyword-enum.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -1081,6 +1081,14 @@ encodeEnumEnum x = case x of
10811081
10821082 --- encoder helpers
10831083
1084+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
1085+makeDictEncoder f m r =
1086+ r
1087+ |> Dict.toList
1088+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
1089+ |> String.join ","
1090+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
1091+
10841092 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
10851093 makeNullableEncoder f m =
10861094 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -449,7 +449,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
449449 if (val === null || typeof val !== "object" || Array.isArray(val)) {
450450 return invalidValue(l(ref || "object"), val, key, parent);
451451 }
452- const result: any = {};
452+ const result: any = Object.create(null);
453453 Object.getOwnPropertyNames(props).forEach(key => {
454454 const prop = props[key];
455455 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -460,7 +460,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
460460 result[key] = transform(val[key], additional, getProps, key, ref);
461461 }
462462 });
463- return result;
463+ return Object.setPrototypeOf(result, Object.prototype);
464464 }
465465
466466 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/keyword-unions.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -11880,6 +11880,14 @@ encodeYield x =
1188011880
1188111881 --- encoder helpers
1188211882
11883+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
11884+makeDictEncoder f m r =
11885+ r
11886+ |> Dict.toList
11887+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
11888+ |> String.join ","
11889+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
11890+
1188311891 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
1188411892 makeNullableEncoder f m =
1188511893 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -2136,7 +2136,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
21362136 if (val === null || typeof val !== "object" || Array.isArray(val)) {
21372137 return invalidValue(l(ref || "object"), val, key, parent);
21382138 }
2139- const result: any = {};
2139+ const result: any = Object.create(null);
21402140 Object.getOwnPropertyNames(props).forEach(key => {
21412141 const prop = props[key];
21422142 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -2147,7 +2147,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
21472147 result[key] = transform(val[key], additional, getProps, key, ref);
21482148 }
21492149 });
2150- return result;
2150+ return Object.setPrototypeOf(result, Object.prototype);
21512151 }
21522152
21532153 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -1122,7 +1122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
11221122 if (val === null || typeof val !== "object" || Array.isArray(val)) {
11231123 return invalidValue(l(ref || "object"), val, key, parent);
11241124 }
1125- const result: any = {};
1125+ const result: any = Object.create(null);
11261126 Object.getOwnPropertyNames(props).forEach(key => {
11271127 const prop = props[key];
11281128 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -1133,7 +1133,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
11331133 result[key] = transform(val[key], additional, getProps, key, ref);
11341134 }
11351135 });
1136- return result;
1136+ return Object.setPrototypeOf(result, Object.prototype);
11371137 }
11381138
11391139 if (typ === "any") return val;
Test case

test/inputs/schema/light.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -72,6 +72,14 @@ encodeLightParams x =
7272
7373 --- encoder helpers
7474
75+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
76+makeDictEncoder f m r =
77+ r
78+ |> Dict.toList
79+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
80+ |> String.join ","
81+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
82+
7583 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7684 makeNullableEncoder f m =
7785 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Test case

test/inputs/schema/list.schema

3 generated files · +6 −6
Mschema-flowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/schema/min-max-items.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -79,6 +79,14 @@ encodeUnionItem x = case x of
7979
8080 --- encoder helpers
8181
82+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
83+makeDictEncoder f m r =
84+ r
85+ |> Dict.toList
86+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
87+ |> String.join ","
88+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
89+
8290 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
8391 makeNullableEncoder f m =
8492 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -114,7 +114,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
114114 if (val === null || typeof val !== "object" || Array.isArray(val)) {
115115 return invalidValue(l(ref || "object"), val, key, parent);
116116 }
117- const result: any = {};
117+ const result: any = Object.create(null);
118118 Object.getOwnPropertyNames(props).forEach(key => {
119119 const prop = props[key];
120120 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -125,7 +125,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
125125 result[key] = transform(val[key], additional, getProps, key, ref);
126126 }
127127 });
128- return result;
128+ return Object.setPrototypeOf(result, Object.prototype);
129129 }
130130
131131 if (typ === "any") return val;
Test case

test/inputs/schema/minmax-integer.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -71,6 +71,14 @@ encodeQuickType x =
7171
7272 --- encoder helpers
7373
74+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
75+makeDictEncoder f m r =
76+ r
77+ |> Dict.toList
78+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
79+ |> String.join ","
80+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
81+
7482 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7583 makeNullableEncoder f m =
7684 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/schema/minmax.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -71,6 +71,14 @@ encodeQuickType x =
7171
7272 --- encoder helpers
7373
74+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
75+makeDictEncoder f m r =
76+ r
77+ |> Dict.toList
78+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
79+ |> String.join ","
80+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
81+
7482 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7583 makeNullableEncoder f m =
7684 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/schema/minmaxlength.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -88,6 +88,14 @@ encodeInUnion x = case x of
8888
8989 --- encoder helpers
9090
91+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
92+makeDictEncoder f m r =
93+ r
94+ |> Dict.toList
95+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
96+ |> String.join ","
97+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
98+
9199 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
92100 makeNullableEncoder f m =
93101 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Test case

test/inputs/schema/multi-type-enum.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -96,6 +96,14 @@ encodeFooEnum x = case x of
9696
9797 --- encoder helpers
9898
99+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
100+makeDictEncoder f m r =
101+ r
102+ |> Dict.toList
103+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
104+ |> String.join ","
105+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
106+
99107 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
100108 makeNullableEncoder f m =
101109 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/schema/mutually-recursive.schema

3 generated files · +6 −6
Mschema-flowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/schema/nested-intersection-union.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -75,6 +75,14 @@ encodeItem x =
7575
7676 --- encoder helpers
7777
78+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
79+makeDictEncoder f m r =
80+ r
81+ |> Dict.toList
82+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
83+ |> String.join ","
84+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
85+
7886 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7987 makeNullableEncoder f m =
8088 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/schema/non-standard-ref.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -56,6 +56,14 @@ encodeQuickType x =
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/nullable-optional-one-of.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -73,6 +73,14 @@ encodeKind x = case x of
7373
7474 --- encoder helpers
7575
76+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
77+makeDictEncoder f m r =
78+ r
79+ |> Dict.toList
80+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
81+ |> String.join ","
82+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
83+
7684 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7785 makeNullableEncoder f m =
7886 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/schema/object-type-required.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -71,6 +71,14 @@ encodeEmpty x =
7171
7272 --- encoder helpers
7373
74+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
75+makeDictEncoder f m r =
76+ r
77+ |> Dict.toList
78+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
79+ |> String.join ","
80+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
81+
7482 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7583 makeNullableEncoder f m =
7684 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/optional-any.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -53,6 +53,14 @@ encodeQuickType x =
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/optional-const-ref.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -87,6 +87,14 @@ encodeCoordinate x =
8787
8888 --- encoder helpers
8989
90+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
91+makeDictEncoder f m r =
92+ r
93+ |> Dict.toList
94+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
95+ |> String.join ","
96+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
97+
9098 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
9199 makeNullableEncoder f m =
92100 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 if (val === null || typeof val !== "object" || Array.isArray(val)) {
119119 return invalidValue(l(ref || "object"), val, key, parent);
120120 }
121- const result: any = {};
121+ const result: any = Object.create(null);
122122 Object.getOwnPropertyNames(props).forEach(key => {
123123 const prop = props[key];
124124 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -129,7 +129,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
129129 result[key] = transform(val[key], additional, getProps, key, ref);
130130 }
131131 });
132- return result;
132+ return Object.setPrototypeOf(result, Object.prototype);
133133 }
134134
135135 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 if (val === null || typeof val !== "object" || Array.isArray(val)) {
119119 return invalidValue(l(ref || "object"), val, key, parent);
120120 }
121- const result: any = {};
121+ const result: any = Object.create(null);
122122 Object.getOwnPropertyNames(props).forEach(key => {
123123 const prop = props[key];
124124 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -129,7 +129,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
129129 result[key] = transform(val[key], additional, getProps, key, ref);
130130 }
131131 });
132- return result;
132+ return Object.setPrototypeOf(result, Object.prototype);
133133 }
134134
135135 if (typ === "any") return val;
Test case

test/inputs/schema/optional-constraints.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -62,6 +62,14 @@ encodeQuickType x =
6262
6363 --- encoder helpers
6464
65+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
66+makeDictEncoder f m r =
67+ r
68+ |> Dict.toList
69+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
70+ |> String.join ","
71+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
72+
6573 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6674 makeNullableEncoder f m =
6775 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/schema/optional-date-time.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -65,6 +65,14 @@ encodeQuickType x =
6565
6666 --- encoder helpers
6767
68+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
69+makeDictEncoder f m r =
70+ r
71+ |> Dict.toList
72+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
73+ |> String.join ","
74+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
75+
6876 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6977 makeNullableEncoder f m =
7078 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/schema/optional-enum.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -73,6 +73,14 @@ encodeShortcut x = case x of
7373
7474 --- encoder helpers
7575
76+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
77+makeDictEncoder f m r =
78+ r
79+ |> Dict.toList
80+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
81+ |> String.join ","
82+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
83+
7684 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7785 makeNullableEncoder f m =
7886 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/optional-property.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -107,7 +107,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
107107 if (val === null || typeof val !== "object" || Array.isArray(val)) {
108108 return invalidValue(l(ref || "object"), val, key, parent);
109109 }
110- const result: any = {};
110+ const result: any = Object.create(null);
111111 Object.getOwnPropertyNames(props).forEach(key => {
112112 const prop = props[key];
113113 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 result[key] = transform(val[key], additional, getProps, key, ref);
119119 }
120120 });
121- return result;
121+ return Object.setPrototypeOf(result, Object.prototype);
122122 }
123123
124124 if (typ === "any") return val;
Test case

test/inputs/schema/pattern.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -75,6 +75,14 @@ encodeRegExp x =
7575
7676 --- encoder helpers
7777
78+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
79+makeDictEncoder f m r =
80+ r
81+ |> Dict.toList
82+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
83+ |> String.join ","
84+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
85+
7886 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7987 makeNullableEncoder f m =
8088 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -115,7 +115,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
115115 if (val === null || typeof val !== "object" || Array.isArray(val)) {
116116 return invalidValue(l(ref || "object"), val, key, parent);
117117 }
118- const result: any = {};
118+ const result: any = Object.create(null);
119119 Object.getOwnPropertyNames(props).forEach(key => {
120120 const prop = props[key];
121121 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 result[key] = transform(val[key], additional, getProps, key, ref);
127127 }
128128 });
129- return result;
129+ return Object.setPrototypeOf(result, Object.prototype);
130130 }
131131
132132 if (typ === "any") return val;
Test case

test/inputs/schema/postman-collection.schema

3 generated files · +6 −6
Mschema-flowdefault / TopLevel.js+2 −2
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 if (val === null || typeof val !== "object" || Array.isArray(val)) {
119119 return invalidValue(l(ref || "object"), val, key, parent);
120120 }
121- const result: any = {};
121+ const result: any = Object.create(null);
122122 Object.getOwnPropertyNames(props).forEach(key => {
123123 const prop = props[key];
124124 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -129,7 +129,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
129129 result[key] = transform(val[key], additional, getProps, key, ref);
130130 }
131131 });
132- return result;
132+ return Object.setPrototypeOf(result, Object.prototype);
133133 }
134134
135135 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 if (val === null || typeof val !== "object" || Array.isArray(val)) {
119119 return invalidValue(l(ref || "object"), val, key, parent);
120120 }
121- const result: any = {};
121+ const result: any = Object.create(null);
122122 Object.getOwnPropertyNames(props).forEach(key => {
123123 const prop = props[key];
124124 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -129,7 +129,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
129129 result[key] = transform(val[key], additional, getProps, key, ref);
130130 }
131131 });
132- return result;
132+ return Object.setPrototypeOf(result, Object.prototype);
133133 }
134134
135135 if (typ === "any") return val;
Test case

test/inputs/schema/prefix-items.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -70,6 +70,14 @@ encodeOpen x = case x of
7070
7171 --- encoder helpers
7272
73+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
74+makeDictEncoder f m r =
75+ r
76+ |> Dict.toList
77+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
78+ |> String.join ","
79+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
80+
7381 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7482 makeNullableEncoder f m =
7583 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/schema/recursive-union-flattening.schema

3 generated files · +6 −6
Mschema-flowdefault / TopLevel.js+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 if (val === null || typeof val !== "object" || Array.isArray(val)) {
122122 return invalidValue(l(ref || "object"), val, key, parent);
123123 }
124- const result: any = {};
124+ const result: any = Object.create(null);
125125 Object.getOwnPropertyNames(props).forEach(key => {
126126 const prop = props[key];
127127 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -132,7 +132,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
132132 result[key] = transform(val[key], additional, getProps, key, ref);
133133 }
134134 });
135- return result;
135+ return Object.setPrototypeOf(result, Object.prototype);
136136 }
137137
138138 if (typ === "any") return val;
Test case

test/inputs/schema/ref-id-files.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/ref-remote.schema

3 generated files · +6 −6
Mschema-flowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/schema/renaming-bug.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -385,6 +385,14 @@ encodeName x = case x of
385385
386386 --- encoder helpers
387387
388+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
389+makeDictEncoder f m r =
390+ r
391+ |> Dict.toList
392+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
393+ |> String.join ","
394+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
395+
388396 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
389397 makeNullableEncoder f m =
390398 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -210,7 +210,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
210210 if (val === null || typeof val !== "object" || Array.isArray(val)) {
211211 return invalidValue(l(ref || "object"), val, key, parent);
212212 }
213- const result: any = {};
213+ const result: any = Object.create(null);
214214 Object.getOwnPropertyNames(props).forEach(key => {
215215 const prop = props[key];
216216 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -221,7 +221,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
221221 result[key] = transform(val[key], additional, getProps, key, ref);
222222 }
223223 });
224- return result;
224+ return Object.setPrototypeOf(result, Object.prototype);
225225 }
226226
227227 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -195,7 +195,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
195195 if (val === null || typeof val !== "object" || Array.isArray(val)) {
196196 return invalidValue(l(ref || "object"), val, key, parent);
197197 }
198- const result: any = {};
198+ const result: any = Object.create(null);
199199 Object.getOwnPropertyNames(props).forEach(key => {
200200 const prop = props[key];
201201 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -206,7 +206,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
206206 result[key] = transform(val[key], additional, getProps, key, ref);
207207 }
208208 });
209- return result;
209+ return Object.setPrototypeOf(result, Object.prototype);
210210 }
211211
212212 if (typ === "any") return val;
Test case

test/inputs/schema/required-draft3.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/required-non-properties.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -53,6 +53,14 @@ encodeQuickType x =
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/schema/required.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/rust-cycle-breaker-union.schema

3 generated files · +6 −6
Mschema-flowdefault / TopLevel.js+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Test case

test/inputs/schema/schema-constraints.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -53,6 +53,14 @@ encodeQuickType x =
5353
5454 --- encoder helpers
5555
56+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
57+makeDictEncoder f m r =
58+ r
59+ |> Dict.toList
60+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
61+ |> String.join ","
62+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
63+
5664 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5765 makeNullableEncoder f m =
5866 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -109,7 +109,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
109109 if (val === null || typeof val !== "object" || Array.isArray(val)) {
110110 return invalidValue(l(ref || "object"), val, key, parent);
111111 }
112- const result: any = {};
112+ const result: any = Object.create(null);
113113 Object.getOwnPropertyNames(props).forEach(key => {
114114 const prop = props[key];
115115 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -120,7 +120,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
120120 result[key] = transform(val[key], additional, getProps, key, ref);
121121 }
122122 });
123- return result;
123+ return Object.setPrototypeOf(result, Object.prototype);
124124 }
125125
126126 if (typ === "any") return val;
Test case

test/inputs/schema/simple-ref.schema

3 generated files · +6 −6
Mschema-flowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/schema/strict-optional.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -50,6 +50,14 @@ encodeQuickType x =
5050
5151 --- encoder helpers
5252
53+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
54+makeDictEncoder f m r =
55+ r
56+ |> Dict.toList
57+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
58+ |> String.join ","
59+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
60+
5361 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
5462 makeNullableEncoder f m =
5563 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/top-level-array.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -59,6 +59,14 @@ encodeTextClassificationOutputElement x =
5959
6060 --- encoder helpers
6161
62+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
63+makeDictEncoder f m r =
64+ r
65+ |> Dict.toList
66+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
67+ |> String.join ","
68+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
69+
6270 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6371 makeNullableEncoder f m =
6472 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -111,7 +111,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
111111 if (val === null || typeof val !== "object" || Array.isArray(val)) {
112112 return invalidValue(l(ref || "object"), val, key, parent);
113113 }
114- const result: any = {};
114+ const result: any = Object.create(null);
115115 Object.getOwnPropertyNames(props).forEach(key => {
116116 const prop = props[key];
117117 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -122,7 +122,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
122122 result[key] = transform(val[key], additional, getProps, key, ref);
123123 }
124124 });
125- return result;
125+ return Object.setPrototypeOf(result, Object.prototype);
126126 }
127127
128128 if (typ === "any") return val;
Test case

test/inputs/schema/top-level-enum.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -57,6 +57,14 @@ encodeQuickType x = case x of
5757
5858 --- encoder helpers
5959
60+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
61+makeDictEncoder f m r =
62+ r
63+ |> Dict.toList
64+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
65+ |> String.join ","
66+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
67+
6068 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6169 makeNullableEncoder f m =
6270 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Test case

test/inputs/schema/top-level-primitive-array.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -40,6 +40,14 @@ quickTypeToString r = Jenc.encode 0 (Jenc.list Jenc.string r)
4040
4141 --- encoder helpers
4242
43+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
44+makeDictEncoder f m r =
45+ r
46+ |> Dict.toList
47+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
48+ |> String.join ","
49+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
50+
4351 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
4452 makeNullableEncoder f m =
4553 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -105,7 +105,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
105105 if (val === null || typeof val !== "object" || Array.isArray(val)) {
106106 return invalidValue(l(ref || "object"), val, key, parent);
107107 }
108- const result: any = {};
108+ const result: any = Object.create(null);
109109 Object.getOwnPropertyNames(props).forEach(key => {
110110 const prop = props[key];
111111 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -116,7 +116,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
116116 result[key] = transform(val[key], additional, getProps, key, ref);
117117 }
118118 });
119- return result;
119+ return Object.setPrototypeOf(result, Object.prototype);
120120 }
121121
122122 if (typ === "any") return val;
Test case

test/inputs/schema/top-level-primitive.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -40,6 +40,14 @@ quickTypeToString r = Jenc.encode 0 (Jenc.float r)
4040
4141 --- encoder helpers
4242
43+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
44+makeDictEncoder f m r =
45+ r
46+ |> Dict.toList
47+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
48+ |> String.join ","
49+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
50+
4351 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
4452 makeNullableEncoder f m =
4553 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -108,7 +108,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
108108 if (val === null || typeof val !== "object" || Array.isArray(val)) {
109109 return invalidValue(l(ref || "object"), val, key, parent);
110110 }
111- const result: any = {};
111+ const result: any = Object.create(null);
112112 Object.getOwnPropertyNames(props).forEach(key => {
113113 const prop = props[key];
114114 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -119,7 +119,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
119119 result[key] = transform(val[key], additional, getProps, key, ref);
120120 }
121121 });
122- return result;
122+ return Object.setPrototypeOf(result, Object.prototype);
123123 }
124124
125125 if (typ === "any") return val;
Test case

test/inputs/schema/tuple.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -67,6 +67,14 @@ encodeTuple x = case x of
6767
6868 --- encoder helpers
6969
70+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
71+makeDictEncoder f m r =
72+ r
73+ |> Dict.toList
74+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
75+ |> String.join ","
76+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
77+
7078 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7179 makeNullableEncoder f m =
7280 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/unevaluated-properties.schema

4 generated files · +15 −7
Mschema-elmdefault / QuickType.elm+9 −1
@@ -88,7 +88,7 @@ encodeConfig x =
8888 Jenc.object
8989 [ ("closed", makeNullableEncoder encodeClosed x.closed)
9090 , ("name", makeNullableEncoder Jenc.string x.name)
91- , ("settings", makeNullableEncoder (Jenc.dict identity (Jenc.list encodeItem)) x.settings)
91+ , ("settings", makeNullableEncoder (makeDictEncoder identity (Jenc.list encodeItem)) x.settings)
9292 ]
9393
9494 closed : Jdec.Decoder Closed
@@ -138,6 +138,14 @@ encodeItem x =
138138
139139 --- encoder helpers
140140
141+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
142+makeDictEncoder f m r =
143+ r
144+ |> Dict.toList
145+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
146+ |> String.join ","
147+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
148+
141149 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
142150 makeNullableEncoder f m =
143151 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -126,7 +126,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
126126 if (val === null || typeof val !== "object" || Array.isArray(val)) {
127127 return invalidValue(l(ref || "object"), val, key, parent);
128128 }
129- const result: any = {};
129+ const result: any = Object.create(null);
130130 Object.getOwnPropertyNames(props).forEach(key => {
131131 const prop = props[key];
132132 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -137,7 +137,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
137137 result[key] = transform(val[key], additional, getProps, key, ref);
138138 }
139139 });
140- return result;
140+ return Object.setPrototypeOf(result, Object.prototype);
141141 }
142142
143143 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 if (val === null || typeof val !== "object" || Array.isArray(val)) {
124124 return invalidValue(l(ref || "object"), val, key, parent);
125125 }
126- const result: any = {};
126+ const result: any = Object.create(null);
127127 Object.getOwnPropertyNames(props).forEach(key => {
128128 const prop = props[key];
129129 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -134,7 +134,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
134134 result[key] = transform(val[key], additional, getProps, key, ref);
135135 }
136136 });
137- return result;
137+ return Object.setPrototypeOf(result, Object.prototype);
138138 }
139139
140140 if (typ === "any") return val;
Test case

test/inputs/schema/unicode-codepoint-length.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -56,6 +56,14 @@ encodeQuickType x =
5656
5757 --- encoder helpers
5858
59+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
60+makeDictEncoder f m r =
61+ r
62+ |> Dict.toList
63+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
64+ |> String.join ","
65+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
66+
5967 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6068 makeNullableEncoder f m =
6169 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/union-int-double.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -70,6 +70,14 @@ encodeValue x = case x of
7070
7171 --- encoder helpers
7272
73+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
74+makeDictEncoder f m r =
75+ r
76+ |> Dict.toList
77+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
78+ |> String.join ","
79+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
80+
7381 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
7482 makeNullableEncoder f m =
7583 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -110,7 +110,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
110110 if (val === null || typeof val !== "object" || Array.isArray(val)) {
111111 return invalidValue(l(ref || "object"), val, key, parent);
112112 }
113- const result: any = {};
113+ const result: any = Object.create(null);
114114 Object.getOwnPropertyNames(props).forEach(key => {
115115 const prop = props[key];
116116 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -121,7 +121,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
121121 result[key] = transform(val[key], additional, getProps, key, ref);
122122 }
123123 });
124- return result;
124+ return Object.setPrototypeOf(result, Object.prototype);
125125 }
126126
127127 if (typ === "any") return val;
Test case

test/inputs/schema/union-list.schema

3 generated files · +6 −6
Mschema-flowdefault / TopLevel.js+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -113,7 +113,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
113113 if (val === null || typeof val !== "object" || Array.isArray(val)) {
114114 return invalidValue(l(ref || "object"), val, key, parent);
115115 }
116- const result: any = {};
116+ const result: any = Object.create(null);
117117 Object.getOwnPropertyNames(props).forEach(key => {
118118 const prop = props[key];
119119 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -124,7 +124,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
124124 result[key] = transform(val[key], additional, getProps, key, ref);
125125 }
126126 });
127- return result;
127+ return Object.setPrototypeOf(result, Object.prototype);
128128 }
129129
130130 if (typ === "any") return val;
Test case

test/inputs/schema/union.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -62,6 +62,14 @@ encodeQuickTypeElement x =
6262
6363 --- encoder helpers
6464
65+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
66+makeDictEncoder f m r =
67+ r
68+ |> Dict.toList
69+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
70+ |> String.join ","
71+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
72+
6573 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6674 makeNullableEncoder f m =
6775 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -112,7 +112,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
112112 if (val === null || typeof val !== "object" || Array.isArray(val)) {
113113 return invalidValue(l(ref || "object"), val, key, parent);
114114 }
115- const result: any = {};
115+ const result: any = Object.create(null);
116116 Object.getOwnPropertyNames(props).forEach(key => {
117117 const prop = props[key];
118118 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -123,7 +123,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
123123 result[key] = transform(val[key], additional, getProps, key, ref);
124124 }
125125 });
126- return result;
126+ return Object.setPrototypeOf(result, Object.prototype);
127127 }
128128
129129 if (typ === "any") return val;
Test case

test/inputs/schema/uuid.schema

4 generated files · +14 −6
Mschema-elmdefault / QuickType.elm+8 −0
@@ -65,6 +65,14 @@ encodeQuickType x =
6565
6666 --- encoder helpers
6767
68+makeDictEncoder : (String -> String) -> (a -> Jenc.Value) -> Dict String a -> Jenc.Value
69+makeDictEncoder f m r =
70+ r
71+ |> Dict.toList
72+ |> List.map (\( x, y ) -> Jenc.encode 0 (Jenc.string (f x)) ++ ":" ++ Jenc.encode 0 (m y))
73+ |> String.join ","
74+ |> (\str -> Jdec.decodeString Jdec.value ("{" ++ str ++ "}") |> Result.withDefault Jenc.null)
75+
6876 makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
6977 makeNullableEncoder f m =
7078 case m of
Mschema-flowdefault / TopLevel.js+2 −2
@@ -118,7 +118,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
118118 if (val === null || typeof val !== "object" || Array.isArray(val)) {
119119 return invalidValue(l(ref || "object"), val, key, parent);
120120 }
121- const result: any = {};
121+ const result: any = Object.create(null);
122122 Object.getOwnPropertyNames(props).forEach(key => {
123123 const prop = props[key];
124124 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -129,7 +129,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
129129 result[key] = transform(val[key], additional, getProps, key, ref);
130130 }
131131 });
132- return result;
132+ return Object.setPrototypeOf(result, Object.prototype);
133133 }
134134
135135 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -117,7 +117,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
117117 if (val === null || typeof val !== "object" || Array.isArray(val)) {
118118 return invalidValue(l(ref || "object"), val, key, parent);
119119 }
120- const result: any = {};
120+ const result: any = Object.create(null);
121121 Object.getOwnPropertyNames(props).forEach(key => {
122122 const prop = props[key];
123123 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -128,7 +128,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
128128 result[key] = transform(val[key], additional, getProps, key, ref);
129129 }
130130 });
131- return result;
131+ return Object.setPrototypeOf(result, Object.prototype);
132132 }
133133
134134 if (typ === "any") return val;
Test case

test/inputs/schema/vega-lite.schema

3 generated files · +6 −6
Mschema-flowdefault / TopLevel.js+2 −2
@@ -6199,7 +6199,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
61996199 if (val === null || typeof val !== "object" || Array.isArray(val)) {
62006200 return invalidValue(l(ref || "object"), val, key, parent);
62016201 }
6202- const result: any = {};
6202+ const result: any = Object.create(null);
62036203 Object.getOwnPropertyNames(props).forEach(key => {
62046204 const prop = props[key];
62056205 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -6210,7 +6210,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
62106210 result[key] = transform(val[key], additional, getProps, key, ref);
62116211 }
62126212 });
6213- return result;
6213+ return Object.setPrototypeOf(result, Object.prototype);
62146214 }
62156215
62166216 if (typ === "any") return val;
Mschema-javascriptdefault / TopLevel.js+2 −2
@@ -101,7 +101,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
101101 if (val === null || typeof val !== "object" || Array.isArray(val)) {
102102 return invalidValue(l(ref || "object"), val, key, parent);
103103 }
104- const result = {};
104+ const result = Object.create(null);
105105 Object.getOwnPropertyNames(props).forEach(key => {
106106 const prop = props[key];
107107 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -112,7 +112,7 @@ function transform(val, typ, getProps, key = '', parent = '') {
112112 result[key] = transform(val[key], additional, getProps, key, ref);
113113 }
114114 });
115- return result;
115+ return Object.setPrototypeOf(result, Object.prototype);
116116 }
117117
118118 if (typ === "any") return val;
Mschema-typescriptdefault / TopLevel.ts+2 −2
@@ -5956,7 +5956,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
59565956 if (val === null || typeof val !== "object" || Array.isArray(val)) {
59575957 return invalidValue(l(ref || "object"), val, key, parent);
59585958 }
5959- const result: any = {};
5959+ const result: any = Object.create(null);
59605960 Object.getOwnPropertyNames(props).forEach(key => {
59615961 const prop = props[key];
59625962 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
@@ -5967,7 +5967,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any
59675967 result[key] = transform(val[key], additional, getProps, key, ref);
59685968 }
59695969 });
5970- return result;
5970+ return Object.setPrototypeOf(result, Object.prototype);
59715971 }
59725972
59735973 if (typ === "any") return val;
No generated files match these filters.