@pnpm/exe 11.0.0-beta.0 → 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 (200) 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/cacache/package.json +10 -11
  7. package/dist/node_modules/glob/dist/commonjs/glob.js +2 -1
  8. package/dist/node_modules/glob/dist/commonjs/index.min.js +4 -0
  9. package/dist/node_modules/glob/dist/commonjs/pattern.js +4 -0
  10. package/dist/node_modules/glob/dist/esm/glob.js +2 -1
  11. package/dist/node_modules/glob/dist/esm/index.min.js +4 -0
  12. package/dist/node_modules/glob/dist/esm/pattern.js +4 -0
  13. package/dist/node_modules/glob/package.json +38 -37
  14. package/dist/node_modules/graceful-fs/graceful-fs.js +1 -1
  15. package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +460 -525
  16. package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +179 -182
  17. package/dist/node_modules/iconv-lite/encodings/index.js +15 -15
  18. package/dist/node_modules/iconv-lite/encodings/internal.js +168 -148
  19. package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +55 -52
  20. package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +174 -175
  21. package/dist/node_modules/iconv-lite/encodings/utf16.js +121 -131
  22. package/dist/node_modules/iconv-lite/encodings/utf32.js +226 -238
  23. package/dist/node_modules/iconv-lite/encodings/utf7.js +208 -215
  24. package/dist/node_modules/iconv-lite/lib/bom-handling.js +30 -34
  25. package/dist/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  26. package/dist/node_modules/iconv-lite/lib/index.js +125 -123
  27. package/dist/node_modules/iconv-lite/lib/streams.js +92 -96
  28. package/dist/node_modules/iconv-lite/package.json +34 -8
  29. package/dist/node_modules/isexe/package.json +65 -18
  30. package/dist/node_modules/lru-cache/dist/commonjs/index.js +134 -85
  31. package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  32. package/dist/node_modules/lru-cache/dist/esm/index.js +134 -85
  33. package/dist/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  34. package/dist/node_modules/lru-cache/package.json +18 -41
  35. package/dist/node_modules/make-fetch-happen/lib/remote.js +1 -1
  36. package/dist/node_modules/make-fetch-happen/package.json +10 -10
  37. package/dist/node_modules/minipass-fetch/lib/body.js +25 -15
  38. package/dist/node_modules/minipass-fetch/package.json +7 -7
  39. package/dist/node_modules/minipass-sized/dist/commonjs/index.js +69 -0
  40. package/dist/node_modules/minipass-sized/dist/esm/index.js +64 -0
  41. package/dist/node_modules/minipass-sized/package.json +39 -9
  42. package/dist/node_modules/node-gyp/.release-please-manifest.json +1 -1
  43. package/dist/node_modules/node-gyp/bin/node-gyp.js +7 -0
  44. package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +1 -1
  45. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +3 -3
  46. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +26 -1
  47. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +1 -1
  48. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +3 -4
  49. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +1 -1
  50. package/dist/node_modules/node-gyp/gyp/pyproject.toml +1 -1
  51. package/dist/node_modules/node-gyp/lib/build.js +2 -2
  52. package/dist/node_modules/node-gyp/lib/find-python.js +2 -8
  53. package/dist/node_modules/node-gyp/lib/find-visualstudio.js +11 -5
  54. package/dist/node_modules/node-gyp/lib/install.js +1 -1
  55. package/dist/node_modules/node-gyp/lib/process-release.js +3 -3
  56. package/dist/node_modules/node-gyp/package.json +13 -13
  57. package/dist/node_modules/nopt/package.json +5 -5
  58. package/dist/node_modules/proc-log/lib/index.js +10 -5
  59. package/dist/node_modules/proc-log/package.json +5 -5
  60. package/dist/node_modules/retry/lib/retry.js +2 -2
  61. package/dist/node_modules/retry/lib/retry_operation.js +10 -6
  62. package/dist/node_modules/retry/package.json +6 -2
  63. package/dist/node_modules/ssri/lib/index.js +33 -63
  64. package/dist/node_modules/ssri/package.json +17 -17
  65. package/dist/node_modules/unique-filename/package.json +5 -5
  66. package/dist/node_modules/unique-slug/package.json +4 -4
  67. package/dist/node_modules/which/package.json +29 -20
  68. package/dist/pnpm.mjs +63952 -54674
  69. package/dist/worker.js +601 -2162
  70. package/package.json +8 -8
  71. package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-regex/index.js +0 -16
  72. package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-styles/index.js +0 -170
  73. package/dist/node_modules/@isaacs/cliui/dist/commonjs/eastasianwidth/index.js +0 -307
  74. package/dist/node_modules/@isaacs/cliui/dist/commonjs/emoji-regex/index.js +0 -7
  75. package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.js +0 -322
  76. package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.min.js +0 -12
  77. package/dist/node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js +0 -49
  78. package/dist/node_modules/@isaacs/cliui/dist/commonjs/strip-ansi/index.js +0 -8
  79. package/dist/node_modules/@isaacs/cliui/dist/commonjs/wrap-ansi/index.js +0 -176
  80. package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-regex/index.js +0 -12
  81. package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-styles/index.js +0 -167
  82. package/dist/node_modules/@isaacs/cliui/dist/esm/eastasianwidth/index.js +0 -299
  83. package/dist/node_modules/@isaacs/cliui/dist/esm/emoji-regex/index.js +0 -3
  84. package/dist/node_modules/@isaacs/cliui/dist/esm/index.js +0 -317
  85. package/dist/node_modules/@isaacs/cliui/dist/esm/index.min.js +0 -12
  86. package/dist/node_modules/@isaacs/cliui/dist/esm/string-width/index.js +0 -46
  87. package/dist/node_modules/@isaacs/cliui/dist/esm/strip-ansi/index.js +0 -4
  88. package/dist/node_modules/@isaacs/cliui/dist/esm/wrap-ansi/index.js +0 -172
  89. package/dist/node_modules/@isaacs/cliui/package.json +0 -163
  90. package/dist/node_modules/cross-spawn/LICENSE +0 -21
  91. package/dist/node_modules/cross-spawn/index.js +0 -39
  92. package/dist/node_modules/cross-spawn/lib/enoent.js +0 -59
  93. package/dist/node_modules/cross-spawn/lib/parse.js +0 -91
  94. package/dist/node_modules/cross-spawn/lib/util/escape.js +0 -47
  95. package/dist/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
  96. package/dist/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
  97. package/dist/node_modules/cross-spawn/package.json +0 -73
  98. package/dist/node_modules/encoding/.prettierrc.js +0 -8
  99. package/dist/node_modules/encoding/LICENSE +0 -16
  100. package/dist/node_modules/encoding/lib/encoding.js +0 -83
  101. package/dist/node_modules/encoding/package.json +0 -18
  102. package/dist/node_modules/err-code/.eslintrc.json +0 -7
  103. package/dist/node_modules/err-code/bower.json +0 -30
  104. package/dist/node_modules/err-code/index.js +0 -47
  105. package/dist/node_modules/err-code/index.umd.js +0 -51
  106. package/dist/node_modules/err-code/package.json +0 -34
  107. package/dist/node_modules/foreground-child/LICENSE +0 -15
  108. package/dist/node_modules/foreground-child/dist/commonjs/all-signals.js +0 -58
  109. package/dist/node_modules/foreground-child/dist/commonjs/index.js +0 -123
  110. package/dist/node_modules/foreground-child/dist/commonjs/proxy-signals.js +0 -38
  111. package/dist/node_modules/foreground-child/dist/commonjs/watchdog.js +0 -50
  112. package/dist/node_modules/foreground-child/dist/esm/all-signals.js +0 -52
  113. package/dist/node_modules/foreground-child/dist/esm/index.js +0 -115
  114. package/dist/node_modules/foreground-child/dist/esm/proxy-signals.js +0 -34
  115. package/dist/node_modules/foreground-child/dist/esm/watchdog.js +0 -46
  116. package/dist/node_modules/foreground-child/package.json +0 -106
  117. package/dist/node_modules/glob/dist/esm/bin.d.mts +0 -3
  118. package/dist/node_modules/glob/dist/esm/bin.mjs +0 -346
  119. package/dist/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  120. package/dist/node_modules/iconv-lite/.idea/codeStyles/Project.xml +0 -47
  121. package/dist/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +0 -5
  122. package/dist/node_modules/iconv-lite/.idea/iconv-lite.iml +0 -12
  123. package/dist/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +0 -6
  124. package/dist/node_modules/iconv-lite/.idea/modules.xml +0 -8
  125. package/dist/node_modules/iconv-lite/.idea/vcs.xml +0 -6
  126. package/dist/node_modules/isexe/LICENSE +0 -15
  127. package/dist/node_modules/isexe/index.js +0 -57
  128. package/dist/node_modules/isexe/mode.js +0 -41
  129. package/dist/node_modules/isexe/windows.js +0 -42
  130. package/dist/node_modules/jackspeak/dist/commonjs/index.js +0 -944
  131. package/dist/node_modules/jackspeak/dist/commonjs/index.min.js +0 -33
  132. package/dist/node_modules/jackspeak/dist/commonjs/package.json +0 -3
  133. package/dist/node_modules/jackspeak/dist/esm/index.js +0 -936
  134. package/dist/node_modules/jackspeak/dist/esm/index.min.js +0 -33
  135. package/dist/node_modules/jackspeak/dist/esm/package.json +0 -3
  136. package/dist/node_modules/jackspeak/package.json +0 -115
  137. package/dist/node_modules/lru-cache/LICENSE +0 -15
  138. package/dist/node_modules/minipass-sized/index.js +0 -67
  139. package/dist/node_modules/minipass-sized/node_modules/minipass/LICENSE +0 -15
  140. package/dist/node_modules/minipass-sized/node_modules/minipass/index.js +0 -649
  141. package/dist/node_modules/minipass-sized/node_modules/minipass/package.json +0 -56
  142. package/dist/node_modules/minipass-sized/package-lock.json +0 -3464
  143. package/dist/node_modules/node-gyp/node_modules/isexe/dist/commonjs/package.json +0 -3
  144. package/dist/node_modules/node-gyp/node_modules/isexe/dist/esm/package.json +0 -3
  145. package/dist/node_modules/node-gyp/node_modules/isexe/package.json +0 -78
  146. package/dist/node_modules/node-gyp/node_modules/which/LICENSE +0 -15
  147. package/dist/node_modules/node-gyp/node_modules/which/package.json +0 -52
  148. package/dist/node_modules/package-json-from-dist/dist/commonjs/index.js +0 -134
  149. package/dist/node_modules/package-json-from-dist/dist/commonjs/package.json +0 -3
  150. package/dist/node_modules/package-json-from-dist/dist/esm/index.js +0 -129
  151. package/dist/node_modules/package-json-from-dist/dist/esm/package.json +0 -3
  152. package/dist/node_modules/package-json-from-dist/package.json +0 -68
  153. package/dist/node_modules/path-key/index.js +0 -16
  154. package/dist/node_modules/path-key/license +0 -9
  155. package/dist/node_modules/path-key/package.json +0 -39
  156. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +0 -1589
  157. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +0 -2
  158. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +0 -3
  159. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +0 -1585
  160. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +0 -2
  161. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +0 -3
  162. package/dist/node_modules/path-scurry/node_modules/lru-cache/package.json +0 -101
  163. package/dist/node_modules/promise-retry/index.js +0 -52
  164. package/dist/node_modules/promise-retry/package.json +0 -37
  165. package/dist/node_modules/retry/equation.gif +0 -0
  166. package/dist/node_modules/shebang-command/index.js +0 -19
  167. package/dist/node_modules/shebang-command/license +0 -9
  168. package/dist/node_modules/shebang-command/package.json +0 -34
  169. package/dist/node_modules/shebang-regex/index.js +0 -2
  170. package/dist/node_modules/shebang-regex/license +0 -9
  171. package/dist/node_modules/shebang-regex/package.json +0 -35
  172. package/dist/node_modules/signal-exit/LICENSE.txt +0 -16
  173. package/dist/node_modules/signal-exit/dist/cjs/browser.js +0 -10
  174. package/dist/node_modules/signal-exit/dist/cjs/index.js +0 -279
  175. package/dist/node_modules/signal-exit/dist/cjs/package.json +0 -3
  176. package/dist/node_modules/signal-exit/dist/cjs/signals.js +0 -42
  177. package/dist/node_modules/signal-exit/dist/mjs/browser.js +0 -4
  178. package/dist/node_modules/signal-exit/dist/mjs/index.js +0 -275
  179. package/dist/node_modules/signal-exit/dist/mjs/package.json +0 -3
  180. package/dist/node_modules/signal-exit/dist/mjs/signals.js +0 -39
  181. package/dist/node_modules/signal-exit/package.json +0 -106
  182. package/dist/node_modules/which/bin/node-which +0 -52
  183. package/dist/node_modules/which/which.js +0 -125
  184. /package/dist/node_modules/{promise-retry → @gar/promise-retry}/LICENSE +0 -0
  185. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.js +0 -0
  186. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.min.js +0 -0
  187. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/options.js +0 -0
  188. /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/commonjs/package.json +0 -0
  189. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/posix.js +0 -0
  190. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/win32.js +0 -0
  191. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.js +0 -0
  192. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.min.js +0 -0
  193. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/options.js +0 -0
  194. /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/esm/package.json +0 -0
  195. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/posix.js +0 -0
  196. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/win32.js +0 -0
  197. /package/dist/node_modules/{foreground-child → minipass-sized}/dist/commonjs/package.json +0 -0
  198. /package/dist/node_modules/{foreground-child → minipass-sized}/dist/esm/package.json +0 -0
  199. /package/dist/node_modules/{node-gyp/node_modules/which → which}/bin/which.js +0 -0
  200. /package/dist/node_modules/{node-gyp/node_modules/which → which}/lib/index.js +0 -0
@@ -1,70 +1,66 @@
1
- "use strict";
2
- var Buffer = require("safer-buffer").Buffer;
1
+ "use strict"
2
+ var Buffer = require("safer-buffer").Buffer
3
3
 
4
4
  // Note: UTF16-LE (or UCS2) codec is Node.js native. See encodings/internal.js
5
5
 
6
6
  // == UTF16-BE codec. ==========================================================
7
7
 
8
- exports.utf16be = Utf16BECodec;
9
- function Utf16BECodec() {
8
+ exports.utf16be = Utf16BECodec
9
+ function Utf16BECodec () {
10
10
  }
11
11
 
12
- Utf16BECodec.prototype.encoder = Utf16BEEncoder;
13
- Utf16BECodec.prototype.decoder = Utf16BEDecoder;
14
- Utf16BECodec.prototype.bomAware = true;
15
-
12
+ Utf16BECodec.prototype.encoder = Utf16BEEncoder
13
+ Utf16BECodec.prototype.decoder = Utf16BEDecoder
14
+ Utf16BECodec.prototype.bomAware = true
16
15
 
17
16
  // -- Encoding
18
17
 
19
- function Utf16BEEncoder() {
18
+ function Utf16BEEncoder () {
20
19
  }
21
20
 
22
- Utf16BEEncoder.prototype.write = function(str) {
23
- var buf = Buffer.from(str, 'ucs2');
24
- for (var i = 0; i < buf.length; i += 2) {
25
- var tmp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = tmp;
26
- }
27
- return buf;
21
+ Utf16BEEncoder.prototype.write = function (str) {
22
+ var buf = Buffer.from(str, "ucs2")
23
+ for (var i = 0; i < buf.length; i += 2) {
24
+ var tmp = buf[i]; buf[i] = buf[i + 1]; buf[i + 1] = tmp
25
+ }
26
+ return buf
28
27
  }
29
28
 
30
- Utf16BEEncoder.prototype.end = function() {
29
+ Utf16BEEncoder.prototype.end = function () {
31
30
  }
32
31
 
33
-
34
32
  // -- Decoding
35
33
 
36
- function Utf16BEDecoder() {
37
- this.overflowByte = -1;
34
+ function Utf16BEDecoder () {
35
+ this.overflowByte = -1
38
36
  }
39
37
 
40
- Utf16BEDecoder.prototype.write = function(buf) {
41
- if (buf.length == 0)
42
- return '';
38
+ Utf16BEDecoder.prototype.write = function (buf) {
39
+ if (buf.length == 0) { return "" }
43
40
 
44
- var buf2 = Buffer.alloc(buf.length + 1),
45
- i = 0, j = 0;
41
+ var buf2 = Buffer.alloc(buf.length + 1)
42
+ var i = 0; var j = 0
46
43
 
47
- if (this.overflowByte !== -1) {
48
- buf2[0] = buf[0];
49
- buf2[1] = this.overflowByte;
50
- i = 1; j = 2;
51
- }
44
+ if (this.overflowByte !== -1) {
45
+ buf2[0] = buf[0]
46
+ buf2[1] = this.overflowByte
47
+ i = 1; j = 2
48
+ }
52
49
 
53
- for (; i < buf.length-1; i += 2, j+= 2) {
54
- buf2[j] = buf[i+1];
55
- buf2[j+1] = buf[i];
56
- }
50
+ for (; i < buf.length - 1; i += 2, j += 2) {
51
+ buf2[j] = buf[i + 1]
52
+ buf2[j + 1] = buf[i]
53
+ }
57
54
 
58
- this.overflowByte = (i == buf.length-1) ? buf[buf.length-1] : -1;
55
+ this.overflowByte = (i == buf.length - 1) ? buf[buf.length - 1] : -1
59
56
 
60
- return buf2.slice(0, j).toString('ucs2');
57
+ return buf2.slice(0, j).toString("ucs2")
61
58
  }
62
59
 
63
- Utf16BEDecoder.prototype.end = function() {
64
- this.overflowByte = -1;
60
+ Utf16BEDecoder.prototype.end = function () {
61
+ this.overflowByte = -1
65
62
  }
66
63
 
67
-
68
64
  // == UTF-16 codec =============================================================
69
65
  // Decoder chooses automatically from UTF-16LE and UTF-16BE using BOM and space-based heuristic.
70
66
  // Defaults to UTF-16LE, as it's prevalent and default in Node.
@@ -73,125 +69,119 @@ Utf16BEDecoder.prototype.end = function() {
73
69
 
74
70
  // Encoder uses UTF-16LE and prepends BOM (which can be overridden with addBOM: false).
75
71
 
76
- exports.utf16 = Utf16Codec;
77
- function Utf16Codec(codecOptions, iconv) {
78
- this.iconv = iconv;
72
+ exports.utf16 = Utf16Codec
73
+ function Utf16Codec (codecOptions, iconv) {
74
+ this.iconv = iconv
79
75
  }
80
76
 
81
- Utf16Codec.prototype.encoder = Utf16Encoder;
82
- Utf16Codec.prototype.decoder = Utf16Decoder;
83
-
77
+ Utf16Codec.prototype.encoder = Utf16Encoder
78
+ Utf16Codec.prototype.decoder = Utf16Decoder
84
79
 
85
80
  // -- Encoding (pass-through)
86
81
 
87
- function Utf16Encoder(options, codec) {
88
- options = options || {};
89
- if (options.addBOM === undefined)
90
- options.addBOM = true;
91
- this.encoder = codec.iconv.getEncoder('utf-16le', options);
82
+ function Utf16Encoder (options, codec) {
83
+ options = options || {}
84
+ if (options.addBOM === undefined) { options.addBOM = true }
85
+ this.encoder = codec.iconv.getEncoder("utf-16le", options)
92
86
  }
93
87
 
94
- Utf16Encoder.prototype.write = function(str) {
95
- return this.encoder.write(str);
88
+ Utf16Encoder.prototype.write = function (str) {
89
+ return this.encoder.write(str)
96
90
  }
97
91
 
98
- Utf16Encoder.prototype.end = function() {
99
- return this.encoder.end();
92
+ Utf16Encoder.prototype.end = function () {
93
+ return this.encoder.end()
100
94
  }
101
95
 
102
-
103
96
  // -- Decoding
104
97
 
105
- function Utf16Decoder(options, codec) {
106
- this.decoder = null;
107
- this.initialBufs = [];
108
- this.initialBufsLen = 0;
98
+ function Utf16Decoder (options, codec) {
99
+ this.decoder = null
100
+ this.initialBufs = []
101
+ this.initialBufsLen = 0
109
102
 
110
- this.options = options || {};
111
- this.iconv = codec.iconv;
103
+ this.options = options || {}
104
+ this.iconv = codec.iconv
112
105
  }
113
106
 
114
- Utf16Decoder.prototype.write = function(buf) {
115
- if (!this.decoder) {
116
- // Codec is not chosen yet. Accumulate initial bytes.
117
- this.initialBufs.push(buf);
118
- this.initialBufsLen += buf.length;
119
-
120
- if (this.initialBufsLen < 16) // We need more bytes to use space heuristic (see below)
121
- return '';
122
-
123
- // We have enough bytes -> detect endianness.
124
- var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
125
- this.decoder = this.iconv.getDecoder(encoding, this.options);
126
-
127
- var resStr = '';
128
- for (var i = 0; i < this.initialBufs.length; i++)
129
- resStr += this.decoder.write(this.initialBufs[i]);
130
-
131
- this.initialBufs.length = this.initialBufsLen = 0;
132
- return resStr;
133
- }
107
+ Utf16Decoder.prototype.write = function (buf) {
108
+ if (!this.decoder) {
109
+ // Codec is not chosen yet. Accumulate initial bytes.
110
+ this.initialBufs.push(buf)
111
+ this.initialBufsLen += buf.length
112
+
113
+ if (this.initialBufsLen < 16) // We need more bytes to use space heuristic (see below)
114
+ { return "" }
134
115
 
135
- return this.decoder.write(buf);
116
+ // We have enough bytes -> detect endianness.
117
+ var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding)
118
+ this.decoder = this.iconv.getDecoder(encoding, this.options)
119
+
120
+ var resStr = ""
121
+ for (var i = 0; i < this.initialBufs.length; i++) { resStr += this.decoder.write(this.initialBufs[i]) }
122
+
123
+ this.initialBufs.length = this.initialBufsLen = 0
124
+ return resStr
125
+ }
126
+
127
+ return this.decoder.write(buf)
136
128
  }
137
129
 
138
- Utf16Decoder.prototype.end = function() {
139
- if (!this.decoder) {
140
- var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
141
- this.decoder = this.iconv.getDecoder(encoding, this.options);
130
+ Utf16Decoder.prototype.end = function () {
131
+ if (!this.decoder) {
132
+ var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding)
133
+ this.decoder = this.iconv.getDecoder(encoding, this.options)
142
134
 
143
- var resStr = '';
144
- for (var i = 0; i < this.initialBufs.length; i++)
145
- resStr += this.decoder.write(this.initialBufs[i]);
135
+ var resStr = ""
136
+ for (var i = 0; i < this.initialBufs.length; i++) { resStr += this.decoder.write(this.initialBufs[i]) }
146
137
 
147
- var trail = this.decoder.end();
148
- if (trail)
149
- resStr += trail;
138
+ var trail = this.decoder.end()
139
+ if (trail) { resStr += trail }
150
140
 
151
- this.initialBufs.length = this.initialBufsLen = 0;
152
- return resStr;
153
- }
154
- return this.decoder.end();
141
+ this.initialBufs.length = this.initialBufsLen = 0
142
+ return resStr
143
+ }
144
+ return this.decoder.end()
155
145
  }
156
146
 
157
- function detectEncoding(bufs, defaultEncoding) {
158
- var b = [];
159
- var charsProcessed = 0;
160
- var asciiCharsLE = 0, asciiCharsBE = 0; // Number of ASCII chars when decoded as LE or BE.
161
-
162
- outer_loop:
163
- for (var i = 0; i < bufs.length; i++) {
164
- var buf = bufs[i];
165
- for (var j = 0; j < buf.length; j++) {
166
- b.push(buf[j]);
167
- if (b.length === 2) {
168
- if (charsProcessed === 0) {
169
- // Check BOM first.
170
- if (b[0] === 0xFF && b[1] === 0xFE) return 'utf-16le';
171
- if (b[0] === 0xFE && b[1] === 0xFF) return 'utf-16be';
172
- }
173
-
174
- if (b[0] === 0 && b[1] !== 0) asciiCharsBE++;
175
- if (b[0] !== 0 && b[1] === 0) asciiCharsLE++;
176
-
177
- b.length = 0;
178
- charsProcessed++;
179
-
180
- if (charsProcessed >= 100) {
181
- break outer_loop;
182
- }
183
- }
147
+ function detectEncoding (bufs, defaultEncoding) {
148
+ var b = []
149
+ var charsProcessed = 0
150
+ // Number of ASCII chars when decoded as LE or BE.
151
+ var asciiCharsLE = 0
152
+ var asciiCharsBE = 0
153
+
154
+ outerLoop:
155
+ for (var i = 0; i < bufs.length; i++) {
156
+ var buf = bufs[i]
157
+ for (var j = 0; j < buf.length; j++) {
158
+ b.push(buf[j])
159
+ if (b.length === 2) {
160
+ if (charsProcessed === 0) {
161
+ // Check BOM first.
162
+ if (b[0] === 0xFF && b[1] === 0xFE) return "utf-16le"
163
+ if (b[0] === 0xFE && b[1] === 0xFF) return "utf-16be"
184
164
  }
185
- }
186
165
 
187
- // Make decisions.
188
- // Most of the time, the content has ASCII chars (U+00**), but the opposite (U+**00) is uncommon.
189
- // So, we count ASCII as if it was LE or BE, and decide from that.
190
- if (asciiCharsBE > asciiCharsLE) return 'utf-16be';
191
- if (asciiCharsBE < asciiCharsLE) return 'utf-16le';
166
+ if (b[0] === 0 && b[1] !== 0) asciiCharsBE++
167
+ if (b[0] !== 0 && b[1] === 0) asciiCharsLE++
192
168
 
193
- // Couldn't decide (likely all zeros or not enough data).
194
- return defaultEncoding || 'utf-16le';
195
- }
169
+ b.length = 0
170
+ charsProcessed++
196
171
 
172
+ if (charsProcessed >= 100) {
173
+ break outerLoop
174
+ }
175
+ }
176
+ }
177
+ }
197
178
 
179
+ // Make decisions.
180
+ // Most of the time, the content has ASCII chars (U+00**), but the opposite (U+**00) is uncommon.
181
+ // So, we count ASCII as if it was LE or BE, and decide from that.
182
+ if (asciiCharsBE > asciiCharsLE) return "utf-16be"
183
+ if (asciiCharsBE < asciiCharsLE) return "utf-16le"
184
+
185
+ // Couldn't decide (likely all zeros or not enough data).
186
+ return defaultEncoding || "utf-16le"
187
+ }