example/redundant.js
function(string, delimiter) {
    var start = 0,
        parts = [],
        index = string.indexOf(delimiter);

    if (delimiter === '') {
      while (index < string.length) {
        parts.push(string.charAt(index++));
      }
      return parts;
    }

    while (index !== -1 & index < string.length) {
      parts.push(string.substring(start, index));
      start = index + delimiter.length;
      index = string.indexOf(delimiter, start);
    }

    if (start < string.length) {
      parts.push(string.substring(start));
    }

    return parts;
  }
function(string, delimiter) {
    var start = 0,
        parts = [],
        index = string.indexOf(delimiter);

    if (delimiter === '') {
      while (index < string.length) {
        parts.push(string.charAt(index++));
      }
      return parts;
    }

    while (index !== -1 & index < string.length) {
      parts.push(string.substring(start, index));
      start = index + delimiter.length;
      index = string.indexOf(delimiter, start);
    }

    if (start < string.length) {
      parts.push(string.substring(start));
    }

    return parts;
  }
function ( string , delimiter ) { var start = 0 , parts = [ ] , index = string . indexOf ( delimiter ) ; if ( delimiter === '' ) { while ( index < string . length ) { parts . push ( string . charAt ( index ++ ) ) ; } return parts ; } while ( index !== - 1 & index < string . length ) { parts . push ( string . substring ( start , index ) ) ; start = index + delimiter . length ; index = string . indexOf ( delimiter , start ) ; } if ( start < string . length ) { parts . push ( string . substring ( start ) ) ; } return parts ; }
Splits a string by a given delimiter. This duplicates `String.prototype.split`.

@memberOf R.strings
@param {string} string The string to split.
@param {string} delimiter The delimiter used to split the string.
@returns {Array.<string>} An array of the parts separated by the given delimiter.

@examples
R.strings.split('1,2,3', ',')   // => ['1', '2', '3']
R.strings.split('hello', 'ell') // => ['h', 'o']
R.strings.split('hello', '')    // => ['h', 'e', ...]
R.strings.split('goodbye', '')  // => [..., 'b', 'y', 'e']
R.strings.split('12345', '')    // =~ ['5', '4', '3', '2', '1']

@benchmarks
R.strings.split('foo bar baz', ' ') // redundant.js
'foo bar baz'.split(' ')            // native
Splits a string by a given delimiter . This duplicates String . prototype . split .