index.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
  3. * Build: `lodash modularize modern exports="npm" -o ./npm/`
  4. * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
  5. * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
  6. * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  7. * Available under MIT license <http://lodash.com/license>
  8. */
  9. var escapeHtmlChar = require('lodash._escapehtmlchar'),
  10. keys = require('lodash.keys'),
  11. reUnescapedHtml = require('lodash._reunescapedhtml');
  12. /**
  13. * Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their
  14. * corresponding HTML entities.
  15. *
  16. * @static
  17. * @memberOf _
  18. * @category Utilities
  19. * @param {string} string The string to escape.
  20. * @returns {string} Returns the escaped string.
  21. * @example
  22. *
  23. * _.escape('Fred, Wilma, & Pebbles');
  24. * // => 'Fred, Wilma, &amp; Pebbles'
  25. */
  26. function escape(string) {
  27. return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar);
  28. }
  29. module.exports = escape;