diff --git a/README.md b/README.md index f93fe914a..7a9522e36 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ A list of upcoming features is available on our [roadmap](https://github.com/lod * [_.bind](http://lodash.com/docs#bind), [_.curry](http://lodash.com/docs#curry), [_.partial](http://lodash.com/docs#partial), & [more](http://lodash.com/docs "_.bindKey, _.partialRight") support argument placeholders * [_.capitalize](http://lodash.com/docs#capitalize), [_.trim](http://lodash.com/docs#trim), & - [more](http://lodash.com/docs "_.camelCase, _.endsWith, _.escapeRegExp, _.kebabCase, _.pad, _.padLeft, _.padRight, _.repeat, _.snakeCase, _.startsWith, _.trimLeft, _.trimRight, _.truncate") string methods + [more](http://lodash.com/docs "_.camelCase, _.endsWith, _.escapeRegExp, _.kebabCase, _.pad, _.padLeft, _.padRight, _.repeat, _.snakeCase, _.startsWith, _.trimLeft, _.trimRight, _.trunc") string methods * [_.contains](http://lodash.com/docs#contains), [_.toArray](http://lodash.com/docs#toArray), & [more](http://lodash.com/docs "_.at, _.countBy, _.every, _.filter, _.find, _.forEach, _.forEachRight, _.groupBy, _.invoke, _.map, _.max, _.min, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.size, _.some, _.sortBy, _.where") accept strings * [_.dropWhile](http://lodash.com/docs#dropWhile), [_.takeWhile](http://lodash.com/docs#takeWhile), & diff --git a/lodash.js b/lodash.js index 851e26ac9..5c777b30c 100644 --- a/lodash.js +++ b/lodash.js @@ -7937,22 +7937,22 @@ * @returns {string} Returns the truncated string. * @example * - * _.truncate('hi-diddly-ho there, neighborino'); + * _.trunc('hi-diddly-ho there, neighborino'); * // => 'hi-diddly-ho there, neighbo...' * - * _.truncate('hi-diddly-ho there, neighborino', 24); + * _.trunc('hi-diddly-ho there, neighborino', 24); * // => 'hi-diddly-ho there, n...' * - * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); + * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); * // => 'hi-diddly-ho there,...' * - * _.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); + * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); * //=> 'hi-diddly-ho there...' * - * _.truncate('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); + * _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); * // => 'hi-diddly-ho there, neig [...]' */ - function truncate(string, options) { + function trunc(string, options) { var length = 30, omission = '...'; @@ -8740,7 +8740,7 @@ lodash.trim = trim; lodash.trimLeft = trimLeft; lodash.trimRight = trimRight; - lodash.truncate = truncate; + lodash.trunc = trunc; lodash.unescape = unescape; lodash.uniqueId = uniqueId; diff --git a/test/saucelabs.js b/test/saucelabs.js index 155729cbf..e08cf7ade 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -265,7 +265,7 @@ function isJobId(value) { */ function logInline(text) { var blankLine = _.repeat(' ', _.size(prevLine)); - prevLine = text = _.truncate(text, 40); + prevLine = text = _.trunc(text, 40); process.stdout.write(text + blankLine.slice(text.length) + '\r'); } diff --git a/test/test.js b/test/test.js index 925fb044b..cea191069 100644 --- a/test/test.js +++ b/test/test.js @@ -9148,55 +9148,55 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.truncate'); + QUnit.module('lodash.trunc'); (function() { var string = 'hi-diddly-ho there, neighborino'; test('should truncate to a length of `30` by default', 1, function() { - strictEqual(_.truncate(string), 'hi-diddly-ho there, neighbo...'); + strictEqual(_.trunc(string), 'hi-diddly-ho there, neighbo...'); }); test('should not truncate if `string` is <= `length`', 2, function() { - strictEqual(_.truncate(string, string.length), string); - strictEqual(_.truncate(string, string.length + 2), string); + strictEqual(_.trunc(string, string.length), string); + strictEqual(_.trunc(string, string.length + 2), string); }); test('should truncate string the given length', 1, function() { - strictEqual(_.truncate(string, 24), 'hi-diddly-ho there, n...'); + strictEqual(_.trunc(string, 24), 'hi-diddly-ho there, n...'); }); test('should support a `omission` option', 1, function() { - strictEqual(_.truncate(string, { 'omission': ' [...]' }), 'hi-diddly-ho there, neig [...]'); + strictEqual(_.trunc(string, { 'omission': ' [...]' }), 'hi-diddly-ho there, neig [...]'); }); test('should support a `length` option', 1, function() { - strictEqual(_.truncate(string, { 'length': 4 }), 'h...'); + strictEqual(_.trunc(string, { 'length': 4 }), 'h...'); }); test('should support a `separator` option', 2, function() { - strictEqual(_.truncate(string, { 'length': 24, 'separator': ' ' }), 'hi-diddly-ho there,...'); - strictEqual(_.truncate(string, { 'length': 24, 'separator': /,? +/ }), 'hi-diddly-ho there...'); + strictEqual(_.trunc(string, { 'length': 24, 'separator': ' ' }), 'hi-diddly-ho there,...'); + strictEqual(_.trunc(string, { 'length': 24, 'separator': /,? +/ }), 'hi-diddly-ho there...'); }); test('should treat negative `length` as `0`', 4, function() { _.each([0, -2], function(length) { - strictEqual(_.truncate(string, length), '...'); - strictEqual(_.truncate(string, { 'length': length }), '...'); + strictEqual(_.trunc(string, length), '...'); + strictEqual(_.trunc(string, { 'length': length }), '...'); }); }); test('should coerce `length` to a number', 4, function() { _.each(['', '4'], function(length, index) { var actual = index ? 'h...' : '...'; - strictEqual(_.truncate(string, length), actual); - strictEqual(_.truncate(string, { 'length': { 'valueOf': _.constant(length) } }), actual); + strictEqual(_.trunc(string, length), actual); + strictEqual(_.trunc(string, { 'length': { 'valueOf': _.constant(length) } }), actual); }); }); test('should coerce `string` to a string', 2, function() { - strictEqual(_.truncate(Object(string), 4), 'h...'); - strictEqual(_.truncate({ 'toString': _.constant(string) }, 5), 'hi...'); + strictEqual(_.trunc(Object(string), 4), 'h...'); + strictEqual(_.trunc({ 'toString': _.constant(string) }, 5), 'hi...'); }); }()); @@ -10747,7 +10747,7 @@ 'trim', 'trimLeft', 'trimRight', - 'truncate', + 'trunc', 'unescape' ];