CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
split.js53 linesDownload Raw Back to lodash-es
1import baseToString from './_baseToString.js';2import castSlice from './_castSlice.js';3import hasUnicode from './_hasUnicode.js';4import isIterateeCall from './_isIterateeCall.js';5import isRegExp from './isRegExp.js';6import stringToArray from './_stringToArray.js';7import toString from './toString.js';8 9/** Used as references for the maximum length and index of an array. */10var MAX_ARRAY_LENGTH = 4294967295;11 12/**13 * Splits `string` by `separator`.14 *15 * **Note:** This method is based on16 * [`String#split`](https://mdn.io/String/split).17 *18 * @static19 * @memberOf _20 * @since 4.0.021 * @category String22 * @param {string} [string=''] The string to split.23 * @param {RegExp|string} separator The separator pattern to split by.24 * @param {number} [limit] The length to truncate results to.25 * @returns {Array} Returns the string segments.26 * @example27 *28 * _.split('a-b-c', '-', 2);29 * // => ['a', 'b']30 */31function split(string, separator, limit) {32  if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {33    separator = limit = undefined;34  }35  limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;36  if (!limit) {37    return [];38  }39  string = toString(string);40  if (string && (41        typeof separator == 'string' ||42        (separator != null && !isRegExp(separator))43      )) {44    separator = baseToString(separator);45    if (!separator && hasUnicode(string)) {46      return castSlice(stringToArray(string), 0, limit);47    }48  }49  return string.split(separator, limit);50}51 52export default split;53 
basant307/AI_Governance_Project · CoolFace