function substring()

in packages/fbjs/src/unicode/UnicodeUtils.js [180:194]


function substring(str, start, end) {
  start = start || 0;
  end   = (end === undefined) ? Infinity : (end || 0);

  if (start < 0) {
    start = 0;
  }
  if (end < 0) {
    end = 0;
  }

  const length = Math.abs(end - start);
  start = (start < end) ? start : end;
  return substr(str, start, length);
}