index.js
function (str) {
    if (!str) return {};

    var additions = {};
    var adds      = str.split(':');

    if (adds[0] && adds[0] !== '0') {
      var sample;
      switch (adds[0]) {
        case '1':
          sample = 'normal';
          break;
        case '2':
          sample = 'soft';
          break;
        case '3':
          sample = 'drum';
          break;
      }
      additions.sample = sample;
    }

    if (adds[1] && adds[1] !== '0') {
      var addSample;
      switch (adds[1]) {
        case '1':
          addSample = 'normal';
          break;
        case '2':
          addSample = 'soft';
          break;
        case '3':
          addSample = 'drum';
          break;
      }
      additions.additionalSample = addSample;
    }

    if (adds[2] && adds[2] !== '0') { additions.customSampleIndex = parseInt(adds[2]); }
    if (adds[3] && adds[3] !== '0') { additions.hitsoundVolume    = parseInt(adds[3]); }
    if (adds[4])                    { additions.hitsound          = adds[4]; }

    return additions;
  }
function (str) {
    if (!str) return {};

    var additions = {};
    var adds      = str.split(':');

    if (adds[0] && adds[0] !== '0') {
      var sample;
      switch (adds[0]) {
        case '1':
          sample = 'normal';
          break;
        case '2':
          sample = 'soft';
          break;
        case '3':
          sample = 'drum';
          break;
      }
      additions.sample = sample;
    }

    if (adds[1] && adds[1] !== '0') {
      var addSample;
      switch (adds[1]) {
        case '1':
          addSample = 'normal';
          break;
        case '2':
          addSample = 'soft';
          break;
        case '3':
          addSample = 'drum';
          break;
      }
      additions.additionalSample = addSample;
    }

    if (adds[2] && adds[2] !== '0') { additions.customSampleIndex = parseInt(adds[2]); }
    if (adds[3] && adds[3] !== '0') { additions.hitsoundVolume    = parseInt(adds[3]); }
    if (adds[4])                    { additions.hitsound          = adds[4]; }

    return additions;
  }
function ( str ) { if ( ! str ) return { } ; var additions = { } ; var adds = str . split ( ':' ) ; if ( adds [ 0 ] && adds [ 0 ] !== '0' ) { var sample ; switch ( adds [ 0 ] ) { case '1' : sample = 'normal' ; break ; case '2' : sample = 'soft' ; break ; case '3' : sample = 'drum' ; break ; } additions . sample = sample ; } if ( adds [ 1 ] && adds [ 1 ] !== '0' ) { var addSample ; switch ( adds [ 1 ] ) { case '1' : addSample = 'normal' ; break ; case '2' : addSample = 'soft' ; break ; case '3' : addSample = 'drum' ; break ; } additions . additionalSample = addSample ; } if ( adds [ 2 ] && adds [ 2 ] !== '0' ) { additions . customSampleIndex = parseInt ( adds [ 2 ] ) ; } if ( adds [ 3 ] && adds [ 3 ] !== '0' ) { additions . hitsoundVolume = parseInt ( adds [ 3 ] ) ; } if ( adds [ 4 ] ) { additions . hitsound = adds [ 4 ] ; } return additions ; }
Parse additions member
@param  {String} str         additions member (sample:add:customSampleIndex:Volume:hitsound)
@return {Object} additions   a list of additions
Parse additions member