<commit_before>/**
 * Object that represents a linkted list item
 *
 * @param {Number} key
 * @param {LListItem} prev
 * @param {LListItem} next
 * @constructor
 */
var LListItem = function (key, prev, next) {

    this.key = (key) ? key : 0;
    this.prev = (prev) ? prev : null;
    this.next = (next) ? next : null;

};

/**
 * Object that represents a linked list
 *
 * @param {LListItem} firstItem
 * @param {LListItem} lastItem
 * @constructor
 */
var LList = function (firstItem, lastItem) {

    this.firstItem = (firstItem) ? firstItem : null;
    this.lastItem = (lastItem) ? lastItem : null;

};





<commit_msg>function insert for linked list<commit_after>/**
 * Object that represents a linkted list item
 *
 * @param {Number} key
 * @constructor
 */
var LListItem = function (key) {

    this.key = (key) ? key : 0;
    this.prev = null;
    this.next = null;

};

/**
 * Object that represents a linked list
 *
 * @param {string} name
 * @constructor
 */
var LList = function (name) {

    this.name = (name) ? name : '';
    this.firstItem = null;
    this.lastItem = null;

};

/**
 *
 * @param {LList} list
 * @param {LListItem} item
 */
function insert (list, item) {

    if (!(list instanceof LList)) {
        throw new Error('list param is not instance of LList');
    }

    if(!(item instanceof LListItem)){
        throw new Error('item param is not instance of LListItem');
    }

    // empty list
    if (!(list.lastItem)) {
        list.firstItem = item;
        list.lastItem = item;
        return;
    }

    var oldLastItem = list.lastItem;

    // non-empty list
    oldLastItem.next = item;
    item.prev = oldLastItem;
    list.lastItem = item;

}

var listA = new LList('List A');
var keysToInsert = [1,2,3,4,5,6,7];

keysToInsert.forEach(function (key) {
    insert(listA, new LListItem(key));
});



{'fraction_non_alphanumeric': 0.14402173913043478, 'fraction_numerical': 0.004891304347826087, 'mean_word_length': 2.757142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2152952', 'n_tokens_mistral': 629, 'n_tokens_neox': 611, 'n_words': 179}