function trim(haystack, needle) {
        if (needle === void 0) { needle = ' '; }
        var trimmed = ltrim(haystack, needle);
        return rtrim(trimmed, needle);
    }
Removes all occurrences of needle from the beginning and end of haystack.
@param haystack string to trim
@param needle the thing to trim (default is a blank)