You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
687 B
30 lines
687 B
var regSpace = /^\s+/; |
|
exports = function(str, chars) { |
|
if (chars == null) { |
|
if (str.trimLeft) { |
|
return str.trimLeft(); |
|
} |
|
return str.replace(regSpace, ''); |
|
} |
|
var start = 0; |
|
var len = str.length; |
|
var charLen = chars.length; |
|
var found = true; |
|
var i; |
|
var 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); |
|
}; |
|
|
|
module.exports = exports;
|
|
|