<commit_before>var Jello = function (siteUrl, listOptions) {

    // Any initialization logic should go here
    if (!listOptions.name || !listOptions.contentType || !siteUrl)
    {
        throw("Invalid settings");
    }
    
    
    return {
        listName: listOptions.name,
        listContentType: listOptions.contentType,
        requestDigest: null,
        getRequestDigest: function () {
            var self = this;
            var dfd = $.Deferred();
            if (self.requestDigest && self.requestDigest.expiresOn > (new Date())) {
                return dfd.resolve();
            }
            else {
                $.ajax({
                    type: "POST",
                    url: "https://jello.sharepoint.com/sites/sprest/_api/contextinfo",
                    headers: {
                    "accept": "application/json;odata=verbose"
                    }
                }).done(function(resp){
                    var now = (new Date()).getTime();
                    self.requestDigest = resp.d.GetContextWebInformation;
                    self.requestDigest.expiresOn = now + (resp.d.GetContextWebInformation.FormDigestTimeoutSeconds * 1000) - 60000; // -60000 To prevent any calls to fail at all, by refreshing a minute before
                    console.log("Token", self.requestDigest.FormDigestValue);
                    dfd.resolve();
                })
                .fail(function(err){
                    console.log("Error fetching Request Digest. Some parts won't work.");
                    dfd.reject();
                });
            }
            
            return dfd.promise();
        },
        get: function (id) {
            var dfd = $.Deferred();
            
            var filter = ( id ) ? "(" + id + ")" : "" ;
            
            $.ajax({
                type: 'GET',
                headers: {
                    "accept": "application/json;odata=verbose"
                },
                url: siteUrl + "/_api/web/lists/getbytitle('" + listOptions.name + "')/items" + filter
            }).done(function (resp) {
                dfd.resolve(resp);
            }).fail(function (err) {
                dfd.reject(err);
            });

            return dfd.promise();
        },
        add: function (item) {
            var self = this;
            var dfd = $.Deferred();
            <commit_msg>changed get(id) to getById(id). get(top) now supported. Closes #7<commit_after>var Jello = function (siteUrl, listOptions) {

    // Any initialization logic should go here
    if (!listOptions.name || !listOptions.contentType || !siteUrl)
    {
        throw("Invalid settings");
    }
    
    
    return {
        listName: listOptions.name,
        listContentType: listOptions.contentType,
        requestDigest: null,
        getRequestDigest: function () {
            var self = this;
            var dfd = $.Deferred();
            if (self.requestDigest && self.requestDigest.expiresOn > (new Date())) {
                return dfd.resolve();
            }
            else {
                $.ajax({
                    type: "POST",
                    url: "https://jello.sharepoint.com/sites/sprest/_api/contextinfo",
                    headers: {
                    "accept": "application/json;odata=verbose"
                    }
                }).done(function(resp){
                    var now = (new Date()).getTime();
                    self.requestDigest = resp.d.GetContextWebInformation;
                    self.requestDigest.expiresOn = now + (resp.d.GetContextWebInformation.FormDigestTimeoutSeconds * 1000) - 60000; // -60000 To prevent any calls to fail at all, by refreshing a minute before
                    console.log("Token", self.requestDigest.FormDigestValue);
                    dfd.resolve();
                })
                .fail(function(err){
                    console.log("Error fetching Request Digest. Some parts won't work.");
                    dfd.reject();
                });
            }
            
            return dfd.promise();
        },
        get: function (top) {
            var dfd = $.Deferred();
            
            var filter = ( top ) ? "?$top=" + top : "" ;
            
            $.ajax({
                type: 'GET',
                headers: {
                    "accept": "application/json;odata=verbose"
                },
                url: siteUrl + "/_api/web/lists/getbytitle('" + listOptions.name + "')/items" + filter
            }).done(function (resp) {
                dfd.resolve(resp);
            }).fail(function (err) {
                dfd.reject(err);
            });

            return dfd.promise();
        },
        getById: function (id) {
            var dfd = $.Deferred();
            
            if (!id)
                throw("Provided ID is not valid");
            
            $.ajax({
                type: 'GET',
                headers: {
                    "accept": "application/json;odata=verbose"
                },
                url: siteUrl + "/_api/web/lists/getbytitle('" + listOptions.name + "')/items(" + id + ")"
            }).done(function (resp) {
                dfd.resolve(resp);
            }).fail(function (err) {
                dfd.reject(err);
            });

            return dfd.promise();
        },
        add: function (item) {
            var self = this;
            var dfd = $.Deferred();
            
{'fraction_non_alphanumeric': 0.12401394239589066, 'fraction_numerical': 0.005320124747752706, 'mean_word_length': 1.2575569358178054, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '5578401', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1373, 'n_words': 298}