UNPKG

@botonic/plugin-contentful

Version:

Botonic Plugin Contentful is one of the **[available](https://github.com/hubtype/botonic/tree/master/packages)** plugins for Botonic. **[Contentful](http://www.contentful.com)** is a CMS (Content Management System) which manages contents of a great variet

33 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.replaceAll = exports.trim = exports.rtrim = exports.ltrim = void 0; const tslib_1 = require("tslib"); const escape_string_regexp_1 = tslib_1.__importDefault(require("escape-string-regexp")); function ltrim(str, chars) { while (str.length && chars.includes(str[0])) { str = str.slice(1); } return str; } exports.ltrim = ltrim; function rtrim(str, chars) { while (str.length && chars.includes(str[str.length - 1])) { str = str.slice(0, str.length - 1); } return str; } exports.rtrim = rtrim; function trim(str, chars) { str = rtrim(str, chars); return ltrim(str, chars); } exports.trim = trim; /** * String.replaceAll only available in esnext */ function replaceAll(haystack, oldStr, newStr) { oldStr = (0, escape_string_regexp_1.default)(oldStr); return haystack.replace(new RegExp(oldStr, 'g'), newStr); } exports.replaceAll = replaceAll; //# sourceMappingURL=strings.js.map