2 title: Underscore-string
3 category: JavaScript libraries
14 _.mixin(_.string.exports());
22 _.truncate("Hello world", 4) // => "Hell..."
23 _.prune("Hello world", 5) // => "Hello..."
25 _.trim(" foo ") // => "foo"
26 _.trim("-foo-", '-') // => "foo"
32 _.numberFormat(1000, 2) // => "1,000.00"
36 _.capitalize("foo bar") // => "Foo Bar"
37 _.humanize("hey-there foo") // => "Hey there foo"
38 _.titleize('My name is hi') // => "My Name Is Hi"
40 _.dasherize('MozTransform') // => "-moz-transform"
41 _.underscored('MozTransform') // => "moz_transform"
42 _.classify('-moz-transform') // => "MozTransform"
43 _.camelize('moz_transform') // => "MozTransform"
45 _.slugify("hey there") // => "hey-there"
47 _.swapCase("hELLO") // => "Hello"
51 _.startsWith('image.gif', 'image') // => true
52 _.endsWith('image.gif', '.gif') // => true
53 _.isBlank(" ") // => true (also for "\n", "")
58 _.unescapeHTML("<div>")
59 _.stripTags("<div>hi</div>")
63 _.quote("hi", '"') // => '"hi"'
64 _.unquote('"hi"') // => "hi"
68 _.lines("hi\nthere") // => ["hi","there"]
69 _.words("hi there you") // => ["hi","there","you"]
73 _.sprintf("%.1f", 1.17)
77 _.pad("1", 8) // => " 1"
78 _.pad("1", 8, "0") // => "00000001"
79 _.pad("1", 8, " ", "right") // => "1 "
80 _.pad("1", 8, " ", "both") // => " 1 "
82 _.lpad(..) // same as _.pad(.., 'left')
83 _.rpad(..) // same as _.pad(.., 'right')
84 _.lrpad(..) // same as _.pad(.., 'both')
88 * https://github.com/epeli/underscore.string