mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Bump to v4.10.0.
This commit is contained in:
18
truncate.js
18
truncate.js
@@ -1,5 +1,7 @@
|
||||
var isObject = require('./isObject'),
|
||||
var castSlice = require('./_castSlice'),
|
||||
isObject = require('./isObject'),
|
||||
isRegExp = require('./isRegExp'),
|
||||
reHasComplexSymbol = require('./_reHasComplexSymbol'),
|
||||
stringSize = require('./_stringSize'),
|
||||
stringToArray = require('./_stringToArray'),
|
||||
toInteger = require('./toInteger'),
|
||||
@@ -12,18 +14,6 @@ var DEFAULT_TRUNC_LENGTH = 30,
|
||||
/** Used to match `RegExp` flags from their coerced string values. */
|
||||
var reFlags = /\w*$/;
|
||||
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
||||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
|
||||
|
||||
/**
|
||||
* Truncates `string` if it's longer than the given maximum string length.
|
||||
* The last characters of the truncated string are replaced with the omission
|
||||
@@ -85,7 +75,7 @@ function truncate(string, options) {
|
||||
return omission;
|
||||
}
|
||||
var result = strSymbols
|
||||
? strSymbols.slice(0, end).join('')
|
||||
? castSlice(strSymbols, 0, end).join('')
|
||||
: string.slice(0, end);
|
||||
|
||||
if (separator === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user