Sha256: af5e4dbe5704e24784697561272398053ee666b4595450ec45a3de559a01ad61
Contents?: true
Size: 642 Bytes
Versions: 69
Compression:
Stored size: 642 Bytes
Contents
define(['../lang/toString', './trim'], function(toString, trim){ /** * Limit number of chars. */ function truncate(str, maxChars, append, onlyFullWords){ str = toString(str); append = append || '...'; maxChars = onlyFullWords? maxChars + 1 : maxChars; str = trim(str); if(str.length <= maxChars){ return str; } str = str.substr(0, maxChars - append.length); //crop at last space or remove trailing whitespace str = onlyFullWords? str.substr(0, str.lastIndexOf(' ')) : trim(str); return str + append; } return truncate; });
Version data entries
69 entries across 69 versions & 2 rubygems