Skip to content

Instantly share code, notes, and snippets.

@solotimes
solotimes / example.js
Created April 29, 2012 06:55
javascript truncate filename
var s = 'this-is-a-very-very-very-long-file-name.jpg';
console.log(truncate(s, 100)); //this-is-a-very-very-very-long-file-name.jpg
console.log(truncate(s, 10)); //this-is-a-[...].jpg
console.log(truncate(s, 4)); //this[...].jpg