Mirror: The small sibling of the graphql package, slimmed down for client-side libraries.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix discrepancies in visitor implementation

+10 -10
+10 -10
alias/language/visitor.mjs
··· 16 16 } 17 17 18 18 function traverse(node, key, parent) { 19 + let hasEdited = false; 19 20 let result; 20 21 21 22 result = callback(node, key, parent, false); 22 23 if (result === false) { 23 24 return; 24 25 } else if (result && typeof result.kind === 'string') { 26 + hasEdited = true; 25 27 node = result; 26 28 } 27 29 28 30 ancestors.push(node); 29 - const copy = {}; 31 + const copy = { ...node }; 30 32 31 - let hasEdited = false; 32 33 for (const nodeKey in node) { 33 - const value = node[nodeKey]; 34 - 35 - let newValue; 34 + let value = node[nodeKey]; 36 35 path.push(nodeKey); 37 36 if (Array.isArray(value)) { 38 - newValue = value.slice(); 37 + value = value.slice(); 39 38 for (let index = 0; index < value.length; index++) { 40 39 if (value[index] != null && typeof value[index].kind === 'string') { 41 40 path.push(index); 42 41 result = traverse(value[index], index, node); 43 42 path.pop(); 44 43 if (result !== undefined) { 45 - newValue[index] = result; 44 + value[index] = result; 46 45 hasEdited = true; 47 46 } 48 47 } ··· 51 50 } else if (value != null && typeof value.kind === 'string') { 52 51 result = traverse(value, nodeKey, node); 53 52 if (result !== undefined) { 54 - newValue = result; 53 + value = result; 55 54 hasEdited = true; 56 55 } 57 56 } 58 57 59 58 path.pop(); 60 - copy[nodeKey] = hasEdited ? newValue : value; 59 + if (hasEdited) copy[nodeKey] = value; 61 60 } 62 61 63 62 ancestors.pop(); 64 63 65 64 if (hasEdited) node = copy; 66 - return callback(node, key, parent, true); 65 + result = callback(node, key, parent, true); 66 + return hasEdited && result === undefined ? node : result; 67 67 } 68 68 69 69 try {