<commit_before>'use strict';
/* global _ */

angular.module('resourceCollection', ['ngResource'])

  .factory('$collection', function($resource, $q) {

    var slice = Array.prototype.slice;
    var splice = Array.prototype.splice;
    var extend = angular.extend;
    var forEach = angular.forEach;

    var CollectionFactory = function(url, paramDefaults, actions) {

      var collection = $resource(url, paramDefaults, actions);

      var parentQuery = collection.query;
      extend(collection, {
        models: [],
        query: function() {
          var value = parentQuery();
          this.models = value.$promise;
          return value;
        },
        getById: function(id) {
          return this.find(function(v, k) {
            return v._id === id;
          });
        }
      });

      // Underscore methods that we want to implement on the Collection.
      var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
        'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
        'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
        'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
        'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf',
        'isEmpty'];

      // Mix in each Underscore/Lodash method as a proxy to Collection#data.
      forEach(methods, function(method) {
        if(!angular.isDefined(_[method])) throw 'Unknown _.' + method + ' method.';
        collection[method] = function() {
          var args = slice.call(arguments);
          return $q.when(collection.models, function(models) {
            args.unshift(models);
            return _[method].apply(_, args);
          });
        };
      });

      return collection;

    };

    return CollectionFactory;

  });
<commit_msg>chore(update): better parent call<commit_after>'use strict';
/* global _ */

angular.module('resourceCollection', ['ngResource'])

  .factory('$collection', function($resource, $filter, $q) {

    var slice = Array.prototype.slice;
    var splice = Array.prototype.splice;
    var extend = angular.extend;
    var forEach = angular.forEach;

    var CollectionFactory = function(url, paramDefaults, actions) {

      var collection = $resource(url, paramDefaults, actions);
      var parentQuery = collection.query;
      // var filter = $filter('filter');

      extend(collection, {
        models: [],
        query: function() {
          var value = parentQuery.apply(this, arguments);
          this.models = value.$promise;
          return value;
        },
        getById: function(id) {
          return this.find(function(v, k) {
            return v._id === id;
          });
        }
      });

      // Underscore methods that we want to implement on the Collection.
      var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
        'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
        'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
        'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
        'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf',
        'isEmpty'];

      // Mix in each Underscore/Lodash method as a proxy to Collection#data.
      forEach(methods, function(method) {
        if(!angular.isDefined(_[method])) throw 'Unknown _.' + method + ' method.';
        collection[method] = function() {
          var args = slice.call(arguments);
          return $q.when(collection.models, function(models) {
            args.unshift(models);
            return _[method].apply(_, args);
          });
        };
      });

      return collection;

    };

    return CollectionFactory;

  });

{'fraction_non_alphanumeric': 0.1615364377795317, 'fraction_numerical': 0.0, 'mean_word_length': 2.52037037037037, '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': '1758322', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1051, 'n_words': 278}