MCPcopy
hub / github.com/livebud/bud / unpack_destructuring

Function unpack_destructuring

package/svelte/compiler.js:15766–15854  ·  view source on GitHub ↗
({ contexts, node: node2, modifier = (node3) => node3, default_modifier = (node3) => node3, scope: scope2, component })

Source from the content-addressed store, hash-verified

15764 return "func";
15765 }
15766 function unpack_destructuring({ contexts, node: node2, modifier = (node3) => node3, default_modifier = (node3) => node3, scope: scope2, component }) {
15767 if (!node2)
15768 return;
15769 if (node2.type === "Identifier") {
15770 contexts.push({
15771 key: node2,
15772 modifier,
15773 default_modifier
15774 });
15775 } else if (node2.type === "RestElement") {
15776 contexts.push({
15777 key: node2.argument,
15778 modifier,
15779 default_modifier
15780 });
15781 } else if (node2.type === "ArrayPattern") {
15782 node2.elements.forEach((element, i) => {
15783 if (element && element.type === "RestElement") {
15784 unpack_destructuring({
15785 contexts,
15786 node: element,
15787 modifier: (node3) => x`${modifier(node3)}.slice(${i})`,
15788 default_modifier,
15789 scope: scope2,
15790 component
15791 });
15792 } else if (element && element.type === "AssignmentPattern") {
15793 const n2 = contexts.length;
15794 mark_referenced(element.right, scope2, component);
15795 unpack_destructuring({
15796 contexts,
15797 node: element.left,
15798 modifier: (node3) => x`${modifier(node3)}[${i}]`,
15799 default_modifier: (node3, to_ctx) => x`${node3} !== undefined ? ${node3} : ${update_reference(contexts, n2, element.right, to_ctx)}`,
15800 scope: scope2,
15801 component
15802 });
15803 } else {
15804 unpack_destructuring({
15805 contexts,
15806 node: element,
15807 modifier: (node3) => x`${modifier(node3)}[${i}]`,
15808 default_modifier,
15809 scope: scope2,
15810 component
15811 });
15812 }
15813 });
15814 } else if (node2.type === "ObjectPattern") {
15815 const used_properties = [];
15816 node2.properties.forEach((property) => {
15817 if (property.type === "RestElement") {
15818 unpack_destructuring({
15819 contexts,
15820 node: property.argument,
15821 modifier: (node3) => x`@object_without_properties(${modifier(node3)}, [${used_properties}])`,
15822 default_modifier,
15823 scope: scope2,

Callers 2

parse_expressionMethod · 0.85
constructorMethod · 0.85

Calls 4

xFunction · 0.85
mark_referencedFunction · 0.85
update_referenceFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected