~webapps/unity-js-scopes/node.js

« back to all changes in this revision

Viewing changes to tools/eslint/node_modules/inquirer/node_modules/lodash/string/unescape.js

  • Committer: Marcus Tomlinson
  • Date: 2015-11-13 07:59:04 UTC
  • Revision ID: marcus.tomlinson@canonical.com-20151113075904-h0swczmoq1rvstfc
Node v4 (stable)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;