Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / string / unescape.js
1 var baseToString = require('../internal/baseToString'),
2     unescapeHtmlChar = require('../internal/unescapeHtmlChar');
3
4 /** Used to match HTML entities and HTML characters. */
5 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,
6     reHasEscapedHtml = RegExp(reEscapedHtml.source);
7
8 /**
9  * The inverse of `_.escape`; this method converts the HTML entities
10  * `&`, `<`, `>`, `"`, `'`, and ``` in `string` to their
11  * corresponding characters.
12  *
13  * **Note:** No other HTML entities are unescaped. To unescape additional HTML
14  * entities use a third-party library like [_he_](https://mths.be/he).
15  *
16  * @static
17  * @memberOf _
18  * @category String
19  * @param {string} [string=''] The string to unescape.
20  * @returns {string} Returns the unescaped string.
21  * @example
22  *
23  * _.unescape('fred, barney, & pebbles');
24  * // => 'fred, barney, & pebbles'
25  */
26 function unescape(string) {
27   string = baseToString(string);
28   return (string && reHasEscapedHtml.test(string))
29     ? string.replace(reEscapedHtml, unescapeHtmlChar)
30     : string;
31 }
32
33 module.exports = unescape;