Last active
December 12, 2015 04:38
-
-
Save madrobby/4716024 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.midTruncate = function(length, seperator){ | |
var left, right; | |
length = length || 30, left = Math.ceil(length/2), right = Math.floor(length/2); | |
seperator = seperator || '…'; | |
if (this.length<=(length+1)) return this.toString(); | |
return this.slice(0,left).strip()+seperator+this.slice(-right,this.length).strip(); | |
}; |
Author
madrobby
commented
Feb 5, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment