source: node_modules/ramda-adjunct/lib/replaceAll.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[d24f17c]1"use strict";
2
3exports.__esModule = true;
4exports.replaceAllPonyfill = exports.replaceAllInvoker = exports["default"] = void 0;
5var _ramda = require("ramda");
6var _isFunction = _interopRequireDefault(require("./isFunction"));
7var _String = _interopRequireDefault(require("./internal/ponyfills/String.replaceAll"));
8function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
9var replaceAllPonyfill = (0, _ramda.curryN)(3, _String["default"]);
10exports.replaceAllPonyfill = replaceAllPonyfill;
11var replaceAllInvoker = (0, _ramda.invoker)(2, 'replaceAll');
12
13/**
14 * Replaces all substring matches in a string with a replacement.
15 *
16 * @func replaceAll
17 * @memberOf RA
18 * @since {@link https://char0n.github.io/ramda-adjunct/2.17.0|v2.17.0}
19 * @category String
20 * @sig String -> String -> String -> String
21 * @param {string} searchValue The substring or a global RegExp to match
22 * @param {string} replaceValue The string to replace the matches with
23 * @param {string} str The String to do the search and replacement in
24 * @return {string} A new string containing all the `searchValue` replaced with the `replaceValue`
25 * @throws {TypeError} When invalid arguments provided
26 * @see {@link http://ramdajs.com/docs/#replace|R.replace}, {@link https://github.com/tc39/proposal-string-replaceall|TC39 proposal}
27 * @example
28 *
29 * RA.replaceAll('ac', 'ef', 'ac ab ac ab'); //=> 'ef ab ef ab'
30 * RA.replaceAll('', '_', 'xxx'); //=> '_x_x_x_'
31 * RA.replaceAll(/x/g, 'v', 'xxx'); //=> 'vvv'
32 * RA.replaceAll(/x/, 'v', 'xxx'); //=> TypeError
33 */
34exports.replaceAllInvoker = replaceAllInvoker;
35var replaceAll = (0, _isFunction["default"])(String.prototype.replaceAll) ? replaceAllInvoker : replaceAllPonyfill;
36var _default = replaceAll;
37exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.