<commit_before>/** @namespace sputils.list */

(function () {
  /*

  EXAMPLE USE

  sputils.list.getListByName('Announcements')
    .then(function (data) { console.log(data.d.results) });

  */
  var getListByName = function (name, config) {
    var url = '/_api/Web/Lists/getByTitle(\'' + name + '\')/items/';
    return sputils.rest.get(url, config)
      .then(sputils.rest.unwrapResults);
  };


  /*

  EXAMPLE USE

  var data = {"Title": "listlessly POSTing",
              "__metadata": { type: "SP.Data.AnnouncementsListItem"} };
  sputils.list.postListByName("Announcements", data)
    .then(function (data) { console.log(data); });

  */
  var postListByName = function (name, data, config) {
    var url = '/_api/Web/Lists/getByTitle(\'' + name + '\')/items/';
    return sputils.rest.post(url, data, config)
      .then(sputils.rest.unwrapResults);
  };

  /*

  EXAMPLE USE

  sputils.list.getListItemById('Announcements', 1)
    .then(function (data) { console.log(data.d.results) });

  */
  // Returns the list item with the specified id.
  var getListItemById = function (listName, itemId, config) {
    var url = '/_api/Web/Lists/getByTitle(\'' + listName + '\')/items/getbyid(' + itemId + ')';
    return sputils.rest.get(url, config)
      .then(sputils.rest.unwrapResults);
  };

  sputils.list = {
    getListByName: getListByName,
    postListByName: postListByName,
    getListItemById: getListItemById
  };
})();<commit_msg>Add comments to list utility<commit_after>/** @namespace sputils.list */

(function () {

  /**
  Returns the list items from the given list name.
  @function sputils.lists.getListByName
  @param {string} name a list name
  @returns {array}
  @example

  sputils.list.getListByName('Announcements')
    .then(function (data) { console.log(data.d.results) });

  */
  var getListByName = function (name, config) {
    var url = '/_api/Web/Lists/getByTitle(\'' + name + '\')/items/';
    return sputils.rest.get(url, config)
      .then(sputils.rest.unwrapResults);
  };

  /**
  Modifies list items in the given list.
  @function sputils.lists.postListByName
  @param {string} name a list name
  @param {object} data the payload
  @param {object} config the config
  @returns {object} Promise
  @example

    var data = {"Title": "listlessly POSTing",
              "__metadata": { type: "SP.Data.AnnouncementsListItem"} };
  sputils.list.postListByName("Announcements", data)
    .then(function (data) { console.log(data); });

  */
  var postListByName = function (name, data, config) {
    var url = '/_api/Web/Lists/getByTitle(\'' + name + '\')/items/';
    return sputils.rest.post(url, data, config)
      .then(sputils.rest.unwrapResults);
  };

   /**
  Returns the list item with the specified id.
  @function sputils.lists.getListItemById
  @param {string} name a list name
  @param {object} data the payload
  @param {object} config the config
  @returns {array} List items
  @example

     sputils.list.getListItemById('Announcements', 1)
    .then(function (data) { console.log(data.d.results) });

  */
  var getListItemById = function (listName, itemId, config) {
    var url = '/_api/Web/Lists/getByTitle(\'' + listName + '\')/items/getbyid(' + itemId + ')';
    return sputils.rest.get(url, config)
      .then(sputils.rest.unwrapResults);
  };

  sputils.list = {
    getListByName: getListByName,
    postListByName: postListByName,
    getListItemById: getListItemById
  };
})();
{'fraction_non_alphanumeric': 0.15516241299303946, 'fraction_numerical': 0.000580046403712297, 'mean_word_length': 3.327478042659975, 'pattern_counts': {'":': 4, '<': 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': '6676506', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1157, 'n_words': 256}