Working with cursors & limits

Hello, we were working on a formatter that has separate functions for individual node types that are to be formatted. In this, we were creating new cursors for each of the functions, to keep the cursors separate. While it works, we were wondering if it’s a good idea to do it this way?

function fromClauseFormatter(cursor) {

  var tempCursor = cursor.node.cursor;
  //using tempCursor for rest of the function


Also, just in case, is there a limit to the number of cursors we can have?

This should work. There’s no limit on the number of cursors, and they should be pretty lightweight (especially if they are created like this, in which case they’ll share parent objects) in terms of memory use.

1 Like

Ah okay, thank you!