source: imaps-frontend/node_modules/lodash-es/replace.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 752 bytes
Line 
1import toString from './toString.js';
2
3/**
4 * Replaces matches for `pattern` in `string` with `replacement`.
5 *
6 * **Note:** This method is based on
7 * [`String#replace`](https://mdn.io/String/replace).
8 *
9 * @static
10 * @memberOf _
11 * @since 4.0.0
12 * @category String
13 * @param {string} [string=''] The string to modify.
14 * @param {RegExp|string} pattern The pattern to replace.
15 * @param {Function|string} replacement The match replacement.
16 * @returns {string} Returns the modified string.
17 * @example
18 *
19 * _.replace('Hi Fred', 'Fred', 'Barney');
20 * // => 'Hi Barney'
21 */
22function replace() {
23 var args = arguments,
24 string = toString(args[0]);
25
26 return args.length < 3 ? string : string.replace(args[1], args[2]);
27}
28
29export default replace;
Note: See TracBrowser for help on using the repository browser.