Sha256: 9ddd17c2b6f10fcae28e91b8e8448ec8e5a8d97e3b4c8c005fc6d684060b8926

Contents?: true

Size: 1.51 KB

Versions: 277

Compression:

Stored size: 1.51 KB

Contents

var baseToString = require('./_baseToString'),
    castSlice = require('./_castSlice'),
    hasUnicode = require('./_hasUnicode'),
    isIterateeCall = require('./_isIterateeCall'),
    isRegExp = require('./isRegExp'),
    stringToArray = require('./_stringToArray'),
    toString = require('./toString');

/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295;

/**
 * Splits `string` by `separator`.
 *
 * **Note:** This method is based on
 * [`String#split`](https://mdn.io/String/split).
 *
 * @static
 * @memberOf _
 * @since 4.0.0
 * @category String
 * @param {string} [string=''] The string to split.
 * @param {RegExp|string} separator The separator pattern to split by.
 * @param {number} [limit] The length to truncate results to.
 * @returns {Array} Returns the string segments.
 * @example
 *
 * _.split('a-b-c', '-', 2);
 * // => ['a', 'b']
 */
function split(string, separator, limit) {
  if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
    separator = limit = undefined;
  }
  limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  if (!limit) {
    return [];
  }
  string = toString(string);
  if (string && (
        typeof separator == 'string' ||
        (separator != null && !isRegExp(separator))
      )) {
    separator = baseToString(separator);
    if (!separator && hasUnicode(string)) {
      return castSlice(stringToArray(string), 0, limit);
    }
  }
  return string.split(separator, limit);
}

module.exports = split;

Version data entries

277 entries across 275 versions & 31 rubygems

Version Path
rapid_stack-0.2.0 templates/frontend/node_modules/lodash/split.js
rapid_stack-0.1.1 templates/FrontEnd/node_modules/lodash/split.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/lodash/split.js
immosquare-cleaner-0.1.60 node_modules/lodash/split.js
immosquare-cleaner-0.1.59 node_modules/lodash/split.js
immosquare-cleaner-0.1.58 node_modules/lodash/split.js
immosquare-cleaner-0.1.57 node_modules/lodash/split.js
immosquare-cleaner-0.1.56 node_modules/lodash/split.js
immosquare-cleaner-0.1.55 node_modules/lodash/split.js
immosquare-cleaner-0.1.54 node_modules/lodash/split.js
immosquare-cleaner-0.1.53 node_modules/lodash/split.js
immosquare-cleaner-0.1.52 node_modules/lodash/split.js
trusty-cms-6.3.1 node_modules/lodash/split.js
immosquare-cleaner-0.1.51 node_modules/lodash/split.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/split.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/split.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/split.js
immosquare-cleaner-0.1.50 node_modules/lodash/split.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/split.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/split.js