(str, leading, trailing, predicate)
| 3713 | function removeHTTPWhitespace(str, leading = true, trailing = true) { |
| 3714 | return removeChars(str, leading, trailing, isHTTPWhiteSpace); |
| 3715 | } |
| 3716 | function isASCIIWhitespace(char) { |
| 3717 | return char === 13 || char === 10 || char === 9 || char === 12 || char === 32; |
| 3718 | } |
| 3719 | function removeASCIIWhitespace(str, leading = true, trailing = true) { |
| 3720 | return removeChars(str, leading, trailing, isASCIIWhitespace); |
| 3721 | } |
| 3722 | function removeChars(str, leading, trailing, predicate) { |
| 3723 | let lead = 0; |
| 3724 | let trail = str.length - 1; |
| 3725 | if (leading) { |
| 3726 | while (lead < str.length && predicate(str.charCodeAt(lead))) |
| 3727 | lead++; |
| 3728 | } |
| 3729 | if (trailing) { |
| 3730 | while (trail > 0 && predicate(str.charCodeAt(trail))) |
no test coverage detected