code: function getCycles/*::<T>*/(currDepsMap /*: Graph<T> */, visited /*: Graph<T> */) /*: Groups<T> */ {
    // Get a list of all the remaining items in the dep map.
    let items = Array.from(currDepsMap.keys());
    // Create an array for cycles to push to.
    let cycles /*: Groups<T> */ = [];
  
    // Create a function to call recursively in a depth-first search.
    function visit(item, cycle) {
      let visitedDeps = visited.get(item);
  
      // Create an object for the item to mark visited deps.
      if (!visitedDeps) {
        visitedDeps = [];
        visited.set(item, visitedDeps);
      }
  
      // Get the current deps for the item.
      let deps = currDepsMap.get(item);
      if (typeof deps === 'undefined') return;
  
      // For each dep,
      for (let dep of deps) {
        // Check if this dep creates a cycle. We know it's a cycle if the first
        // item is the same as our dep.
        if (cycle[0] === dep) {
          cycles.push(cycle);
        }
  
        // If an item hasn't been visited, visit it (and pass an updated
        // potential cycle)
        if (!arrayIncludes(visitedDeps, dep)) {
          visitedDeps.push(dep);
          visit(dep, cycle.concat(dep));
        }
      }
    }
  
    // Iterate through each item in our current deps map and search it for cycles.
    for (let item of items) {
      visit(item, [item]);
    }
  
    // Return any cycles we found.
    return cycles;
  }
docs: /*::
  type Graph<T> = Map<T, Array<T>>;
  type Groups<T> = Array<Array<T>>;
  
  type Options<T> = {
  graph: Graph<T>,
  groups: Groups<T>,
  };
  
  type Result<T> = {
  safe: boolean,
  chunks: Groups<T>,
  cycles: Groups<T>,
  };
   A function for finding cycles in a remaining graph.