···11+---
22+'@urql/core': patch
33+---
44+55+Remove `for-of` syntax from `@urql/core` helpers for JSC memory reduction.
+2-1
packages/core/src/client.ts
···649649 } else {
650650 // If the current result has queued up an operation of the same
651651 // key, then `stale` refers to it
652652- for (const operation of queue) {
652652+ for (let i = 0; i < queue.length; i++) {
653653+ const operation = queue[i];
653654 if (operation.key === result.operation.key) {
654655 dispatched.delete(operation.key);
655656 break;
+3-2
packages/core/src/gql.ts
···7878 }
79798080 source.unshift(keyDocument(body));
8181- for (const document of source) {
8282- for (const definition of document.definitions) {
8181+ for (let i = 0; i < source.length; i++) {
8282+ for (let j = 0; j < source[i].definitions.length; j++) {
8383+ const definition = source[i].definitions[j];
8384 if (definition.kind === Kind.FRAGMENT_DEFINITION) {
8485 const name = definition.name.value;
8586 const value = stringifyDocument(definition);
+3-1
packages/core/src/utils/collectTypenames.ts
···5566const collectTypes = (obj: EntityLike | EntityLike[], types: Set<string>) => {
77 if (Array.isArray(obj)) {
88- for (const item of obj) collectTypes(item, types);
88+ for (let i = 0, l = obj.length; i < l; i++) {
99+ collectTypes(obj[i], types);
1010+ }
911 } else if (typeof obj === 'object' && obj !== null) {
1012 for (const key in obj) {
1113 if (key === '__typename' && typeof obj[key] === 'string') {
+2-2
packages/core/src/utils/error.ts
···88 let error = '';
99 if (networkErr) return `[Network] ${networkErr.message}`;
1010 if (graphQlErrs) {
1111- for (const err of graphQlErrs) {
1111+ for (let i = 0, l = graphQlErrs.length; i < l; i++) {
1212 if (error) error += '\n';
1313- error += `[GraphQL] ${err.message}`;
1313+ error += `[GraphQL] ${graphQlErrs[i].message}`;
1414 }
1515 }
1616 return error;
+6-4
packages/core/src/utils/formatDocument.ts
···1616): FormattedNode<T> => {
1717 if ('definitions' in node) {
1818 const definitions: FormattedNode<DefinitionNode>[] = [];
1919- for (const definition of node.definitions) {
2020- const newDefinition = formatNode(definition);
1919+ for (let i = 0, l = node.definitions.length; i < l; i++) {
2020+ const newDefinition = formatNode(node.definitions[i]);
2121 definitions.push(newDefinition);
2222 }
2323···2727 if ('directives' in node && node.directives && node.directives.length) {
2828 const directives: DirectiveNode[] = [];
2929 const _directives = {};
3030- for (const directive of node.directives) {
3030+ for (let i = 0, l = node.directives.length; i < l; i++) {
3131+ const directive = node.directives[i];
3132 let name = directive.name.value;
3233 if (name[0] !== '_') {
3334 directives.push(directive);
···4344 const selections: FormattedNode<SelectionNode>[] = [];
4445 let hasTypename = node.kind === Kind.OPERATION_DEFINITION;
4546 if (node.selectionSet) {
4646- for (const selection of node.selectionSet.selections || []) {
4747+ for (let i = 0, l = node.selectionSet.selections.length; i < l; i++) {
4848+ const selection = node.selectionSet.selections[i];
4749 hasTypename =
4850 hasTypename ||
4951 (selection.kind === Kind.FIELD &&
+4-2
packages/core/src/utils/request.ts
···180180 * @returns the operation's name contained within the document, or `undefined`
181181 */
182182export const getOperationName = (query: DocumentNode): string | undefined => {
183183- for (const node of query.definitions) {
183183+ for (let i = 0, l = query.definitions.length; i < l; i++) {
184184+ const node = query.definitions[i];
184185 if (node.kind === Kind.OPERATION_DEFINITION) {
185186 return node.name ? node.name.value : undefined;
186187 }
···192193 * @returns the operation's type contained within the document, or `undefined`
193194 */
194195export const getOperationType = (query: DocumentNode): string | undefined => {
195195- for (const node of query.definitions) {
196196+ for (let i = 0, l = query.definitions.length; i < l; i++) {
197197+ const node = query.definitions[i];
196198 if (node.kind === Kind.OPERATION_DEFINITION) {
197199 return node.operation;
198200 }
+9-3
packages/core/src/utils/result.ts
···53535454const deepMerge = (target: any, source: any): any => {
5555 if (typeof target === 'object' && target != null) {
5656+ if (Array.isArray(target)) {
5757+ target = [...target];
5858+ for (let i = 0, l = source.length; i < l; i++)
5959+ target[i] = deepMerge(target[i], source[i]);
6060+ }
5661 if (
5762 !target.constructor ||
5863 target.constructor === Object ||
5964 Array.isArray(target)
6065 ) {
6161- target = Array.isArray(target) ? [...target] : { ...target };
6262- for (const key of Object.keys(source))
6666+ target = { ...target };
6767+ for (const key in source)
6368 target[key] = deepMerge(target[key], source[key]);
6469 return target;
6570 }
···108113109114 const withData = { data: prevResult.data };
110115 if (incremental) {
111111- for (const patch of incremental) {
116116+ for (let i = 0, l = incremental.length; i < l; i++) {
117117+ const patch = incremental[i];
112118 if (Array.isArray(patch.errors)) {
113119 errors.push(...(patch.errors as any));
114120 }
+6-6
packages/core/src/utils/variables.ts
···1212 return stringify(x.toJSON(), includeFiles);
1313 } else if (Array.isArray(x)) {
1414 let out = '[';
1515- for (const value of x) {
1515+ for (let i = 0, l = x.length; i < l; i++) {
1616 if (out.length > 1) out += ',';
1717- out += stringify(value, includeFiles) || 'null';
1717+ out += stringify(x[i], includeFiles) || 'null';
1818 }
1919 out += ']';
2020 return out;
···39394040 seen.add(x);
4141 let out = '{';
4242- for (const key of keys) {
4343- const value = stringify(x[key], includeFiles);
4242+ for (let i = 0, l = keys.length; i < l; i++) {
4343+ const value = stringify(x[keys[i]], includeFiles);
4444 if (value) {
4545 if (out.length > 1) out += ',';
4646- out += stringify(key, includeFiles) + ':' + value;
4646+ out += stringify(keys[i], includeFiles) + ':' + value;
4747 }
4848 }
4949···6262 map.set(path, x as File | Blob);
6363 } else {
6464 seen.add(x);
6565- for (const key of Object.keys(x)) extract(map, `${path}.${key}`, x[key]);
6565+ for (const key in x) extract(map, `${path}.${key}`, x[key]);
6666 }
6767};
6868