MCPcopy Create free account
hub / github.com/browserify/static-module / finish

Function finish

index.js:64–164  ·  view source on GitHub ↗
(src)

Source from the content-addressed store, hash-verified

62 }), output);
63
64 function finish (src) {
65 var pos = 0;
66 src = String(src);
67
68 moduleBindings.forEach(function (binding) {
69 if (binding.isReferenced()) {
70 return;
71 }
72 var node = binding.initializer;
73 if (node.type === 'VariableDeclarator') {
74 var i = node.parent.declarations.indexOf(node);
75 if (node.parent.declarations.length === 1) {
76 // remove the entire declaration
77 updates.push({
78 start: node.parent.start,
79 offset: node.parent.end - node.parent.start,
80 stream: st()
81 });
82 } else if (i === node.parent.declarations.length - 1) {
83 updates.push({
84 // remove ", a = 1"
85 start: node.parent.declarations[i - 1].end,
86 offset: node.end - node.parent.declarations[i - 1].end,
87 stream: st()
88 });
89 } else {
90 updates.push({
91 // remove "a = 1, "
92 start: node.start,
93 offset: node.parent.declarations[i + 1].start - node.start,
94 stream: st()
95 });
96 }
97 } else if (node.parent.type === 'SequenceExpression' && node.parent.expressions.length > 1) {
98 var i = node.parent.expressions.indexOf(node);
99 if (i === node.parent.expressions.length - 1) {
100 updates.push({
101 // remove ", a = 1"
102 start: node.parent.expressions[i - 1].end,
103 offset: node.end - node.parent.expressions[i - 1].end,
104 stream: st()
105 });
106 } else {
107 updates.push({
108 // remove "a = 1, "
109 start: node.start,
110 offset: node.parent.expressions[i + 1].start - node.start,
111 stream: st()
112 });
113 }
114 } else {
115 if (node.parent.type === 'ExpressionStatement') node = node.parent;
116 updates.push({
117 start: node.start,
118 offset: node.end - node.start,
119 stream: st()
120 });
121 }

Callers 1

index.jsFile · 0.85

Calls 2

stFunction · 0.85
doneFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…