fixed case seq being multiple characters or empty
@@ -143,11 +143,15 @@ $.assert('example'.split('') == ['e', 'x', 'a', 'm', 'p', 'l', 'e'])
},
l_pad: #[desc("Returns a left-padded version of the string")]
(self, times: @number, seq: @string = ' ') -> @string {
- return seq * ([times-self.length, 0].max()) + self
+ pad = seq if seq.length > 0 else ' '
+ len = [times-self.length, 0].max()
+ return (pad * len).substr(0,len) + self
},
r_pad: #[desc("Returns a right-padded version of the string")]
(self, times: @number, seq: @string = ' ') -> @string {
- return self + seq * ([times-self.length, 0].max())
+ pad = seq if seq.length > 0 else ' '
+ len = [times-self.length, 0].max()
+ return self + (pad * len).substr(0,len)
},
l_trim: #[desc("Returns a left-trimmed verison of the string") example("
str1 = ' abcd g '
