UNPKG

x-js-utils

Version:
24 lines (23 loc) 599 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var trim = function (str, pos) { if (pos === void 0) { pos = 'both'; } if (typeof str !== "string") return ""; if (pos == 'both') { return str.replace(/^\s+|\s+$/g, ""); } else if (pos == "left") { return str.replace(/^\s*/, ''); } else if (pos == 'right') { return str.replace(/(\s*$)/g, ""); } else if (pos == 'all') { return str.replace(/\s+/g, ""); } else { return str; } }; exports.default = trim;