Mirror: The spec-compliant minimum of client-side GraphQL.

fix: Remove for-of syntax from `values` helpers for JSC memory reduction (#33)

* Remove for-of from values helpers

* Add changeset

Changed files
+12 -3
.changeset
src
+5
.changeset/nasty-cobras-repair.md
···
+
---
+
'@0no-co/graphql.web': patch
+
---
+
+
Remove `for-of` syntax from `valueFromTypeNode` and `valueFromASTUntyped` helpers for JSC memory reduction.
+7 -3
src/values.ts
···
return node.value;
case 'ListValue': {
const values: unknown[] = [];
-
for (const value of node.values) values.push(valueFromASTUntyped(value, variables));
+
for (let i = 0, l = node.values.length; i < l; i++)
+
values.push(valueFromASTUntyped(node.values[i], variables));
return values;
}
case 'ObjectValue': {
const obj = Object.create(null);
-
for (const field of node.fields)
+
for (let i = 0, l = node.fields.length; i < l; i++) {
+
const field = node.fields[i];
obj[field.name.value] = valueFromASTUntyped(field.value, variables);
+
}
return obj;
}
case 'Variable':
···
} else if (type.kind === 'ListType') {
if (node.kind === 'ListValue') {
const values: unknown[] = [];
-
for (const value of node.values) {
+
for (let i = 0, l = node.values.length; i < l; i++) {
+
const value = node.values[i];
const coerced = valueFromTypeNode(value, type.type, variables);
if (coerced === undefined) {
return undefined;