traversalMethods.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Mixin: traversalMethods</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Mixin: traversalMethods</h1>
  17. <section>
  18. <header>
  19. <h2>traversalMethods</h2>
  20. </header>
  21. <article>
  22. <div class="container-overview">
  23. <dl class="details">
  24. <dt class="tag-source">Source:</dt>
  25. <dd class="tag-source"><ul class="dummy"><li>
  26. <a href="collections_JSXElement.js.html">collections/JSXElement.js</a>, <a href="collections_JSXElement.js.html#line131">line 131</a>
  27. </li></ul></dd>
  28. </dl>
  29. </div>
  30. <h3 class="subsection-title">Methods</h3>
  31. <h4 class="name" id=".childElements"><span class="type-signature">(static) </span>childElements<span class="signature">()</span><span class="type-signature"> &rarr; {JSXElementCollection}</span></h4>
  32. <div class="description">
  33. Returns all children that are JSXElements.
  34. </div>
  35. <dl class="details">
  36. <dt class="tag-source">Source:</dt>
  37. <dd class="tag-source"><ul class="dummy"><li>
  38. <a href="collections_JSXElement.js.html">collections/JSXElement.js</a>, <a href="collections_JSXElement.js.html#line155">line 155</a>
  39. </li></ul></dd>
  40. </dl>
  41. <h5>Returns:</h5>
  42. <dl>
  43. <dt>
  44. Type
  45. </dt>
  46. <dd>
  47. <span class="param-type">JSXElementCollection</span>
  48. </dd>
  49. </dl>
  50. <h4 class="name" id=".childNodes"><span class="type-signature">(static) </span>childNodes<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  51. <div class="description">
  52. Returns all child nodes, including literals and expressions.
  53. </div>
  54. <dl class="details">
  55. <dt class="tag-source">Source:</dt>
  56. <dd class="tag-source"><ul class="dummy"><li>
  57. <a href="collections_JSXElement.js.html">collections/JSXElement.js</a>, <a href="collections_JSXElement.js.html#line138">line 138</a>
  58. </li></ul></dd>
  59. </dl>
  60. <h5>Returns:</h5>
  61. <dl>
  62. <dt>
  63. Type
  64. </dt>
  65. <dd>
  66. <span class="param-type"><a href="Collection.html">Collection</a></span>
  67. </dd>
  68. </dl>
  69. <h4 class="name" id=".closest"><span class="type-signature">(static) </span>closest<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  70. <div class="description">
  71. Traverse the AST up and finds the closest node of the provided type.
  72. </div>
  73. <h5>Parameters:</h5>
  74. <table class="params">
  75. <thead>
  76. <tr>
  77. <th>Type</th>
  78. <th class="last">Description</th>
  79. </tr>
  80. </thead>
  81. <tbody>
  82. <tr>
  83. <td class="type">
  84. <span class="param-type"><a href="Collection.html">Collection</a></span>
  85. </td>
  86. <td class="description last"></td>
  87. </tr>
  88. <tr>
  89. <td class="type">
  90. <span class="param-type">filter</span>
  91. </td>
  92. <td class="description last"></td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. <dl class="details">
  97. <dt class="tag-source">Source:</dt>
  98. <dd class="tag-source"><ul class="dummy"><li>
  99. <a href="collections_Node.js.html">collections/Node.js</a>, <a href="collections_Node.js.html#line78">line 78</a>
  100. </li></ul></dd>
  101. </dl>
  102. <h5>Returns:</h5>
  103. <dl>
  104. <dt>
  105. Type
  106. </dt>
  107. <dd>
  108. <span class="param-type"><a href="Collection.html">Collection</a></span>
  109. </dd>
  110. </dl>
  111. <h4 class="name" id=".closestScope"><span class="type-signature">(static) </span>closestScope<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  112. <div class="description">
  113. Returns a collection containing the paths that create the scope of the
  114. currently selected paths. Dedupes the paths.
  115. </div>
  116. <dl class="details">
  117. <dt class="tag-source">Source:</dt>
  118. <dd class="tag-source"><ul class="dummy"><li>
  119. <a href="collections_Node.js.html">collections/Node.js</a>, <a href="collections_Node.js.html#line67">line 67</a>
  120. </li></ul></dd>
  121. </dl>
  122. <h5>Returns:</h5>
  123. <dl>
  124. <dt>
  125. Type
  126. </dt>
  127. <dd>
  128. <span class="param-type"><a href="Collection.html">Collection</a></span>
  129. </dd>
  130. </dl>
  131. <h4 class="name" id=".find"><span class="type-signature">(static) </span>find<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  132. <div class="description">
  133. Find nodes of a specific type within the nodes of this collection.
  134. </div>
  135. <h5>Parameters:</h5>
  136. <table class="params">
  137. <thead>
  138. <tr>
  139. <th>Type</th>
  140. <th class="last">Description</th>
  141. </tr>
  142. </thead>
  143. <tbody>
  144. <tr>
  145. <td class="type">
  146. <span class="param-type">type</span>
  147. </td>
  148. <td class="description last"></td>
  149. </tr>
  150. <tr>
  151. <td class="type">
  152. <span class="param-type">filter</span>
  153. </td>
  154. <td class="description last"></td>
  155. </tr>
  156. </tbody>
  157. </table>
  158. <dl class="details">
  159. <dt class="tag-source">Source:</dt>
  160. <dd class="tag-source"><ul class="dummy"><li>
  161. <a href="collections_Node.js.html">collections/Node.js</a>, <a href="collections_Node.js.html#line34">line 34</a>
  162. </li></ul></dd>
  163. </dl>
  164. <h5>Returns:</h5>
  165. <dl>
  166. <dt>
  167. Type
  168. </dt>
  169. <dd>
  170. <span class="param-type"><a href="Collection.html">Collection</a></span>
  171. </dd>
  172. </dl>
  173. <h4 class="name" id=".getVariableDeclarators"><span class="type-signature">(static) </span>getVariableDeclarators<span class="signature">(nameGetter)</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  174. <div class="description">
  175. Finds the declaration for each selected path. Useful for member expressions
  176. or JSXElements. Expects a callback function that maps each path to the name
  177. to look for.
  178. If the callback returns a falsey value, the element is skipped.
  179. </div>
  180. <h5>Parameters:</h5>
  181. <table class="params">
  182. <thead>
  183. <tr>
  184. <th>Name</th>
  185. <th>Type</th>
  186. <th class="last">Description</th>
  187. </tr>
  188. </thead>
  189. <tbody>
  190. <tr>
  191. <td class="name"><code>nameGetter</code></td>
  192. <td class="type">
  193. <span class="param-type">function</span>
  194. </td>
  195. <td class="description last"></td>
  196. </tr>
  197. </tbody>
  198. </table>
  199. <dl class="details">
  200. <dt class="tag-source">Source:</dt>
  201. <dd class="tag-source"><ul class="dummy"><li>
  202. <a href="collections_Node.js.html">collections/Node.js</a>, <a href="collections_Node.js.html#line105">line 105</a>
  203. </li></ul></dd>
  204. </dl>
  205. <h5>Returns:</h5>
  206. <dl>
  207. <dt>
  208. Type
  209. </dt>
  210. <dd>
  211. <span class="param-type"><a href="Collection.html">Collection</a></span>
  212. </dd>
  213. </dl>
  214. </article>
  215. </section>
  216. <section>
  217. <header>
  218. <h2>traversalMethods</h2>
  219. </header>
  220. <article>
  221. <div class="container-overview">
  222. <dl class="details">
  223. <dt class="tag-source">Source:</dt>
  224. <dd class="tag-source"><ul class="dummy"><li>
  225. <a href="collections_Node.js.html">collections/Node.js</a>, <a href="collections_Node.js.html#line25">line 25</a>
  226. </li></ul></dd>
  227. </dl>
  228. </div>
  229. <h3 class="subsection-title">Methods</h3>
  230. <h4 class="name" id=".childElements"><span class="type-signature">(static) </span>childElements<span class="signature">()</span><span class="type-signature"> &rarr; {JSXElementCollection}</span></h4>
  231. <div class="description">
  232. Returns all children that are JSXElements.
  233. </div>
  234. <dl class="details">
  235. <dt class="tag-source">Source:</dt>
  236. <dd class="tag-source"><ul class="dummy"><li>
  237. <a href="collections_JSXElement.js.html">collections/JSXElement.js</a>, <a href="collections_JSXElement.js.html#line155">line 155</a>
  238. </li></ul></dd>
  239. </dl>
  240. <h5>Returns:</h5>
  241. <dl>
  242. <dt>
  243. Type
  244. </dt>
  245. <dd>
  246. <span class="param-type">JSXElementCollection</span>
  247. </dd>
  248. </dl>
  249. <h4 class="name" id=".childNodes"><span class="type-signature">(static) </span>childNodes<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  250. <div class="description">
  251. Returns all child nodes, including literals and expressions.
  252. </div>
  253. <dl class="details">
  254. <dt class="tag-source">Source:</dt>
  255. <dd class="tag-source"><ul class="dummy"><li>
  256. <a href="collections_JSXElement.js.html">collections/JSXElement.js</a>, <a href="collections_JSXElement.js.html#line138">line 138</a>
  257. </li></ul></dd>
  258. </dl>
  259. <h5>Returns:</h5>
  260. <dl>
  261. <dt>
  262. Type
  263. </dt>
  264. <dd>
  265. <span class="param-type"><a href="Collection.html">Collection</a></span>
  266. </dd>
  267. </dl>
  268. <h4 class="name" id=".closest"><span class="type-signature">(static) </span>closest<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  269. <div class="description">
  270. Traverse the AST up and finds the closest node of the provided type.
  271. </div>
  272. <h5>Parameters:</h5>
  273. <table class="params">
  274. <thead>
  275. <tr>
  276. <th>Type</th>
  277. <th class="last">Description</th>
  278. </tr>
  279. </thead>
  280. <tbody>
  281. <tr>
  282. <td class="type">
  283. <span class="param-type"><a href="Collection.html">Collection</a></span>
  284. </td>
  285. <td class="description last"></td>
  286. </tr>
  287. <tr>
  288. <td class="type">
  289. <span class="param-type">filter</span>
  290. </td>
  291. <td class="description last"></td>
  292. </tr>
  293. </tbody>
  294. </table>
  295. <dl class="details">
  296. <dt class="tag-source">Source:</dt>
  297. <dd class="tag-source"><ul class="dummy"><li>
  298. <a href="collections_Node.js.html">collections/Node.js</a>, <a href="collections_Node.js.html#line78">line 78</a>
  299. </li></ul></dd>
  300. </dl>
  301. <h5>Returns:</h5>
  302. <dl>
  303. <dt>
  304. Type
  305. </dt>
  306. <dd>
  307. <span class="param-type"><a href="Collection.html">Collection</a></span>
  308. </dd>
  309. </dl>
  310. <h4 class="name" id=".closestScope"><span class="type-signature">(static) </span>closestScope<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  311. <div class="description">
  312. Returns a collection containing the paths that create the scope of the
  313. currently selected paths. Dedupes the paths.
  314. </div>
  315. <dl class="details">
  316. <dt class="tag-source">Source:</dt>
  317. <dd class="tag-source"><ul class="dummy"><li>
  318. <a href="collections_Node.js.html">collections/Node.js</a>, <a href="collections_Node.js.html#line67">line 67</a>
  319. </li></ul></dd>
  320. </dl>
  321. <h5>Returns:</h5>
  322. <dl>
  323. <dt>
  324. Type
  325. </dt>
  326. <dd>
  327. <span class="param-type"><a href="Collection.html">Collection</a></span>
  328. </dd>
  329. </dl>
  330. <h4 class="name" id=".find"><span class="type-signature">(static) </span>find<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  331. <div class="description">
  332. Find nodes of a specific type within the nodes of this collection.
  333. </div>
  334. <h5>Parameters:</h5>
  335. <table class="params">
  336. <thead>
  337. <tr>
  338. <th>Type</th>
  339. <th class="last">Description</th>
  340. </tr>
  341. </thead>
  342. <tbody>
  343. <tr>
  344. <td class="type">
  345. <span class="param-type">type</span>
  346. </td>
  347. <td class="description last"></td>
  348. </tr>
  349. <tr>
  350. <td class="type">
  351. <span class="param-type">filter</span>
  352. </td>
  353. <td class="description last"></td>
  354. </tr>
  355. </tbody>
  356. </table>
  357. <dl class="details">
  358. <dt class="tag-source">Source:</dt>
  359. <dd class="tag-source"><ul class="dummy"><li>
  360. <a href="collections_Node.js.html">collections/Node.js</a>, <a href="collections_Node.js.html#line34">line 34</a>
  361. </li></ul></dd>
  362. </dl>
  363. <h5>Returns:</h5>
  364. <dl>
  365. <dt>
  366. Type
  367. </dt>
  368. <dd>
  369. <span class="param-type"><a href="Collection.html">Collection</a></span>
  370. </dd>
  371. </dl>
  372. <h4 class="name" id=".getVariableDeclarators"><span class="type-signature">(static) </span>getVariableDeclarators<span class="signature">(nameGetter)</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
  373. <div class="description">
  374. Finds the declaration for each selected path. Useful for member expressions
  375. or JSXElements. Expects a callback function that maps each path to the name
  376. to look for.
  377. If the callback returns a falsey value, the element is skipped.
  378. </div>
  379. <h5>Parameters:</h5>
  380. <table class="params">
  381. <thead>
  382. <tr>
  383. <th>Name</th>
  384. <th>Type</th>
  385. <th class="last">Description</th>
  386. </tr>
  387. </thead>
  388. <tbody>
  389. <tr>
  390. <td class="name"><code>nameGetter</code></td>
  391. <td class="type">
  392. <span class="param-type">function</span>
  393. </td>
  394. <td class="description last"></td>
  395. </tr>
  396. </tbody>
  397. </table>
  398. <dl class="details">
  399. <dt class="tag-source">Source:</dt>
  400. <dd class="tag-source"><ul class="dummy"><li>
  401. <a href="collections_Node.js.html">collections/Node.js</a>, <a href="collections_Node.js.html#line105">line 105</a>
  402. </li></ul></dd>
  403. </dl>
  404. <h5>Returns:</h5>
  405. <dl>
  406. <dt>
  407. Type
  408. </dt>
  409. <dd>
  410. <span class="param-type"><a href="Collection.html">Collection</a></span>
  411. </dd>
  412. </dl>
  413. </article>
  414. </section>
  415. </div>
  416. <nav>
  417. <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-jscodeshift.html">jscodeshift</a></li></ul><h3>Externals</h3><ul><li><a href="external-astTypes.html">astTypes</a></li></ul><h3>Classes</h3><ul><li><a href="Collection.html">Collection</a></li></ul><h3>Mixins</h3><ul><li><a href="globalMethods.html">globalMethods</a></li><li><a href="mutationMethods.html">mutationMethods</a></li><li><a href="transformMethods.html">transformMethods</a></li><li><a href="traversalMethods.html">traversalMethods</a></li></ul><h3>Global</h3><ul><li><a href="global.html#registerMethods">registerMethods</a></li></ul>
  418. </nav>
  419. <br class="clear">
  420. <footer>
  421. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.1</a> on Wed Sep 21 2016 16:53:09 GMT-0400 (EDT)
  422. </footer>
  423. <script> prettyPrint(); </script>
  424. <script src="scripts/linenumber.js"> </script>
  425. </body>
  426. </html>