UNPKG

strman.removespaces

Version:

The [strman](https://github.com/dleitee/strman) method `removespaces` exported as a [Node.js](https://nodejs.org/) module.

38 lines (36 loc) 937 B
var replace = require('strman.replace') Object.defineProperty(exports, "__esModule", { value: true }); /** * @module removeSpaces * @description * Remove all spaces and replace for value. * ## Install * Install all functions of strman * ```sh * yarn add strman * ``` * or just the removeSpaces function * ```sh * yarn add strman.removespaces * ``` * ## Usage * ```javascript * import { removeSpaces } from 'strman' * // OR * import removeSpaces from 'strman.removespaces' * ``` * @param {String} value - The String! * @param {String} replaced - Value to replace. * @example * const title = ' s t r m a n ' * removeSpaces(title) * // => 'strman' * @returns {String} String without spaces. */ exports.default = function (value) { var replaced = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; return replace(value, '\\s+', replaced); }; module.exports = exports['default'];