index.d.ts 969 B

1234567891011121314151617181920
  1. export declare type Level = 'xml' | 'html4' | 'html5' | 'all';
  2. interface CommonOptions {
  3. level?: Level;
  4. }
  5. export declare type EncodeMode = 'specialChars' | 'nonAscii' | 'nonAsciiPrintable' | 'extensive';
  6. export interface EncodeOptions extends CommonOptions {
  7. mode?: EncodeMode;
  8. numeric?: 'decimal' | 'hexadecimal';
  9. }
  10. export declare type DecodeScope = 'strict' | 'body' | 'attribute';
  11. export interface DecodeOptions extends CommonOptions {
  12. scope?: DecodeScope;
  13. }
  14. /** Encodes all the necessary (specified by `level`) characters in the text */
  15. export declare function encode(text: string | undefined | null, { mode, numeric, level }?: EncodeOptions): string;
  16. /** Decodes a single entity */
  17. export declare function decodeEntity(entity: string | undefined | null, { level }?: CommonOptions): string;
  18. /** Decodes all entities in the text */
  19. export declare function decode(text: string | undefined | null, { level, scope }?: DecodeOptions): string;
  20. export {};