<commit_before>'use strict';

const git = require('nodegit');

class Range extends Array {

  constructor(repo, revisions = []) {
    super(...revisions);
    this.repo = repo;
  }

  walker() {
    if (this.length < 1) {
      throw new Error('no revision to walk');
    }

    return this.reduce((walker, rev) => {
      if (rev.startsWith('^')) {
        walker.hide(git.Oid.fromString(rev.slice(1)));
      } else {
        walker.push(git.Oid.fromString(rev));
      }

      return walker;
    }, git.Revwalk.create(this.repo));
  }

  commits({limit = Infinity, sorting = [git.Revwalk.SORT.TOPOLOGICAL]} = {}) {
    return new Promise(resolve => {
      const walker = this.walker();

      walker.sorting(...[].concat(sorting));

      resolve(walker);
    }).then(walker => walker.getCommits(limit));
  }
<commit_msg>fix: free walker after getting the commits<commit_after>'use strict';

const git = require('nodegit');

class Range extends Array {

  constructor(repo, revisions = []) {
    super(...revisions);
    this.repo = repo;
  }

  walker() {
    if (this.length < 1) {
      throw new Error('no revision to walk');
    }

    return this.reduce((walker, rev) => {
      if (rev.startsWith('^')) {
        walker.hide(git.Oid.fromString(rev.slice(1)));
      } else {
        walker.push(git.Oid.fromString(rev));
      }

      return walker;
    }, git.Revwalk.create(this.repo));
  }

  commits({limit = Infinity, sorting = [git.Revwalk.SORT.TOPOLOGICAL]} = {}) {
    return new Promise(resolve => {
      const walker = this.walker();

      walker.sorting(...[].concat(sorting));

      resolve(walker);
    }).then(walker => walker.getCommits(limit).then(commits => {
      walker.free();

      return commits;
    }));
  }

{'fraction_non_alphanumeric': 0.1742857142857143, 'fraction_numerical': 0.002285714285714286, 'mean_word_length': 2.6631799163179917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4349436', 'n_tokens_mistral': 611, 'n_tokens_neox': 569, 'n_words': 107}