MCPcopy Index your code
hub / github.com/facebook/react / buildGateVersionCondition

Function buildGateVersionCondition

scripts/babel/transform-react-version-pragma.js:22–50  ·  view source on GitHub ↗
(comments)

Source from the content-addressed store, hash-verified

20 // See info about semver ranges here:
21 // https://www.npmjs.com/package/semver
22 function buildGateVersionCondition(comments) {
23 if (!comments) {
24 return null;
25 }
26
27 const resultingCondition = comments.reduce(
28 (accumulatedCondition, commentLine) => {
29 const commentStr = commentLine.value.trim();
30
31 if (!commentStr.startsWith(GATE_VERSION_STR)) {
32 return accumulatedCondition;
33 }
34
35 const condition = commentStr.slice(GATE_VERSION_STR.length);
36 if (accumulatedCondition === null) {
37 return condition;
38 }
39
40 return accumulatedCondition.concat(' ', condition);
41 },
42 null
43 );
44
45 if (resultingCondition === null) {
46 return null;
47 }
48
49 return t.stringLiteral(resultingCondition);
50 }
51
52 return {
53 name: 'transform-react-version-pragma',

Callers 1

ExpressionStatementFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected