d5c2931e97381581acbeb210d17404466e4370d4ebd8074e5339105e47e97da40f8817c318c2b46643053ed6e43229fa18f1b1a3c5de6088cfcfd9500c46fb 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * **The version of the punycode module bundled in Node.js is being deprecated. **In a future major version of Node.js this module will be removed. Users
  3. * currently depending on the `punycode` module should switch to using the
  4. * userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL
  5. * encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`.
  6. *
  7. * The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It
  8. * can be accessed using:
  9. *
  10. * ```js
  11. * import punycode from 'node:punycode';
  12. * ```
  13. *
  14. * [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is
  15. * primarily intended for use in Internationalized Domain Names. Because host
  16. * names in URLs are limited to ASCII characters only, Domain Names that contain
  17. * non-ASCII characters must be converted into ASCII using the Punycode scheme.
  18. * For instance, the Japanese character that translates into the English word, `'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent
  19. * to `'example.com'`) is represented by Punycode as the ASCII string `'xn--fsq.com'`.
  20. *
  21. * The `punycode` module provides a simple implementation of the Punycode standard.
  22. *
  23. * The `punycode` module is a third-party dependency used by Node.js and
  24. * made available to developers as a convenience. Fixes or other modifications to
  25. * the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project.
  26. * @deprecated Since v7.0.0 - Deprecated
  27. * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/punycode.js)
  28. */
  29. declare module "punycode" {
  30. /**
  31. * The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only
  32. * characters to the equivalent string of Unicode codepoints.
  33. *
  34. * ```js
  35. * punycode.decode('maana-pta'); // 'mañana'
  36. * punycode.decode('--dqo34k'); // '☃-⌘'
  37. * ```
  38. * @since v0.5.1
  39. */
  40. function decode(string: string): string;
  41. /**
  42. * The `punycode.encode()` method converts a string of Unicode codepoints to a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters.
  43. *
  44. * ```js
  45. * punycode.encode('mañana'); // 'maana-pta'
  46. * punycode.encode('☃-⌘'); // '--dqo34k'
  47. * ```
  48. * @since v0.5.1
  49. */
  50. function encode(string: string): string;
  51. /**
  52. * The `punycode.toUnicode()` method converts a string representing a domain name
  53. * containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492) encoded parts of the domain name are be
  54. * converted.
  55. *
  56. * ```js
  57. * // decode domain names
  58. * punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com'
  59. * punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com'
  60. * punycode.toUnicode('example.com'); // 'example.com'
  61. * ```
  62. * @since v0.6.1
  63. */
  64. function toUnicode(domain: string): string;
  65. /**
  66. * The `punycode.toASCII()` method converts a Unicode string representing an
  67. * Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the
  68. * domain name will be converted. Calling `punycode.toASCII()` on a string that
  69. * already only contains ASCII characters will have no effect.
  70. *
  71. * ```js
  72. * // encode domain names
  73. * punycode.toASCII('mañana.com'); // 'xn--maana-pta.com'
  74. * punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com'
  75. * punycode.toASCII('example.com'); // 'example.com'
  76. * ```
  77. * @since v0.6.1
  78. */
  79. function toASCII(domain: string): string;
  80. /**
  81. * @deprecated since v7.0.0
  82. * The version of the punycode module bundled in Node.js is being deprecated.
  83. * In a future major version of Node.js this module will be removed.
  84. * Users currently depending on the punycode module should switch to using
  85. * the userland-provided Punycode.js module instead.
  86. */
  87. const ucs2: ucs2;
  88. interface ucs2 {
  89. /**
  90. * @deprecated since v7.0.0
  91. * The version of the punycode module bundled in Node.js is being deprecated.
  92. * In a future major version of Node.js this module will be removed.
  93. * Users currently depending on the punycode module should switch to using
  94. * the userland-provided Punycode.js module instead.
  95. */
  96. decode(string: string): number[];
  97. /**
  98. * @deprecated since v7.0.0
  99. * The version of the punycode module bundled in Node.js is being deprecated.
  100. * In a future major version of Node.js this module will be removed.
  101. * Users currently depending on the punycode module should switch to using
  102. * the userland-provided Punycode.js module instead.
  103. */
  104. encode(codePoints: readonly number[]): string;
  105. }
  106. /**
  107. * @deprecated since v7.0.0
  108. * The version of the punycode module bundled in Node.js is being deprecated.
  109. * In a future major version of Node.js this module will be removed.
  110. * Users currently depending on the punycode module should switch to using
  111. * the userland-provided Punycode.js module instead.
  112. */
  113. const version: string;
  114. }
  115. declare module "node:punycode" {
  116. export * from "punycode";
  117. }