<commit_before>class Node {
  constructor(data) {
    this._value = data;
    this._next = null;
  }

  get value() {
    return this._value;
  }

  get next() {
    return this._next;
  }

  set value(data) {
    this._value = data;
  }

  set next(node) {
    this._next = node;
  }
}

class LinkedList {
  constructor() {
    this._head = null;
    this._length = 0;
  }

  get length() {
    return this.length;
  }

  push(data) {
    const newNode = new Node(data);

    if (this._head === null) {
      this._head = newNode;
    } else {
      newNode.next = this._head;
      this._head = newNode;
    }

    this._length += 1;
    return this;
  }

  printList() {
    let reference = this._head;

    while (reference !== null) {
      process.stdout.write(`${reference.value} -> `);
      reference = reference.next;
    }
    process.stdout.write('null');

    return this;
  }
}


module.exports = LinkedList;<commit_msg>Update: forEach and toString methods added; printList removed<commit_after>const Node = require('./Node');

class LinkedList {
  constructor() {
    this._head = null;
    this._length = 0;
  }

  get length() {
    return this._length;
  }

  isEmpty() {
    return this._length === 0;
  }

  push(data) {
    const newNode = new Node(data);

    if (this._head === null) {
      this._head = newNode;
    } else {
      newNode.next = this._head;
      this._head = newNode;
    }

    this._length += 1;
    return this;
  }

  forEach(func) {
    let reference = this._head;

    while (reference !== null) {
      reference.value = func(reference.value);
      reference = reference.next;
    }
  }

  toString() {
    let reference = this._head;
    let str = '';

    while (reference !== null) {
      str += `${reference.value} -> `;
      reference = reference.next;
    }

    str += 'null';

    return str;
  }
}


module.exports = LinkedList;
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.0026455026455026454, 'mean_word_length': 2.1835016835016834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1536798', 'n_tokens_mistral': 649, 'n_tokens_neox': 618, 'n_words': 141}