How to use the truncate function from underscore.string

Find comprehensive JavaScript underscore.string.truncate code examples handpicked from public code repositorys.

294
295
296
297
298
299
300
301
302
303
    var str = ""
    res.on("data", function (chunk) {
        str += chunk
    })
    res.on("end", function () {
        console.log("RESPONSE: " + _str.truncate(str, 30))
        deferred.resolve(str)
    })
})
req.on("error", function (error) {
fork icon12
star icon15
watch icon0

77
78
79
80
81
82
83
84
85
86
87
88
exports.rtrim = function(value, options, callback){
    callback(null, str.rtrim(String(value), typeof options[0] === 'string' ? options[0] : undefined));
};


exports.truncate = function(value, options, callback){
    callback(null, str.truncate(String(value), options[0], typeof options[1] === 'string' ? options[1] : undefined));
};


exports.prune = function(value, options, callback){
    callback(null, str.prune(String(value), options[0], typeof options[1] === 'string' ? options[1] : undefined));
fork icon2
star icon2
watch icon0

+ 2 other calls in file

34
35
36
37
38
39
40
41
42
43
},
escapejs: function(value) {
	return _string.quote(value);
},
stripText: function(value, args) {
	return _string.truncate(_string.stripTags(value), args[0] || 0, '...');
},
mot: function(value, args) {
	value = value.split(/[\s,.;?!:]+/);
	var n = args[0] ? args[0] - 1 : 0;
fork icon0
star icon1
watch icon0

+ 8 other calls in file