@pnpm/exe 11.0.0-alpha.9 → 11.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/node_modules/@gar/promise-retry/lib/index.js +28 -0
  2. package/dist/node_modules/@gar/promise-retry/package.json +48 -0
  3. package/dist/node_modules/@npmcli/agent/package.json +7 -7
  4. package/dist/node_modules/@npmcli/fs/package.json +4 -4
  5. package/dist/node_modules/abbrev/package.json +11 -15
  6. package/dist/node_modules/balanced-match/package.json +4 -7
  7. package/dist/node_modules/brace-expansion/dist/commonjs/index.js +1 -1
  8. package/dist/node_modules/brace-expansion/dist/esm/index.js +1 -1
  9. package/dist/node_modules/brace-expansion/package.json +3 -3
  10. package/dist/node_modules/cacache/package.json +10 -11
  11. package/dist/node_modules/glob/dist/commonjs/glob.js +2 -1
  12. package/dist/node_modules/glob/dist/commonjs/index.min.js +4 -0
  13. package/dist/node_modules/glob/dist/commonjs/pattern.js +4 -0
  14. package/dist/node_modules/glob/dist/esm/glob.js +2 -1
  15. package/dist/node_modules/glob/dist/esm/index.min.js +4 -0
  16. package/dist/node_modules/glob/dist/esm/pattern.js +4 -0
  17. package/dist/node_modules/glob/package.json +38 -37
  18. package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +460 -525
  19. package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +179 -182
  20. package/dist/node_modules/iconv-lite/encodings/index.js +15 -15
  21. package/dist/node_modules/iconv-lite/encodings/internal.js +168 -148
  22. package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +55 -52
  23. package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +174 -175
  24. package/dist/node_modules/iconv-lite/encodings/utf16.js +121 -131
  25. package/dist/node_modules/iconv-lite/encodings/utf32.js +226 -238
  26. package/dist/node_modules/iconv-lite/encodings/utf7.js +208 -215
  27. package/dist/node_modules/iconv-lite/lib/bom-handling.js +30 -34
  28. package/dist/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  29. package/dist/node_modules/iconv-lite/lib/index.js +125 -123
  30. package/dist/node_modules/iconv-lite/lib/streams.js +92 -96
  31. package/dist/node_modules/iconv-lite/package.json +34 -8
  32. package/dist/node_modules/isexe/package.json +65 -18
  33. package/dist/node_modules/lru-cache/dist/commonjs/index.js +134 -85
  34. package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  35. package/dist/node_modules/lru-cache/dist/esm/index.js +134 -85
  36. package/dist/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  37. package/dist/node_modules/lru-cache/package.json +18 -41
  38. package/dist/node_modules/make-fetch-happen/lib/remote.js +1 -1
  39. package/dist/node_modules/make-fetch-happen/package.json +10 -10
  40. package/dist/node_modules/minimatch/dist/commonjs/ast.js +266 -21
  41. package/dist/node_modules/minimatch/dist/commonjs/index.js +178 -92
  42. package/dist/node_modules/minimatch/dist/esm/ast.js +266 -21
  43. package/dist/node_modules/minimatch/dist/esm/index.js +178 -92
  44. package/dist/node_modules/minimatch/package.json +4 -4
  45. package/dist/node_modules/minipass/dist/commonjs/index.js +13 -3
  46. package/dist/node_modules/minipass/dist/esm/index.js +3 -1
  47. package/dist/node_modules/minipass/package.json +9 -14
  48. package/dist/node_modules/minipass-fetch/lib/body.js +25 -15
  49. package/dist/node_modules/minipass-fetch/package.json +7 -7
  50. package/dist/node_modules/minipass-sized/dist/commonjs/index.js +69 -0
  51. package/dist/node_modules/minipass-sized/dist/esm/index.js +64 -0
  52. package/dist/node_modules/minipass-sized/package.json +39 -9
  53. package/dist/node_modules/node-gyp/.release-please-manifest.json +1 -1
  54. package/dist/node_modules/node-gyp/bin/node-gyp.js +7 -0
  55. package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +1 -1
  56. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +3 -3
  57. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +26 -1
  58. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +1 -1
  59. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +3 -4
  60. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +1 -1
  61. package/dist/node_modules/node-gyp/gyp/pyproject.toml +1 -1
  62. package/dist/node_modules/node-gyp/lib/build.js +2 -2
  63. package/dist/node_modules/node-gyp/lib/find-python.js +2 -8
  64. package/dist/node_modules/node-gyp/lib/find-visualstudio.js +11 -5
  65. package/dist/node_modules/node-gyp/lib/install.js +1 -1
  66. package/dist/node_modules/node-gyp/lib/process-release.js +3 -3
  67. package/dist/node_modules/node-gyp/package.json +13 -13
  68. package/dist/node_modules/nopt/package.json +5 -5
  69. package/dist/node_modules/path-scurry/package.json +8 -24
  70. package/dist/node_modules/proc-log/lib/index.js +10 -5
  71. package/dist/node_modules/proc-log/package.json +5 -5
  72. package/dist/node_modules/retry/lib/retry.js +2 -2
  73. package/dist/node_modules/retry/lib/retry_operation.js +10 -6
  74. package/dist/node_modules/retry/package.json +6 -2
  75. package/dist/node_modules/ssri/lib/index.js +33 -63
  76. package/dist/node_modules/ssri/package.json +17 -17
  77. package/dist/node_modules/tar/dist/commonjs/index.min.js +2 -2
  78. package/dist/node_modules/tar/dist/commonjs/unpack.js +4 -4
  79. package/dist/node_modules/tar/dist/esm/index.min.js +2 -2
  80. package/dist/node_modules/tar/dist/esm/unpack.js +4 -4
  81. package/dist/node_modules/tar/package.json +6 -6
  82. package/dist/node_modules/unique-filename/package.json +5 -5
  83. package/dist/node_modules/unique-slug/package.json +4 -4
  84. package/dist/node_modules/which/package.json +29 -20
  85. package/dist/pnpm.mjs +225713 -208017
  86. package/dist/worker.js +4838 -5926
  87. package/package.json +10 -10
  88. package/setup.js +12 -14
  89. package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-regex/index.js +0 -16
  90. package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-styles/index.js +0 -170
  91. package/dist/node_modules/@isaacs/cliui/dist/commonjs/eastasianwidth/index.js +0 -307
  92. package/dist/node_modules/@isaacs/cliui/dist/commonjs/emoji-regex/index.js +0 -7
  93. package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.js +0 -322
  94. package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.min.js +0 -12
  95. package/dist/node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js +0 -49
  96. package/dist/node_modules/@isaacs/cliui/dist/commonjs/strip-ansi/index.js +0 -8
  97. package/dist/node_modules/@isaacs/cliui/dist/commonjs/wrap-ansi/index.js +0 -176
  98. package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-regex/index.js +0 -12
  99. package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-styles/index.js +0 -167
  100. package/dist/node_modules/@isaacs/cliui/dist/esm/eastasianwidth/index.js +0 -299
  101. package/dist/node_modules/@isaacs/cliui/dist/esm/emoji-regex/index.js +0 -3
  102. package/dist/node_modules/@isaacs/cliui/dist/esm/index.js +0 -317
  103. package/dist/node_modules/@isaacs/cliui/dist/esm/index.min.js +0 -12
  104. package/dist/node_modules/@isaacs/cliui/dist/esm/string-width/index.js +0 -46
  105. package/dist/node_modules/@isaacs/cliui/dist/esm/strip-ansi/index.js +0 -4
  106. package/dist/node_modules/@isaacs/cliui/dist/esm/wrap-ansi/index.js +0 -172
  107. package/dist/node_modules/@isaacs/cliui/package.json +0 -163
  108. package/dist/node_modules/cross-spawn/LICENSE +0 -21
  109. package/dist/node_modules/cross-spawn/index.js +0 -39
  110. package/dist/node_modules/cross-spawn/lib/enoent.js +0 -59
  111. package/dist/node_modules/cross-spawn/lib/parse.js +0 -91
  112. package/dist/node_modules/cross-spawn/lib/util/escape.js +0 -47
  113. package/dist/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
  114. package/dist/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
  115. package/dist/node_modules/cross-spawn/package.json +0 -73
  116. package/dist/node_modules/encoding/.prettierrc.js +0 -8
  117. package/dist/node_modules/encoding/LICENSE +0 -16
  118. package/dist/node_modules/encoding/lib/encoding.js +0 -83
  119. package/dist/node_modules/encoding/package.json +0 -18
  120. package/dist/node_modules/err-code/.eslintrc.json +0 -7
  121. package/dist/node_modules/err-code/bower.json +0 -30
  122. package/dist/node_modules/err-code/index.js +0 -47
  123. package/dist/node_modules/err-code/index.umd.js +0 -51
  124. package/dist/node_modules/err-code/package.json +0 -34
  125. package/dist/node_modules/foreground-child/LICENSE +0 -15
  126. package/dist/node_modules/foreground-child/dist/commonjs/all-signals.js +0 -58
  127. package/dist/node_modules/foreground-child/dist/commonjs/index.js +0 -123
  128. package/dist/node_modules/foreground-child/dist/commonjs/proxy-signals.js +0 -38
  129. package/dist/node_modules/foreground-child/dist/commonjs/watchdog.js +0 -50
  130. package/dist/node_modules/foreground-child/dist/esm/all-signals.js +0 -52
  131. package/dist/node_modules/foreground-child/dist/esm/index.js +0 -115
  132. package/dist/node_modules/foreground-child/dist/esm/proxy-signals.js +0 -34
  133. package/dist/node_modules/foreground-child/dist/esm/watchdog.js +0 -46
  134. package/dist/node_modules/foreground-child/package.json +0 -106
  135. package/dist/node_modules/glob/dist/esm/bin.d.mts +0 -3
  136. package/dist/node_modules/glob/dist/esm/bin.mjs +0 -346
  137. package/dist/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  138. package/dist/node_modules/iconv-lite/.idea/codeStyles/Project.xml +0 -47
  139. package/dist/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +0 -5
  140. package/dist/node_modules/iconv-lite/.idea/iconv-lite.iml +0 -12
  141. package/dist/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +0 -6
  142. package/dist/node_modules/iconv-lite/.idea/modules.xml +0 -8
  143. package/dist/node_modules/iconv-lite/.idea/vcs.xml +0 -6
  144. package/dist/node_modules/isexe/LICENSE +0 -15
  145. package/dist/node_modules/isexe/index.js +0 -57
  146. package/dist/node_modules/isexe/mode.js +0 -41
  147. package/dist/node_modules/isexe/windows.js +0 -42
  148. package/dist/node_modules/jackspeak/dist/commonjs/index.js +0 -944
  149. package/dist/node_modules/jackspeak/dist/commonjs/index.min.js +0 -33
  150. package/dist/node_modules/jackspeak/dist/commonjs/package.json +0 -3
  151. package/dist/node_modules/jackspeak/dist/esm/index.js +0 -936
  152. package/dist/node_modules/jackspeak/dist/esm/index.min.js +0 -33
  153. package/dist/node_modules/jackspeak/dist/esm/package.json +0 -3
  154. package/dist/node_modules/jackspeak/package.json +0 -115
  155. package/dist/node_modules/lru-cache/LICENSE +0 -15
  156. package/dist/node_modules/minipass/LICENSE +0 -15
  157. package/dist/node_modules/minipass-sized/index.js +0 -67
  158. package/dist/node_modules/minipass-sized/node_modules/minipass/LICENSE +0 -15
  159. package/dist/node_modules/minipass-sized/node_modules/minipass/index.js +0 -649
  160. package/dist/node_modules/minipass-sized/node_modules/minipass/package.json +0 -56
  161. package/dist/node_modules/minipass-sized/package-lock.json +0 -3464
  162. package/dist/node_modules/node-gyp/node_modules/isexe/dist/commonjs/package.json +0 -3
  163. package/dist/node_modules/node-gyp/node_modules/isexe/dist/esm/package.json +0 -3
  164. package/dist/node_modules/node-gyp/node_modules/isexe/package.json +0 -78
  165. package/dist/node_modules/node-gyp/node_modules/which/LICENSE +0 -15
  166. package/dist/node_modules/node-gyp/node_modules/which/package.json +0 -52
  167. package/dist/node_modules/package-json-from-dist/dist/commonjs/index.js +0 -134
  168. package/dist/node_modules/package-json-from-dist/dist/commonjs/package.json +0 -3
  169. package/dist/node_modules/package-json-from-dist/dist/esm/index.js +0 -129
  170. package/dist/node_modules/package-json-from-dist/dist/esm/package.json +0 -3
  171. package/dist/node_modules/package-json-from-dist/package.json +0 -68
  172. package/dist/node_modules/path-key/index.js +0 -16
  173. package/dist/node_modules/path-key/license +0 -9
  174. package/dist/node_modules/path-key/package.json +0 -39
  175. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +0 -1589
  176. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +0 -2
  177. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +0 -3
  178. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +0 -1585
  179. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +0 -2
  180. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +0 -3
  181. package/dist/node_modules/path-scurry/node_modules/lru-cache/package.json +0 -101
  182. package/dist/node_modules/promise-retry/index.js +0 -52
  183. package/dist/node_modules/promise-retry/package.json +0 -37
  184. package/dist/node_modules/retry/equation.gif +0 -0
  185. package/dist/node_modules/shebang-command/index.js +0 -19
  186. package/dist/node_modules/shebang-command/license +0 -9
  187. package/dist/node_modules/shebang-command/package.json +0 -34
  188. package/dist/node_modules/shebang-regex/index.js +0 -2
  189. package/dist/node_modules/shebang-regex/license +0 -9
  190. package/dist/node_modules/shebang-regex/package.json +0 -35
  191. package/dist/node_modules/signal-exit/LICENSE.txt +0 -16
  192. package/dist/node_modules/signal-exit/dist/cjs/browser.js +0 -10
  193. package/dist/node_modules/signal-exit/dist/cjs/index.js +0 -279
  194. package/dist/node_modules/signal-exit/dist/cjs/package.json +0 -3
  195. package/dist/node_modules/signal-exit/dist/cjs/signals.js +0 -42
  196. package/dist/node_modules/signal-exit/dist/mjs/browser.js +0 -4
  197. package/dist/node_modules/signal-exit/dist/mjs/index.js +0 -275
  198. package/dist/node_modules/signal-exit/dist/mjs/package.json +0 -3
  199. package/dist/node_modules/signal-exit/dist/mjs/signals.js +0 -39
  200. package/dist/node_modules/signal-exit/package.json +0 -106
  201. package/dist/node_modules/which/bin/node-which +0 -52
  202. package/dist/node_modules/which/which.js +0 -125
  203. /package/dist/node_modules/{promise-retry → @gar/promise-retry}/LICENSE +0 -0
  204. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.js +0 -0
  205. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.min.js +0 -0
  206. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/options.js +0 -0
  207. /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/commonjs/package.json +0 -0
  208. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/posix.js +0 -0
  209. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/win32.js +0 -0
  210. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.js +0 -0
  211. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.min.js +0 -0
  212. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/options.js +0 -0
  213. /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/esm/package.json +0 -0
  214. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/posix.js +0 -0
  215. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/win32.js +0 -0
  216. /package/dist/node_modules/{foreground-child → minipass-sized}/dist/commonjs/package.json +0 -0
  217. /package/dist/node_modules/{foreground-child → minipass-sized}/dist/esm/package.json +0 -0
  218. /package/dist/node_modules/{node-gyp/node_modules/which → which}/bin/which.js +0 -0
  219. /package/dist/node_modules/{node-gyp/node_modules/which → which}/lib/index.js +0 -0
@@ -1,198 +1,218 @@
1
- "use strict";
2
- var Buffer = require("safer-buffer").Buffer;
1
+ "use strict"
2
+ var Buffer = require("safer-buffer").Buffer
3
3
 
4
4
  // Export Node.js internal encodings.
5
5
 
6
6
  module.exports = {
7
- // Encodings
8
- utf8: { type: "_internal", bomAware: true},
9
- cesu8: { type: "_internal", bomAware: true},
10
- unicode11utf8: "utf8",
11
-
12
- ucs2: { type: "_internal", bomAware: true},
13
- utf16le: "ucs2",
14
-
15
- binary: { type: "_internal" },
16
- base64: { type: "_internal" },
17
- hex: { type: "_internal" },
18
-
19
- // Codec.
20
- _internal: InternalCodec,
21
- };
22
-
23
- //------------------------------------------------------------------------------
24
-
25
- function InternalCodec(codecOptions, iconv) {
26
- this.enc = codecOptions.encodingName;
27
- this.bomAware = codecOptions.bomAware;
28
-
29
- if (this.enc === "base64")
30
- this.encoder = InternalEncoderBase64;
31
- else if (this.enc === "cesu8") {
32
- this.enc = "utf8"; // Use utf8 for decoding.
33
- this.encoder = InternalEncoderCesu8;
34
-
35
- // Add decoder for versions of Node not supporting CESU-8
36
- if (Buffer.from('eda0bdedb2a9', 'hex').toString() !== '💩') {
37
- this.decoder = InternalDecoderCesu8;
38
- this.defaultCharUnicode = iconv.defaultCharUnicode;
39
- }
40
- }
41
- }
7
+ // Encodings
8
+ utf8: { type: "_internal", bomAware: true },
9
+ cesu8: { type: "_internal", bomAware: true },
10
+ unicode11utf8: "utf8",
42
11
 
43
- InternalCodec.prototype.encoder = InternalEncoder;
44
- InternalCodec.prototype.decoder = InternalDecoder;
12
+ ucs2: { type: "_internal", bomAware: true },
13
+ utf16le: "ucs2",
45
14
 
46
- //------------------------------------------------------------------------------
15
+ binary: { type: "_internal" },
16
+ base64: { type: "_internal" },
17
+ hex: { type: "_internal" },
47
18
 
48
- // We use node.js internal decoder. Its signature is the same as ours.
49
- var StringDecoder = require('string_decoder').StringDecoder;
19
+ // Codec.
20
+ _internal: InternalCodec
21
+ }
50
22
 
51
- if (!StringDecoder.prototype.end) // Node v0.8 doesn't have this method.
52
- StringDecoder.prototype.end = function() {};
23
+ // ------------------------------------------------------------------------------
53
24
 
25
+ function InternalCodec (codecOptions, iconv) {
26
+ this.enc = codecOptions.encodingName
27
+ this.bomAware = codecOptions.bomAware
54
28
 
55
- function InternalDecoder(options, codec) {
56
- this.decoder = new StringDecoder(codec.enc);
57
- }
29
+ if (this.enc === "base64") { this.encoder = InternalEncoderBase64 } else if (this.enc === "utf8") { this.encoder = InternalEncoderUtf8 } else if (this.enc === "cesu8") {
30
+ this.enc = "utf8" // Use utf8 for decoding.
31
+ this.encoder = InternalEncoderCesu8
58
32
 
59
- InternalDecoder.prototype.write = function(buf) {
60
- if (!Buffer.isBuffer(buf)) {
61
- buf = Buffer.from(buf);
33
+ // Add decoder for versions of Node not supporting CESU-8
34
+ if (Buffer.from("eda0bdedb2a9", "hex").toString() !== "💩") {
35
+ this.decoder = InternalDecoderCesu8
36
+ this.defaultCharUnicode = iconv.defaultCharUnicode
62
37
  }
38
+ }
39
+ }
63
40
 
64
- return this.decoder.write(buf);
41
+ InternalCodec.prototype.encoder = InternalEncoder
42
+ InternalCodec.prototype.decoder = InternalDecoder
43
+
44
+ // ------------------------------------------------------------------------------
45
+
46
+ // We use node.js internal decoder. Its signature is the same as ours.
47
+ var StringDecoder = require("string_decoder").StringDecoder
48
+
49
+ function InternalDecoder (options, codec) {
50
+ this.decoder = new StringDecoder(codec.enc)
65
51
  }
66
52
 
67
- InternalDecoder.prototype.end = function() {
68
- return this.decoder.end();
53
+ InternalDecoder.prototype.write = function (buf) {
54
+ if (!Buffer.isBuffer(buf)) {
55
+ buf = Buffer.from(buf)
56
+ }
57
+
58
+ return this.decoder.write(buf)
69
59
  }
70
60
 
61
+ InternalDecoder.prototype.end = function () {
62
+ return this.decoder.end()
63
+ }
71
64
 
72
- //------------------------------------------------------------------------------
65
+ // ------------------------------------------------------------------------------
73
66
  // Encoder is mostly trivial
74
67
 
75
- function InternalEncoder(options, codec) {
76
- this.enc = codec.enc;
68
+ function InternalEncoder (options, codec) {
69
+ this.enc = codec.enc
77
70
  }
78
71
 
79
- InternalEncoder.prototype.write = function(str) {
80
- return Buffer.from(str, this.enc);
72
+ InternalEncoder.prototype.write = function (str) {
73
+ return Buffer.from(str, this.enc)
81
74
  }
82
75
 
83
- InternalEncoder.prototype.end = function() {
76
+ InternalEncoder.prototype.end = function () {
84
77
  }
85
78
 
86
-
87
- //------------------------------------------------------------------------------
79
+ // ------------------------------------------------------------------------------
88
80
  // Except base64 encoder, which must keep its state.
89
81
 
90
- function InternalEncoderBase64(options, codec) {
91
- this.prevStr = '';
82
+ function InternalEncoderBase64 (options, codec) {
83
+ this.prevStr = ""
92
84
  }
93
85
 
94
- InternalEncoderBase64.prototype.write = function(str) {
95
- str = this.prevStr + str;
96
- var completeQuads = str.length - (str.length % 4);
97
- this.prevStr = str.slice(completeQuads);
98
- str = str.slice(0, completeQuads);
86
+ InternalEncoderBase64.prototype.write = function (str) {
87
+ str = this.prevStr + str
88
+ var completeQuads = str.length - (str.length % 4)
89
+ this.prevStr = str.slice(completeQuads)
90
+ str = str.slice(0, completeQuads)
99
91
 
100
- return Buffer.from(str, "base64");
92
+ return Buffer.from(str, "base64")
101
93
  }
102
94
 
103
- InternalEncoderBase64.prototype.end = function() {
104
- return Buffer.from(this.prevStr, "base64");
95
+ InternalEncoderBase64.prototype.end = function () {
96
+ return Buffer.from(this.prevStr, "base64")
105
97
  }
106
98
 
107
-
108
- //------------------------------------------------------------------------------
99
+ // ------------------------------------------------------------------------------
109
100
  // CESU-8 encoder is also special.
110
101
 
111
- function InternalEncoderCesu8(options, codec) {
102
+ function InternalEncoderCesu8 (options, codec) {
103
+ }
104
+
105
+ InternalEncoderCesu8.prototype.write = function (str) {
106
+ var buf = Buffer.alloc(str.length * 3); var bufIdx = 0
107
+ for (var i = 0; i < str.length; i++) {
108
+ var charCode = str.charCodeAt(i)
109
+ // Naive implementation, but it works because CESU-8 is especially easy
110
+ // to convert from UTF-16 (which all JS strings are encoded in).
111
+ if (charCode < 0x80) { buf[bufIdx++] = charCode } else if (charCode < 0x800) {
112
+ buf[bufIdx++] = 0xC0 + (charCode >>> 6)
113
+ buf[bufIdx++] = 0x80 + (charCode & 0x3f)
114
+ } else { // charCode will always be < 0x10000 in javascript.
115
+ buf[bufIdx++] = 0xE0 + (charCode >>> 12)
116
+ buf[bufIdx++] = 0x80 + ((charCode >>> 6) & 0x3f)
117
+ buf[bufIdx++] = 0x80 + (charCode & 0x3f)
118
+ }
119
+ }
120
+ return buf.slice(0, bufIdx)
112
121
  }
113
122
 
114
- InternalEncoderCesu8.prototype.write = function(str) {
115
- var buf = Buffer.alloc(str.length * 3), bufIdx = 0;
116
- for (var i = 0; i < str.length; i++) {
117
- var charCode = str.charCodeAt(i);
118
- // Naive implementation, but it works because CESU-8 is especially easy
119
- // to convert from UTF-16 (which all JS strings are encoded in).
120
- if (charCode < 0x80)
121
- buf[bufIdx++] = charCode;
122
- else if (charCode < 0x800) {
123
- buf[bufIdx++] = 0xC0 + (charCode >>> 6);
124
- buf[bufIdx++] = 0x80 + (charCode & 0x3f);
125
- }
126
- else { // charCode will always be < 0x10000 in javascript.
127
- buf[bufIdx++] = 0xE0 + (charCode >>> 12);
128
- buf[bufIdx++] = 0x80 + ((charCode >>> 6) & 0x3f);
129
- buf[bufIdx++] = 0x80 + (charCode & 0x3f);
123
+ InternalEncoderCesu8.prototype.end = function () {
124
+ }
125
+
126
+ // ------------------------------------------------------------------------------
127
+ // CESU-8 decoder is not implemented in Node v4.0+
128
+
129
+ function InternalDecoderCesu8 (options, codec) {
130
+ this.acc = 0
131
+ this.contBytes = 0
132
+ this.accBytes = 0
133
+ this.defaultCharUnicode = codec.defaultCharUnicode
134
+ }
135
+
136
+ InternalDecoderCesu8.prototype.write = function (buf) {
137
+ var acc = this.acc; var contBytes = this.contBytes; var accBytes = this.accBytes
138
+ var res = ""
139
+ for (var i = 0; i < buf.length; i++) {
140
+ var curByte = buf[i]
141
+ if ((curByte & 0xC0) !== 0x80) { // Leading byte
142
+ if (contBytes > 0) { // Previous code is invalid
143
+ res += this.defaultCharUnicode
144
+ contBytes = 0
145
+ }
146
+
147
+ if (curByte < 0x80) { // Single-byte code
148
+ res += String.fromCharCode(curByte)
149
+ } else if (curByte < 0xE0) { // Two-byte code
150
+ acc = curByte & 0x1F
151
+ contBytes = 1; accBytes = 1
152
+ } else if (curByte < 0xF0) { // Three-byte code
153
+ acc = curByte & 0x0F
154
+ contBytes = 2; accBytes = 1
155
+ } else { // Four or more are not supported for CESU-8.
156
+ res += this.defaultCharUnicode
157
+ }
158
+ } else { // Continuation byte
159
+ if (contBytes > 0) { // We're waiting for it.
160
+ acc = (acc << 6) | (curByte & 0x3f)
161
+ contBytes--; accBytes++
162
+ if (contBytes === 0) {
163
+ // Check for overlong encoding, but support Modified UTF-8 (encoding NULL as C0 80)
164
+ if (accBytes === 2 && acc < 0x80 && acc > 0) {
165
+ res += this.defaultCharUnicode
166
+ } else if (accBytes === 3 && acc < 0x800) {
167
+ res += this.defaultCharUnicode
168
+ } else {
169
+ // Actually add character.
170
+ res += String.fromCharCode(acc)
171
+ }
130
172
  }
173
+ } else { // Unexpected continuation byte
174
+ res += this.defaultCharUnicode
175
+ }
131
176
  }
132
- return buf.slice(0, bufIdx);
177
+ }
178
+ this.acc = acc; this.contBytes = contBytes; this.accBytes = accBytes
179
+ return res
133
180
  }
134
181
 
135
- InternalEncoderCesu8.prototype.end = function() {
182
+ InternalDecoderCesu8.prototype.end = function () {
183
+ var res = 0
184
+ if (this.contBytes > 0) { res += this.defaultCharUnicode }
185
+ return res
136
186
  }
137
187
 
138
- //------------------------------------------------------------------------------
139
- // CESU-8 decoder is not implemented in Node v4.0+
188
+ // ------------------------------------------------------------------------------
189
+ // check the chunk boundaries for surrogate pair
140
190
 
141
- function InternalDecoderCesu8(options, codec) {
142
- this.acc = 0;
143
- this.contBytes = 0;
144
- this.accBytes = 0;
145
- this.defaultCharUnicode = codec.defaultCharUnicode;
146
- }
147
-
148
- InternalDecoderCesu8.prototype.write = function(buf) {
149
- var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes,
150
- res = '';
151
- for (var i = 0; i < buf.length; i++) {
152
- var curByte = buf[i];
153
- if ((curByte & 0xC0) !== 0x80) { // Leading byte
154
- if (contBytes > 0) { // Previous code is invalid
155
- res += this.defaultCharUnicode;
156
- contBytes = 0;
157
- }
158
-
159
- if (curByte < 0x80) { // Single-byte code
160
- res += String.fromCharCode(curByte);
161
- } else if (curByte < 0xE0) { // Two-byte code
162
- acc = curByte & 0x1F;
163
- contBytes = 1; accBytes = 1;
164
- } else if (curByte < 0xF0) { // Three-byte code
165
- acc = curByte & 0x0F;
166
- contBytes = 2; accBytes = 1;
167
- } else { // Four or more are not supported for CESU-8.
168
- res += this.defaultCharUnicode;
169
- }
170
- } else { // Continuation byte
171
- if (contBytes > 0) { // We're waiting for it.
172
- acc = (acc << 6) | (curByte & 0x3f);
173
- contBytes--; accBytes++;
174
- if (contBytes === 0) {
175
- // Check for overlong encoding, but support Modified UTF-8 (encoding NULL as C0 80)
176
- if (accBytes === 2 && acc < 0x80 && acc > 0)
177
- res += this.defaultCharUnicode;
178
- else if (accBytes === 3 && acc < 0x800)
179
- res += this.defaultCharUnicode;
180
- else
181
- // Actually add character.
182
- res += String.fromCharCode(acc);
183
- }
184
- } else { // Unexpected continuation byte
185
- res += this.defaultCharUnicode;
186
- }
187
- }
191
+ function InternalEncoderUtf8 (options, codec) {
192
+ this.highSurrogate = ""
193
+ }
194
+
195
+ InternalEncoderUtf8.prototype.write = function (str) {
196
+ if (this.highSurrogate) {
197
+ str = this.highSurrogate + str
198
+ this.highSurrogate = ""
199
+ }
200
+
201
+ if (str.length > 0) {
202
+ var charCode = str.charCodeAt(str.length - 1)
203
+ if (charCode >= 0xd800 && charCode < 0xdc00) {
204
+ this.highSurrogate = str[str.length - 1]
205
+ str = str.slice(0, str.length - 1)
188
206
  }
189
- this.acc = acc; this.contBytes = contBytes; this.accBytes = accBytes;
190
- return res;
207
+ }
208
+
209
+ return Buffer.from(str, this.enc)
191
210
  }
192
211
 
193
- InternalDecoderCesu8.prototype.end = function() {
194
- var res = 0;
195
- if (this.contBytes > 0)
196
- res += this.defaultCharUnicode;
197
- return res;
212
+ InternalEncoderUtf8.prototype.end = function () {
213
+ if (this.highSurrogate) {
214
+ var str = this.highSurrogate
215
+ this.highSurrogate = ""
216
+ return Buffer.from(str, this.enc)
217
+ }
198
218
  }
@@ -1,72 +1,75 @@
1
- "use strict";
2
- var Buffer = require("safer-buffer").Buffer;
1
+ "use strict"
2
+ var Buffer = require("safer-buffer").Buffer
3
3
 
4
4
  // Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that
5
- // correspond to encoded bytes (if 128 - then lower half is ASCII).
6
-
7
- exports._sbcs = SBCSCodec;
8
- function SBCSCodec(codecOptions, iconv) {
9
- if (!codecOptions)
10
- throw new Error("SBCS codec is called without the data.")
11
-
12
- // Prepare char buffer for decoding.
13
- if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256))
14
- throw new Error("Encoding '"+codecOptions.type+"' has incorrect 'chars' (must be of len 128 or 256)");
15
-
16
- if (codecOptions.chars.length === 128) {
17
- var asciiString = "";
18
- for (var i = 0; i < 128; i++)
19
- asciiString += String.fromCharCode(i);
20
- codecOptions.chars = asciiString + codecOptions.chars;
21
- }
5
+ // correspond to encoded bytes (if 128 - then lower half is ASCII).
22
6
 
23
- this.decodeBuf = Buffer.from(codecOptions.chars, 'ucs2');
24
-
25
- // Encoding buffer.
26
- var encodeBuf = Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));
7
+ exports._sbcs = SBCSCodec
8
+ function SBCSCodec (codecOptions, iconv) {
9
+ if (!codecOptions) {
10
+ throw new Error("SBCS codec is called without the data.")
11
+ }
27
12
 
28
- for (var i = 0; i < codecOptions.chars.length; i++)
29
- encodeBuf[codecOptions.chars.charCodeAt(i)] = i;
13
+ // Prepare char buffer for decoding.
14
+ if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256)) {
15
+ throw new Error("Encoding '" + codecOptions.type + "' has incorrect 'chars' (must be of len 128 or 256)")
16
+ }
30
17
 
31
- this.encodeBuf = encodeBuf;
32
- }
18
+ if (codecOptions.chars.length === 128) {
19
+ var asciiString = ""
20
+ for (var i = 0; i < 128; i++) {
21
+ asciiString += String.fromCharCode(i)
22
+ }
23
+ codecOptions.chars = asciiString + codecOptions.chars
24
+ }
25
+
26
+ this.decodeBuf = Buffer.from(codecOptions.chars, "ucs2")
33
27
 
34
- SBCSCodec.prototype.encoder = SBCSEncoder;
35
- SBCSCodec.prototype.decoder = SBCSDecoder;
28
+ // Encoding buffer.
29
+ var encodeBuf = Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0))
36
30
 
31
+ for (var i = 0; i < codecOptions.chars.length; i++) {
32
+ encodeBuf[codecOptions.chars.charCodeAt(i)] = i
33
+ }
37
34
 
38
- function SBCSEncoder(options, codec) {
39
- this.encodeBuf = codec.encodeBuf;
35
+ this.encodeBuf = encodeBuf
40
36
  }
41
37
 
42
- SBCSEncoder.prototype.write = function(str) {
43
- var buf = Buffer.alloc(str.length);
44
- for (var i = 0; i < str.length; i++)
45
- buf[i] = this.encodeBuf[str.charCodeAt(i)];
46
-
47
- return buf;
38
+ SBCSCodec.prototype.encoder = SBCSEncoder
39
+ SBCSCodec.prototype.decoder = SBCSDecoder
40
+
41
+ function SBCSEncoder (options, codec) {
42
+ this.encodeBuf = codec.encodeBuf
48
43
  }
49
44
 
50
- SBCSEncoder.prototype.end = function() {
45
+ SBCSEncoder.prototype.write = function (str) {
46
+ var buf = Buffer.alloc(str.length)
47
+ for (var i = 0; i < str.length; i++) {
48
+ buf[i] = this.encodeBuf[str.charCodeAt(i)]
49
+ }
50
+
51
+ return buf
51
52
  }
52
53
 
54
+ SBCSEncoder.prototype.end = function () {
55
+ }
53
56
 
54
- function SBCSDecoder(options, codec) {
55
- this.decodeBuf = codec.decodeBuf;
57
+ function SBCSDecoder (options, codec) {
58
+ this.decodeBuf = codec.decodeBuf
56
59
  }
57
60
 
58
- SBCSDecoder.prototype.write = function(buf) {
59
- // Strings are immutable in JS -> we use ucs2 buffer to speed up computations.
60
- var decodeBuf = this.decodeBuf;
61
- var newBuf = Buffer.alloc(buf.length*2);
62
- var idx1 = 0, idx2 = 0;
63
- for (var i = 0; i < buf.length; i++) {
64
- idx1 = buf[i]*2; idx2 = i*2;
65
- newBuf[idx2] = decodeBuf[idx1];
66
- newBuf[idx2+1] = decodeBuf[idx1+1];
67
- }
68
- return newBuf.toString('ucs2');
61
+ SBCSDecoder.prototype.write = function (buf) {
62
+ // Strings are immutable in JS -> we use ucs2 buffer to speed up computations.
63
+ var decodeBuf = this.decodeBuf
64
+ var newBuf = Buffer.alloc(buf.length * 2)
65
+ var idx1 = 0; var idx2 = 0
66
+ for (var i = 0; i < buf.length; i++) {
67
+ idx1 = buf[i] * 2; idx2 = i * 2
68
+ newBuf[idx2] = decodeBuf[idx1]
69
+ newBuf[idx2 + 1] = decodeBuf[idx1 + 1]
70
+ }
71
+ return newBuf.toString("ucs2")
69
72
  }
70
73
 
71
- SBCSDecoder.prototype.end = function() {
74
+ SBCSDecoder.prototype.end = function () {
72
75
  }