<commit_before><commit_msg>Implement the Track and TrackList models<commit_after>module("models/tracks", function(require) {
  var ID3 = require("lib/id3");

  function Track(blob) {
    var parser = new ID3.ID3v2Parser();
    // XXX: ID3v2Parser#parse should accepts any kind of typed array
    // instead of expecting a Uint8Array;
    tags = parser.parse(new Uint8Array(blob));

    this.title  = tags.title;
    this.album  = tags.album;
    this.artist = tags.artist;
    this.data   = blob;
  }

  Track.prototype = {
    toFile: function() {
      return new Blob([this.data], {type: "audio/mpeg"});
    }
  };

  function TrackList() {
    this.tracks = [];
  }

  TrackList.prototype = {
    add: function(track) {
      this.tracks.push(track);
      this.emit("add", track);
      return this;
    },

    map: function() {
      return this.tracks.map.apply(this.tracks, arguments);
    },

    slice: function() {
      return this.tracks.slice.apply(this.tracks, arguments);
    }
  };

  MicroEvent.mixin(TrackList);

  return  {
    Track: Track,
    TrackList: TrackList
  }
});

{'fraction_non_alphanumeric': 0.14051094890510948, 'fraction_numerical': 0.008211678832116789, 'mean_word_length': 2.756849315068493, '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': '4787349', 'n_tokens_mistral': 374, 'n_tokens_neox': 357, 'n_words': 76}