<commit_before>'use strict';

// TODO: add easings to all of current methods.

SoundJSDirectorGroupProto.play = function playGroup (options, all) {
  // TODO: Pass group options to every sounds considering every group of sound.

  options = SoundJSDirector.extend(
    SoundJSDirector.parseOptions(options),
    this.options
  );

  if (!options.collapsed) {
    this._playSounds(options, all);
  }
  
  else {
    this._playCollapsed(options, all);
  }
  
  return this;

};

// Play sound by @id (id/src of sound instance) with @options.
SoundJSDirectorGroupProto.playSound = function playGroupSound (id, options) {

  var sounds = this.sounds,
      sound = sounds[id];

  if (!sound && isNaN(parseInt(id))) {
    this.eachSound(function (_sound) {
      if (id === _sound.id || id === _sound.src) {
        sound = _sound;
        return SoundJSDirector.OUT_EACH;
      }
    });
  }

  if (sound) {
    sound.play(options);
  }

  return this;
};

// Play free/all sounds in group.
SoundJSDirectorGroupProto._playSounds = function (options, all) {
  // TODO: pass arguments multiplied with all instance groups.
  SoundJSDirector.each(
    all ? this.sounds : this._wait, 
    function (sound) {
      sound.play(options);
    }
  );
  return this;
};

// Play first of free/all sounds.
SoundJSDirectorGroupProto._playCollapsed = function (options, all) {
  // TODO: pass arguments multiplied with all instance groups.
  var sound = SoundJSDirector.randomItem(all ? this.sounds : this._wait);
  if (sound) {
    sound.play(options);
  }
  return this;
};

// Pause all playing sounds.
SoundJSDirectorGroupProto.pause = function pauseGroup () {
  this.eachPlayingSound(function (sound) {
    sound.pause();
  });
  return this;
};

// Resume all paused group sounds.
SoundJSDirectorGroupProto.resume = function resumeGroup () {
  this.eachPlayingSound(function (sound) {
    sound.resume();
  });
  return this;
};

// Stop all playing group sounds.
SoundJSDirectorGroupProto.stop = function stopGroup () {
  this.eachPlayingSound(function (sound) {
    sound.stop();<commit_msg>Imroved .play() method of SoundJSDirector.Group with arguments overload. Fixed namespacing in playback methods.<commit_after>'use strict';

// TODO: add easings to all of current methods.

// TODO: Pass group options to every sounds considering every group of sound.
  
SoundJSDirectorGroupProto.play = function playGroup (options, all) {

  var arg0 = arguments[0], id;

  switch (arguments.length) {

    default:
    case 2: {
      var arg1 = arguments[1];
      if ('object' === typeof arg1) {
        id = arg0;
        options = arg1;
        all = false;
      }
      else if ('object' !== typeof arg1) {
        throw 'SoundJSDirector.Group.play() given bad arguments';
      }
    } break;
    
    case 1: {
      switch (typeof arg0) {
        case 'string': id = arg0; options = all = false; break;
        case 'object': id = arg0.id || arg0.src; all = false; break;
        case 'boolean': all = arg0; options = id = false; break;
        default: throw 'SoundJSDirector.Group.play() given bad arguments';
      }
    } break;
    
    case 0: all = options = id = false; break;
  }

  var _options = SoundJSDirector.extend(
    SoundJSDirector.parseOptions(options),
    this.options
  );

  if (id) {
    this.playSound(id, _options);
  }

  else if (!_options.collapsed) {
    this._playSounds(_options, all);
  }
  
  else {
    this._playCollapsed(_options, all);
  }
  
  return this;

};

// Play sound by @id (id/src of sound instance) with @options.
SoundJSDirectorGroupProto.playSound = function playGroupSound (id, options) {

  var sounds = this.sounds,
      sound = sounds[id];

  if (!sound && isNaN(parseInt(id))) {
    this.eachSound(function (_sound) {
      if (id === _sound.id || id === _sound.src) {
        sound = _sound;
        return SoundJSDirector.OUT_EACH;
      }
    });
  }

  if (sound) {
    sound.play(options);
  }

  return this;
};

// Play @sound instance with @options.
SoundJSDirectorGroupProto._playSoundWithOptions = function playSoundWithOptions (/*sound, options*/) {
  // TODO: process options of every sound.
};

// Play free/all sounds in group.
SoundJSDirectorGroupProto._playSounds = function playSounds (options, all) {
  // TODO: pass arguments multiplied with all instance groups.
  SoundJSDirector.each(
    all ? this.sounds : this._wait, 
    function (sound) {
      sound.play(options);
    }
  );
  return this;
};

// Play first of free/all sounds.
SoundJSDirectorGroupProto._playCollapsed = function playCollapsed (options, all) {
  // TODO: pass arguments multiplied with all instance groups.
  var sound = SoundJSDirector.randomItem(all ? this.sounds : this._wait);
  if (sound) {
    sound.play(options);
  }
  return this;
};

// Pause all playing sounds.
SoundJSDirectorGroupProto.pause = function pauseGroup () {
  this.eachPlayingSound(function (sound) {
    sound.pause();
  });
  return this;
};

// Resume all paused group sounds.
SoundJSDirectorGroupProto.resume = function resumeGroup () {
  this.eachPlayingSound(function (sound) {
    sound.resume();
  });
  return this;
};

// Stop all playing group sounds.
SoundJSDirectorGroupProto.stop = function stopGroup () {
  this.eachPlayingSound(function (sound) {
    sound.stop();
{'fraction_non_alphanumeric': 0.12073193737030749, 'fraction_numerical': 0.003018298434257687, 'mean_word_length': 3.097372488408037, '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': '2726418', 'n_tokens_mistral': 1694, 'n_tokens_neox': 1632, 'n_words': 447}