index.js 961 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @typedef {import('./core.js').CoreOptions & import('./util/format-smart.js').FormatSmartOptions} Options
  3. * @typedef {import('./core.js').CoreOptions} LightOptions
  4. */
  5. import {core} from './core.js'
  6. import {formatSmart} from './util/format-smart.js'
  7. import {formatBasic} from './util/format-basic.js'
  8. /**
  9. * Encode special characters in `value`.
  10. *
  11. * @param {string} value
  12. * Value to encode.
  13. * @param {Options} [options]
  14. * Configuration.
  15. * @returns {string}
  16. * Encoded value.
  17. */
  18. export function stringifyEntities(value, options) {
  19. return core(value, Object.assign({format: formatSmart}, options))
  20. }
  21. /**
  22. * Encode special characters in `value` as hexadecimals.
  23. *
  24. * @param {string} value
  25. * Value to encode.
  26. * @param {LightOptions} [options]
  27. * Configuration.
  28. * @returns {string}
  29. * Encoded value.
  30. */
  31. export function stringifyEntitiesLight(value, options) {
  32. return core(value, Object.assign({format: formatBasic}, options))
  33. }