ltrim.js
798 Bytes
define(['../lang/toString', './WHITE_SPACES'], function(toString, WHITE_SPACES){
/**
* Remove chars from beginning of string.
*/
function ltrim(str, chars) {
str = toString(str);
chars = chars || WHITE_SPACES;
var start = 0,
len = str.length,
charLen = chars.length,
found = true,
i, c;
while (found && start < len) {
found = false;
i = -1;
c = str.charAt(start);
while (++i < charLen) {
if (c === chars[i]) {
found = true;
start++;
break;
}
}
}
return (start >= len) ? '' : str.substr(start, len);
}
return ltrim;
});