fsevents 1.2.3 → 1.2.10

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.

Potentially problematic release.


This version of fsevents might be problematic. Click here for more details.

Files changed (208) hide show
  1. package/.travis.yml +2 -3
  2. package/fsevents.cc +14 -26
  3. package/node_modules/abbrev/package.json +13 -14
  4. package/node_modules/ansi-regex/package.json +13 -14
  5. package/node_modules/aproba/package.json +13 -14
  6. package/node_modules/are-we-there-yet/CHANGES.md +6 -0
  7. package/node_modules/are-we-there-yet/package.json +19 -20
  8. package/node_modules/are-we-there-yet/tracker-stream.js +1 -0
  9. package/node_modules/balanced-match/package.json +13 -14
  10. package/node_modules/brace-expansion/package.json +13 -14
  11. package/node_modules/chownr/chownr.js +113 -40
  12. package/node_modules/chownr/package.json +22 -20
  13. package/node_modules/code-point-at/package.json +13 -14
  14. package/node_modules/concat-map/package.json +8 -9
  15. package/node_modules/console-control-strings/package.json +14 -14
  16. package/node_modules/core-util-is/package.json +13 -14
  17. package/node_modules/debug/CHANGELOG.md +34 -1
  18. package/node_modules/debug/README.md +188 -63
  19. package/node_modules/debug/dist/debug.js +886 -0
  20. package/node_modules/debug/package.json +34 -33
  21. package/node_modules/debug/src/browser.js +77 -82
  22. package/node_modules/debug/src/common.js +249 -0
  23. package/node_modules/debug/src/index.js +5 -3
  24. package/node_modules/debug/src/node.js +72 -146
  25. package/node_modules/deep-extend/CHANGELOG.md +28 -3
  26. package/node_modules/deep-extend/LICENSE +1 -1
  27. package/node_modules/deep-extend/README.md +2 -1
  28. package/node_modules/deep-extend/lib/deep-extend.js +11 -5
  29. package/node_modules/deep-extend/package.json +26 -28
  30. package/node_modules/delegates/package.json +13 -14
  31. package/node_modules/detect-libc/package.json +13 -14
  32. package/node_modules/fs-minipass/index.js +2 -1
  33. package/node_modules/fs-minipass/package.json +24 -22
  34. package/node_modules/fs.realpath/package.json +13 -14
  35. package/node_modules/gauge/package.json +13 -14
  36. package/node_modules/glob/LICENSE +6 -0
  37. package/node_modules/glob/README.md +8 -1
  38. package/node_modules/glob/package.json +21 -19
  39. package/node_modules/has-unicode/package.json +13 -14
  40. package/node_modules/iconv-lite/Changelog.md +16 -0
  41. package/node_modules/iconv-lite/encodings/sbcs-codec.js +2 -2
  42. package/node_modules/iconv-lite/encodings/sbcs-data.js +5 -0
  43. package/node_modules/iconv-lite/lib/extend-node.js +1 -1
  44. package/node_modules/iconv-lite/lib/index.d.ts +2 -2
  45. package/node_modules/iconv-lite/package.json +19 -20
  46. package/node_modules/ignore-walk/README.md +1 -1
  47. package/node_modules/ignore-walk/index.js +9 -5
  48. package/node_modules/ignore-walk/package.json +22 -20
  49. package/node_modules/inflight/package.json +13 -14
  50. package/node_modules/inherits/inherits.js +2 -0
  51. package/node_modules/inherits/inherits_browser.js +18 -14
  52. package/node_modules/inherits/package.json +20 -20
  53. package/node_modules/ini/package.json +13 -14
  54. package/node_modules/is-fullwidth-code-point/package.json +13 -14
  55. package/node_modules/isarray/package.json +13 -14
  56. package/node_modules/minimatch/package.json +14 -14
  57. package/node_modules/minimist/package.json +8 -9
  58. package/node_modules/minipass/LICENSE +15 -0
  59. package/node_modules/minipass/README.md +567 -7
  60. package/node_modules/minipass/index.js +255 -22
  61. package/node_modules/minipass/package.json +26 -22
  62. package/node_modules/minizlib/README.md +36 -27
  63. package/node_modules/minizlib/constants.js +73 -4
  64. package/node_modules/minizlib/index.js +188 -232
  65. package/node_modules/minizlib/package.json +19 -20
  66. package/node_modules/mkdirp/package.json +14 -14
  67. package/node_modules/ms/index.js +29 -19
  68. package/node_modules/ms/package.json +22 -23
  69. package/node_modules/ms/readme.md +18 -9
  70. package/node_modules/needle/README.md +3 -3
  71. package/node_modules/needle/examples/multipart-stream.js +1 -1
  72. package/node_modules/needle/lib/auth.js +1 -1
  73. package/node_modules/needle/lib/cookies.js +12 -10
  74. package/node_modules/needle/lib/multipart.js +1 -1
  75. package/node_modules/needle/lib/needle.js +20 -6
  76. package/node_modules/needle/package.json +26 -27
  77. package/node_modules/needle/test/basic_auth_spec.js +1 -1
  78. package/node_modules/needle/test/cookies_spec.js +2 -2
  79. package/node_modules/needle/test/errors_spec.js +4 -4
  80. package/node_modules/needle/test/headers_spec.js +1 -1
  81. package/node_modules/needle/test/long_string_spec.js +1 -1
  82. package/node_modules/needle/test/output_spec.js +1 -1
  83. package/node_modules/needle/test/post_data_spec.js +20 -20
  84. package/node_modules/needle/test/proxy_spec.js +1 -1
  85. package/node_modules/needle/test/url_spec.js +11 -3
  86. package/node_modules/needle/test/utils/test.js +1 -1
  87. package/node_modules/node-pre-gyp/CHANGELOG.md +34 -3
  88. package/node_modules/node-pre-gyp/README.md +53 -21
  89. package/node_modules/node-pre-gyp/appveyor.yml +2 -9
  90. package/node_modules/node-pre-gyp/contributing.md +2 -2
  91. package/node_modules/node-pre-gyp/lib/build.js +1 -1
  92. package/node_modules/node-pre-gyp/lib/install.js +46 -12
  93. package/node_modules/node-pre-gyp/lib/node-pre-gyp.js +1 -1
  94. package/node_modules/node-pre-gyp/lib/package.js +5 -2
  95. package/node_modules/node-pre-gyp/lib/pre-binding.js +5 -5
  96. package/node_modules/node-pre-gyp/lib/rebuild.js +1 -1
  97. package/node_modules/node-pre-gyp/lib/reinstall.js +1 -1
  98. package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +148 -0
  99. package/node_modules/node-pre-gyp/lib/util/handle_gyp_opts.js +5 -2
  100. package/node_modules/node-pre-gyp/lib/util/napi.js +70 -22
  101. package/node_modules/node-pre-gyp/lib/util/versioning.js +7 -6
  102. package/node_modules/node-pre-gyp/package.json +16 -20
  103. package/node_modules/nopt/package.json +13 -14
  104. package/node_modules/npm-bundled/LICENSE +15 -0
  105. package/node_modules/npm-bundled/README.md +2 -0
  106. package/node_modules/npm-bundled/index.js +29 -7
  107. package/node_modules/npm-bundled/package.json +21 -19
  108. package/node_modules/npm-normalize-package-bin/.github/settings.yml +2 -0
  109. package/node_modules/npm-normalize-package-bin/.npmignore +24 -0
  110. package/node_modules/npm-normalize-package-bin/LICENSE +15 -0
  111. package/node_modules/npm-normalize-package-bin/README.md +14 -0
  112. package/node_modules/npm-normalize-package-bin/index.js +60 -0
  113. package/node_modules/npm-normalize-package-bin/package-lock.json +3529 -0
  114. package/node_modules/npm-normalize-package-bin/package.json +57 -0
  115. package/node_modules/npm-normalize-package-bin/test/array.js +37 -0
  116. package/node_modules/npm-normalize-package-bin/test/nobin.js +35 -0
  117. package/node_modules/npm-normalize-package-bin/test/object.js +141 -0
  118. package/node_modules/npm-normalize-package-bin/test/string.js +37 -0
  119. package/node_modules/npm-packlist/index.js +90 -21
  120. package/node_modules/npm-packlist/package.json +27 -21
  121. package/node_modules/npmlog/package.json +13 -14
  122. package/node_modules/number-is-nan/package.json +13 -14
  123. package/node_modules/object-assign/package.json +13 -14
  124. package/node_modules/once/package.json +14 -14
  125. package/node_modules/os-homedir/package.json +13 -14
  126. package/node_modules/os-tmpdir/package.json +13 -14
  127. package/node_modules/osenv/package.json +13 -14
  128. package/node_modules/path-is-absolute/package.json +13 -14
  129. package/node_modules/process-nextick-args/index.js +2 -1
  130. package/node_modules/process-nextick-args/package.json +17 -18
  131. package/node_modules/rc/node_modules/minimist/package.json +13 -14
  132. package/node_modules/rc/package.json +18 -19
  133. package/node_modules/readable-stream/package.json +13 -14
  134. package/node_modules/rimraf/package.json +22 -20
  135. package/node_modules/rimraf/rimraf.js +9 -1
  136. package/node_modules/safe-buffer/index.d.ts +187 -0
  137. package/node_modules/safe-buffer/package.json +23 -21
  138. package/node_modules/safer-buffer/package.json +13 -14
  139. package/node_modules/sax/package.json +13 -14
  140. package/node_modules/semver/CHANGELOG.md +39 -0
  141. package/node_modules/semver/README.md +43 -19
  142. package/node_modules/semver/bin/semver +92 -75
  143. package/node_modules/semver/package.json +25 -20
  144. package/node_modules/semver/semver.js +922 -763
  145. package/node_modules/set-blocking/package.json +13 -14
  146. package/node_modules/signal-exit/package.json +13 -14
  147. package/node_modules/string-width/package.json +14 -14
  148. package/node_modules/string_decoder/package.json +13 -14
  149. package/node_modules/strip-ansi/package.json +14 -14
  150. package/node_modules/strip-json-comments/package.json +13 -14
  151. package/node_modules/tar/README.md +7 -2
  152. package/node_modules/tar/lib/header.js +20 -4
  153. package/node_modules/tar/lib/large-numbers.js +32 -27
  154. package/node_modules/tar/lib/mkdir.js +2 -2
  155. package/node_modules/tar/lib/mode-fix.js +14 -0
  156. package/node_modules/tar/lib/pack.js +1 -0
  157. package/node_modules/tar/lib/parse.js +7 -1
  158. package/node_modules/tar/lib/read-entry.js +4 -0
  159. package/node_modules/tar/lib/unpack.js +67 -6
  160. package/node_modules/tar/lib/write-entry.js +25 -6
  161. package/node_modules/tar/package.json +33 -30
  162. package/node_modules/util-deprecate/package.json +13 -14
  163. package/node_modules/wide-align/package.json +19 -20
  164. package/node_modules/wrappy/package.json +14 -14
  165. package/node_modules/yallist/iterator.js +5 -5
  166. package/node_modules/yallist/package.json +19 -19
  167. package/node_modules/yallist/yallist.js +52 -2
  168. package/package.json +6 -9
  169. package/src/async.cc +2 -2
  170. package/src/constants.cc +20 -20
  171. package/src/thread.cc +5 -6
  172. package/.npmignore +0 -1
  173. package/build/.target.mk +0 -53
  174. package/build/Makefile +0 -352
  175. package/build/Release/.deps/Release/.node.d +0 -1
  176. package/build/Release/.deps/Release/fse.node.d +0 -1
  177. package/build/Release/.deps/Release/obj.target/action_after_build.stamp.d +0 -1
  178. package/build/Release/.deps/Release/obj.target/fse/fsevents.o.d +0 -65
  179. package/build/Release/.deps/Users/eshanker/Code/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node.d +0 -1
  180. package/build/Release/.node +0 -0
  181. package/build/Release/fse.node +0 -0
  182. package/build/Release/obj.target/action_after_build.stamp +0 -0
  183. package/build/Release/obj.target/fse/fsevents.o +0 -0
  184. package/build/action_after_build.target.mk +0 -32
  185. package/build/binding.Makefile +0 -6
  186. package/build/fse.target.mk +0 -179
  187. package/build/gyp-mac-tool +0 -611
  188. package/build/stage/v1.1.2/fse-v1.1.2-node-v48-darwin-x64.tar.gz +0 -0
  189. package/lib/binding/Release/node-v11-darwin-x64/fse.node +0 -0
  190. package/lib/binding/Release/node-v46-darwin-x64/fse.node +0 -0
  191. package/lib/binding/Release/node-v47-darwin-x64/fse.node +0 -0
  192. package/lib/binding/Release/node-v48-darwin-x64/fse.node +0 -0
  193. package/lib/binding/Release/node-v57-darwin-x64/fse.node +0 -0
  194. package/node_modules/are-we-there-yet/CHANGES.md~ +0 -27
  195. package/node_modules/debug/.coveralls.yml +0 -1
  196. package/node_modules/debug/.eslintrc +0 -11
  197. package/node_modules/debug/.npmignore +0 -9
  198. package/node_modules/debug/.travis.yml +0 -14
  199. package/node_modules/debug/Makefile +0 -50
  200. package/node_modules/debug/component.json +0 -19
  201. package/node_modules/debug/karma.conf.js +0 -70
  202. package/node_modules/debug/src/debug.js +0 -202
  203. package/node_modules/debug/src/inspector-log.js +0 -15
  204. package/node_modules/iconv-lite/.travis.yml +0 -23
  205. package/node_modules/rc/.npmignore +0 -3
  206. package/node_modules/safe-buffer/.travis.yml +0 -7
  207. package/node_modules/safe-buffer/test.js +0 -101
  208. package/src/locking.cc +0 -27
@@ -2,16 +2,24 @@
2
2
 
3
3
  const assert = require('assert')
4
4
  const Buffer = require('buffer').Buffer
5
- const binding = process.binding('zlib')
5
+ const realZlib = require('zlib')
6
6
 
7
7
  const constants = exports.constants = require('./constants.js')
8
- const MiniPass = require('minipass')
8
+ const Minipass = require('minipass')
9
+
10
+ const OriginalBufferConcat = Buffer.concat
9
11
 
10
12
  class ZlibError extends Error {
11
- constructor (msg, errno) {
12
- super('zlib: ' + msg)
13
- this.errno = errno
14
- this.code = codes.get(errno)
13
+ constructor (err) {
14
+ super('zlib: ' + err.message)
15
+ this.code = err.code
16
+ this.errno = err.errno
17
+ /* istanbul ignore if */
18
+ if (!this.code)
19
+ this.code = 'ZLIB_ERROR'
20
+
21
+ this.message = 'zlib: ' + err.message
22
+ Error.captureStackTrace(this, this.constructor)
15
23
  }
16
24
 
17
25
  get name () {
@@ -19,153 +27,51 @@ class ZlibError extends Error {
19
27
  }
20
28
  }
21
29
 
22
- // translation table for return codes.
23
- const codes = new Map([
24
- [constants.Z_OK, 'Z_OK'],
25
- [constants.Z_STREAM_END, 'Z_STREAM_END'],
26
- [constants.Z_NEED_DICT, 'Z_NEED_DICT'],
27
- [constants.Z_ERRNO, 'Z_ERRNO'],
28
- [constants.Z_STREAM_ERROR, 'Z_STREAM_ERROR'],
29
- [constants.Z_DATA_ERROR, 'Z_DATA_ERROR'],
30
- [constants.Z_MEM_ERROR, 'Z_MEM_ERROR'],
31
- [constants.Z_BUF_ERROR, 'Z_BUF_ERROR'],
32
- [constants.Z_VERSION_ERROR, 'Z_VERSION_ERROR']
33
- ])
34
-
35
- const validFlushFlags = new Set([
36
- constants.Z_NO_FLUSH,
37
- constants.Z_PARTIAL_FLUSH,
38
- constants.Z_SYNC_FLUSH,
39
- constants.Z_FULL_FLUSH,
40
- constants.Z_FINISH,
41
- constants.Z_BLOCK
42
- ])
43
-
44
- const strategies = new Set([
45
- constants.Z_FILTERED,
46
- constants.Z_HUFFMAN_ONLY,
47
- constants.Z_RLE,
48
- constants.Z_FIXED,
49
- constants.Z_DEFAULT_STRATEGY
50
- ])
51
-
52
30
  // the Zlib class they all inherit from
53
31
  // This thing manages the queue of requests, and returns
54
32
  // true or false if there is anything in the queue when
55
33
  // you call the .write() method.
56
34
  const _opts = Symbol('opts')
57
- const _chunkSize = Symbol('chunkSize')
58
35
  const _flushFlag = Symbol('flushFlag')
59
- const _finishFlush = Symbol('finishFlush')
36
+ const _finishFlushFlag = Symbol('finishFlushFlag')
37
+ const _fullFlushFlag = Symbol('fullFlushFlag')
60
38
  const _handle = Symbol('handle')
61
- const _hadError = Symbol('hadError')
62
- const _buffer = Symbol('buffer')
63
- const _offset = Symbol('offset')
39
+ const _onError = Symbol('onError')
40
+ const _sawError = Symbol('sawError')
64
41
  const _level = Symbol('level')
65
42
  const _strategy = Symbol('strategy')
66
43
  const _ended = Symbol('ended')
67
- const _writeState = Symbol('writeState')
44
+ const _defaultFullFlush = Symbol('_defaultFullFlush')
68
45
 
69
- class Zlib extends MiniPass {
46
+ class ZlibBase extends Minipass {
70
47
  constructor (opts, mode) {
48
+ if (!opts || typeof opts !== 'object')
49
+ throw new TypeError('invalid options for ZlibBase constructor')
50
+
71
51
  super(opts)
72
52
  this[_ended] = false
73
- this[_opts] = opts = opts || {}
74
- this[_chunkSize] = opts.chunkSize || constants.Z_DEFAULT_CHUNK
75
- if (opts.flush && !validFlushFlags.has(opts.flush)) {
76
- throw new TypeError('Invalid flush flag: ' + opts.flush)
77
- }
78
- if (opts.finishFlush && !validFlushFlags.has(opts.finishFlush)) {
79
- throw new TypeError('Invalid flush flag: ' + opts.finishFlush)
80
- }
81
-
82
- this[_flushFlag] = opts.flush || constants.Z_NO_FLUSH
83
- this[_finishFlush] = typeof opts.finishFlush !== 'undefined' ?
84
- opts.finishFlush : constants.Z_FINISH
85
-
86
- if (opts.chunkSize) {
87
- if (opts.chunkSize < constants.Z_MIN_CHUNK) {
88
- throw new RangeError('Invalid chunk size: ' + opts.chunkSize)
89
- }
90
- }
91
-
92
- if (opts.windowBits) {
93
- if (opts.windowBits < constants.Z_MIN_WINDOWBITS ||
94
- opts.windowBits > constants.Z_MAX_WINDOWBITS) {
95
- throw new RangeError('Invalid windowBits: ' + opts.windowBits)
96
- }
53
+ this[_opts] = opts
54
+
55
+ this[_flushFlag] = opts.flush
56
+ this[_finishFlushFlag] = opts.finishFlush
57
+ // this will throw if any options are invalid for the class selected
58
+ try {
59
+ this[_handle] = new realZlib[mode](opts)
60
+ } catch (er) {
61
+ // make sure that all errors get decorated properly
62
+ throw new ZlibError(er)
97
63
  }
98
64
 
99
- if (opts.level) {
100
- if (opts.level < constants.Z_MIN_LEVEL ||
101
- opts.level > constants.Z_MAX_LEVEL) {
102
- throw new RangeError('Invalid compression level: ' + opts.level)
103
- }
104
- }
105
-
106
- if (opts.memLevel) {
107
- if (opts.memLevel < constants.Z_MIN_MEMLEVEL ||
108
- opts.memLevel > constants.Z_MAX_MEMLEVEL) {
109
- throw new RangeError('Invalid memLevel: ' + opts.memLevel)
110
- }
111
- }
112
-
113
- if (opts.strategy && !(strategies.has(opts.strategy)))
114
- throw new TypeError('Invalid strategy: ' + opts.strategy)
115
-
116
- if (opts.dictionary) {
117
- if (!(opts.dictionary instanceof Buffer)) {
118
- throw new TypeError('Invalid dictionary: it should be a Buffer instance')
119
- }
120
- }
121
-
122
- this[_handle] = new binding.Zlib(mode)
123
-
124
- this[_hadError] = false
125
- this[_handle].onerror = (message, errno) => {
65
+ this[_onError] = (err) => {
66
+ this[_sawError] = true
126
67
  // there is no way to cleanly recover.
127
68
  // continuing only obscures problems.
128
69
  this.close()
129
- this[_hadError] = true
130
-
131
- const error = new ZlibError(message, errno)
132
- this.emit('error', error)
133
- }
134
-
135
- const level = typeof opts.level === 'number' ? opts.level
136
- : constants.Z_DEFAULT_COMPRESSION
137
-
138
- var strategy = typeof opts.strategy === 'number' ? opts.strategy
139
- : constants.Z_DEFAULT_STRATEGY
140
-
141
- this[_writeState] = new Uint32Array(2);
142
- const window = opts.windowBits || constants.Z_DEFAULT_WINDOWBITS
143
- const memLevel = opts.memLevel || constants.Z_DEFAULT_MEMLEVEL
144
-
145
- // API changed in node v9
146
- /* istanbul ignore next */
147
- if (/^v[0-8]\./.test(process.version)) {
148
- this[_handle].init(window,
149
- level,
150
- memLevel,
151
- strategy,
152
- opts.dictionary)
153
- } else {
154
- this[_handle].init(window,
155
- level,
156
- memLevel,
157
- strategy,
158
- this[_writeState],
159
- () => {},
160
- opts.dictionary)
70
+ this.emit('error', err)
161
71
  }
162
72
 
163
- this[_buffer] = Buffer.allocUnsafe(this[_chunkSize])
164
- this[_offset] = 0
165
- this[_level] = level
166
- this[_strategy] = strategy
167
-
168
- this.once('end', this.close)
73
+ this[_handle].on('error', er => this[_onError](new ZlibError(er)))
74
+ this.once('end', () => this.close)
169
75
  }
170
76
 
171
77
  close () {
@@ -176,57 +82,26 @@ class Zlib extends MiniPass {
176
82
  }
177
83
  }
178
84
 
179
- params (level, strategy) {
180
- if (!this[_handle])
181
- throw new Error('cannot switch params when binding is closed')
182
-
183
- // no way to test this without also not supporting params at all
184
- /* istanbul ignore if */
185
- if (!this[_handle].params)
186
- throw new Error('not supported in this implementation')
187
-
188
- if (level < constants.Z_MIN_LEVEL ||
189
- level > constants.Z_MAX_LEVEL) {
190
- throw new RangeError('Invalid compression level: ' + level)
191
- }
192
-
193
- if (!(strategies.has(strategy)))
194
- throw new TypeError('Invalid strategy: ' + strategy)
195
-
196
- if (this[_level] !== level || this[_strategy] !== strategy) {
197
- this.flush(constants.Z_SYNC_FLUSH)
85
+ reset () {
86
+ if (!this[_sawError]) {
198
87
  assert(this[_handle], 'zlib binding closed')
199
- this[_handle].params(level, strategy)
200
- /* istanbul ignore else */
201
- if (!this[_hadError]) {
202
- this[_level] = level
203
- this[_strategy] = strategy
204
- }
88
+ return this[_handle].reset()
205
89
  }
206
90
  }
207
91
 
208
- reset () {
209
- assert(this[_handle], 'zlib binding closed')
210
- return this[_handle].reset()
211
- }
212
-
213
- flush (kind) {
214
- if (kind === undefined)
215
- kind = constants.Z_FULL_FLUSH
216
-
92
+ flush (flushFlag) {
217
93
  if (this.ended)
218
94
  return
219
95
 
220
- const flushFlag = this[_flushFlag]
221
- this[_flushFlag] = kind
222
- this.write(Buffer.alloc(0))
223
- this[_flushFlag] = flushFlag
96
+ if (typeof flushFlag !== 'number')
97
+ flushFlag = this[_fullFlushFlag]
98
+ this.write(Object.assign(Buffer.alloc(0), { [_flushFlag]: flushFlag }))
224
99
  }
225
100
 
226
101
  end (chunk, encoding, cb) {
227
102
  if (chunk)
228
103
  this.write(chunk, encoding)
229
- this.flush(this[_finishFlush])
104
+ this.flush(this[_finishFlushFlag])
230
105
  this[_ended] = true
231
106
  return super.end(null, null, cb)
232
107
  }
@@ -242,66 +117,61 @@ class Zlib extends MiniPass {
242
117
  cb = encoding, encoding = 'utf8'
243
118
 
244
119
  if (typeof chunk === 'string')
245
- chunk = new Buffer(chunk, encoding)
246
-
247
- let availInBefore = chunk && chunk.length
248
- let availOutBefore = this[_chunkSize] - this[_offset]
249
- let inOff = 0 // the offset of the input buffer
250
- const flushFlag = this[_flushFlag]
251
- let writeReturn = true
120
+ chunk = Buffer.from(chunk, encoding)
252
121
 
122
+ if (this[_sawError])
123
+ return
253
124
  assert(this[_handle], 'zlib binding closed')
254
- do {
255
- let res = this[_handle].writeSync(
256
- flushFlag,
257
- chunk, // in
258
- inOff, // in_off
259
- availInBefore, // in_len
260
- this[_buffer], // out
261
- this[_offset], //out_off
262
- availOutBefore // out_len
263
- )
264
-
265
- if (this[_hadError])
266
- break
267
-
268
- // API changed in v9
269
- /* istanbul ignore next */
270
- let availInAfter = res ? res[0] : this[_writeState][1]
271
- /* istanbul ignore next */
272
- let availOutAfter = res ? res[1] : this[_writeState][0]
273
-
274
- const have = availOutBefore - availOutAfter
275
- assert(have >= 0, 'have should not go down')
276
-
277
- if (have > 0) {
278
- const out = this[_buffer].slice(
279
- this[_offset], this[_offset] + have
280
- )
281
-
282
- this[_offset] += have
283
- // serve some output to the consumer.
284
- writeReturn = super.write(out) && writeReturn
285
- }
286
125
 
287
- // exhausted the output buffer, or used all the input create a new one.
288
- if (availOutAfter === 0 || this[_offset] >= this[_chunkSize]) {
289
- availOutBefore = this[_chunkSize]
290
- this[_offset] = 0
291
- this[_buffer] = Buffer.allocUnsafe(this[_chunkSize])
126
+ // _processChunk tries to .close() the native handle after it's done, so we
127
+ // intercept that by temporarily making it a no-op.
128
+ const nativeHandle = this[_handle]._handle
129
+ const originalNativeClose = nativeHandle.close
130
+ nativeHandle.close = () => {}
131
+ const originalClose = this[_handle].close
132
+ this[_handle].close = () => {}
133
+ // It also calls `Buffer.concat()` at the end, which may be convenient
134
+ // for some, but which we are not interested in as it slows us down.
135
+ Buffer.concat = (args) => args
136
+ let result
137
+ try {
138
+ const flushFlag = typeof chunk[_flushFlag] === 'number'
139
+ ? chunk[_flushFlag] : this[_flushFlag]
140
+ result = this[_handle]._processChunk(chunk, flushFlag)
141
+ // if we don't throw, reset it back how it was
142
+ Buffer.concat = OriginalBufferConcat
143
+ } catch (err) {
144
+ // or if we do, put Buffer.concat() back before we emit error
145
+ // Error events call into user code, which may call Buffer.concat()
146
+ Buffer.concat = OriginalBufferConcat
147
+ this[_onError](new ZlibError(err))
148
+ } finally {
149
+ if (this[_handle]) {
150
+ // Core zlib resets `_handle` to null after attempting to close the
151
+ // native handle. Our no-op handler prevented actual closure, but we
152
+ // need to restore the `._handle` property.
153
+ this[_handle]._handle = nativeHandle
154
+ nativeHandle.close = originalNativeClose
155
+ this[_handle].close = originalClose
156
+ // `_processChunk()` adds an 'error' listener. If we don't remove it
157
+ // after each call, these handlers start piling up.
158
+ this[_handle].removeAllListeners('error')
292
159
  }
160
+ }
293
161
 
294
- if (availOutAfter === 0) {
295
- // Not actually done. Need to reprocess.
296
- // Also, update the availInBefore to the availInAfter value,
297
- // so that if we have to hit it a third (fourth, etc.) time,
298
- // it'll have the correct byte counts.
299
- inOff += (availInBefore - availInAfter)
300
- availInBefore = availInAfter
301
- continue
162
+ let writeReturn
163
+ if (result) {
164
+ if (Array.isArray(result) && result.length > 0) {
165
+ // The first buffer is always `handle._outBuffer`, which would be
166
+ // re-used for later invocations; so, we always have to copy that one.
167
+ writeReturn = super.write(Buffer.from(result[0]))
168
+ for (let i = 1; i < result.length; i++) {
169
+ writeReturn = super.write(result[i])
170
+ }
171
+ } else {
172
+ writeReturn = super.write(Buffer.from(result))
302
173
  }
303
- break
304
- } while (!this[_hadError])
174
+ }
305
175
 
306
176
  if (cb)
307
177
  cb()
@@ -309,49 +179,124 @@ class Zlib extends MiniPass {
309
179
  }
310
180
  }
311
181
 
182
+ class Zlib extends ZlibBase {
183
+ constructor (opts, mode) {
184
+ opts = opts || {}
185
+
186
+ opts.flush = opts.flush || constants.Z_NO_FLUSH
187
+ opts.finishFlush = opts.finishFlush || constants.Z_FINISH
188
+ super(opts, mode)
189
+
190
+ this[_fullFlushFlag] = constants.Z_FULL_FLUSH
191
+ this[_level] = opts.level
192
+ this[_strategy] = opts.strategy
193
+ }
194
+
195
+ params (level, strategy) {
196
+ if (this[_sawError])
197
+ return
198
+
199
+ if (!this[_handle])
200
+ throw new Error('cannot switch params when binding is closed')
201
+
202
+ // no way to test this without also not supporting params at all
203
+ /* istanbul ignore if */
204
+ if (!this[_handle].params)
205
+ throw new Error('not supported in this implementation')
206
+
207
+ if (this[_level] !== level || this[_strategy] !== strategy) {
208
+ this.flush(constants.Z_SYNC_FLUSH)
209
+ assert(this[_handle], 'zlib binding closed')
210
+ // .params() calls .flush(), but the latter is always async in the
211
+ // core zlib. We override .flush() temporarily to intercept that and
212
+ // flush synchronously.
213
+ const origFlush = this[_handle].flush
214
+ this[_handle].flush = (flushFlag, cb) => {
215
+ this.flush(flushFlag)
216
+ cb()
217
+ }
218
+ try {
219
+ this[_handle].params(level, strategy)
220
+ } finally {
221
+ this[_handle].flush = origFlush
222
+ }
223
+ /* istanbul ignore else */
224
+ if (this[_handle]) {
225
+ this[_level] = level
226
+ this[_strategy] = strategy
227
+ }
228
+ }
229
+ }
230
+ }
231
+
312
232
  // minimal 2-byte header
313
233
  class Deflate extends Zlib {
314
234
  constructor (opts) {
315
- super(opts, constants.DEFLATE)
235
+ super(opts, 'Deflate')
316
236
  }
317
237
  }
318
238
 
319
239
  class Inflate extends Zlib {
320
240
  constructor (opts) {
321
- super(opts, constants.INFLATE)
241
+ super(opts, 'Inflate')
322
242
  }
323
243
  }
324
244
 
325
245
  // gzip - bigger header, same deflate compression
326
246
  class Gzip extends Zlib {
327
247
  constructor (opts) {
328
- super(opts, constants.GZIP)
248
+ super(opts, 'Gzip')
329
249
  }
330
250
  }
331
251
 
332
252
  class Gunzip extends Zlib {
333
253
  constructor (opts) {
334
- super(opts, constants.GUNZIP)
254
+ super(opts, 'Gunzip')
335
255
  }
336
256
  }
337
257
 
338
258
  // raw - no header
339
259
  class DeflateRaw extends Zlib {
340
260
  constructor (opts) {
341
- super(opts, constants.DEFLATERAW)
261
+ super(opts, 'DeflateRaw')
342
262
  }
343
263
  }
344
264
 
345
265
  class InflateRaw extends Zlib {
346
266
  constructor (opts) {
347
- super(opts, constants.INFLATERAW)
267
+ super(opts, 'InflateRaw')
348
268
  }
349
269
  }
350
270
 
351
271
  // auto-detect header.
352
272
  class Unzip extends Zlib {
353
273
  constructor (opts) {
354
- super(opts, constants.UNZIP)
274
+ super(opts, 'Unzip')
275
+ }
276
+ }
277
+
278
+ class Brotli extends ZlibBase {
279
+ constructor (opts, mode) {
280
+ opts = opts || {}
281
+
282
+ opts.flush = opts.flush || constants.BROTLI_OPERATION_PROCESS
283
+ opts.finishFlush = opts.finishFlush || constants.BROTLI_OPERATION_FINISH
284
+
285
+ super(opts, mode)
286
+
287
+ this[_fullFlushFlag] = constants.BROTLI_OPERATION_FLUSH
288
+ }
289
+ }
290
+
291
+ class BrotliCompress extends Brotli {
292
+ constructor (opts) {
293
+ super(opts, 'BrotliCompress')
294
+ }
295
+ }
296
+
297
+ class BrotliDecompress extends Brotli {
298
+ constructor (opts) {
299
+ super(opts, 'BrotliDecompress')
355
300
  }
356
301
  }
357
302
 
@@ -362,3 +307,14 @@ exports.Gunzip = Gunzip
362
307
  exports.DeflateRaw = DeflateRaw
363
308
  exports.InflateRaw = InflateRaw
364
309
  exports.Unzip = Unzip
310
+ /* istanbul ignore else */
311
+ if (typeof realZlib.BrotliCompress === 'function') {
312
+ exports.BrotliCompress = BrotliCompress
313
+ exports.BrotliDecompress = BrotliDecompress
314
+ } else {
315
+ exports.BrotliCompress = exports.BrotliDecompress = class {
316
+ constructor () {
317
+ throw new Error('Brotli is not supported in this version of Node.js')
318
+ }
319
+ }
320
+ }
@@ -1,30 +1,27 @@
1
1
  {
2
- "_args": [
3
- [
4
- "minizlib@1.1.0",
5
- "/Users/eshanker/Code/fsevents"
6
- ]
7
- ],
8
- "_from": "minizlib@1.1.0",
9
- "_id": "minizlib@1.1.0",
2
+ "_from": "minizlib@^1.2.1",
3
+ "_id": "minizlib@1.3.3",
10
4
  "_inBundle": false,
11
- "_integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==",
5
+ "_integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==",
12
6
  "_location": "/minizlib",
13
7
  "_phantomChildren": {},
14
8
  "_requested": {
15
- "type": "version",
9
+ "type": "range",
16
10
  "registry": true,
17
- "raw": "minizlib@1.1.0",
11
+ "raw": "minizlib@^1.2.1",
18
12
  "name": "minizlib",
19
13
  "escapedName": "minizlib",
20
- "rawSpec": "1.1.0",
14
+ "rawSpec": "^1.2.1",
21
15
  "saveSpec": null,
22
- "fetchSpec": "1.1.0"
16
+ "fetchSpec": "^1.2.1"
23
17
  },
24
- "_requiredBy": [],
25
- "_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz",
26
- "_spec": "1.1.0",
27
- "_where": "/Users/eshanker/Code/fsevents",
18
+ "_requiredBy": [
19
+ "/tar"
20
+ ],
21
+ "_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz",
22
+ "_shasum": "2290de96818a34c29551c8a8d301216bd65a861d",
23
+ "_spec": "minizlib@^1.2.1",
24
+ "_where": "/Users/pipobscure/fsevents/node_modules/tar",
28
25
  "author": {
29
26
  "name": "Isaac Z. Schlueter",
30
27
  "email": "i@izs.me",
@@ -33,12 +30,14 @@
33
30
  "bugs": {
34
31
  "url": "https://github.com/isaacs/minizlib/issues"
35
32
  },
33
+ "bundleDependencies": false,
36
34
  "dependencies": {
37
- "minipass": "^2.2.1"
35
+ "minipass": "^2.9.0"
38
36
  },
37
+ "deprecated": false,
39
38
  "description": "A small fast zlib stream built on [minipass](http://npm.im/minipass) and Node.js's zlib binding.",
40
39
  "devDependencies": {
41
- "tap": "^10.7.2"
40
+ "tap": "^12.0.1"
42
41
  },
43
42
  "files": [
44
43
  "index.js",
@@ -68,5 +67,5 @@
68
67
  "preversion": "npm test",
69
68
  "test": "tap test/*.js --100 -J"
70
69
  },
71
- "version": "1.1.0"
70
+ "version": "1.3.3"
72
71
  }
@@ -1,30 +1,28 @@
1
1
  {
2
- "_args": [
3
- [
4
- "mkdirp@0.5.1",
5
- "/Users/eshanker/Code/fsevents"
6
- ]
7
- ],
8
- "_from": "mkdirp@0.5.1",
2
+ "_from": "mkdirp@^0.5.1",
9
3
  "_id": "mkdirp@0.5.1",
10
4
  "_inBundle": false,
11
5
  "_integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
12
6
  "_location": "/mkdirp",
13
7
  "_phantomChildren": {},
14
8
  "_requested": {
15
- "type": "version",
9
+ "type": "range",
16
10
  "registry": true,
17
- "raw": "mkdirp@0.5.1",
11
+ "raw": "mkdirp@^0.5.1",
18
12
  "name": "mkdirp",
19
13
  "escapedName": "mkdirp",
20
- "rawSpec": "0.5.1",
14
+ "rawSpec": "^0.5.1",
21
15
  "saveSpec": null,
22
- "fetchSpec": "0.5.1"
16
+ "fetchSpec": "^0.5.1"
23
17
  },
24
- "_requiredBy": [],
18
+ "_requiredBy": [
19
+ "/node-pre-gyp",
20
+ "/tar"
21
+ ],
25
22
  "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
26
- "_spec": "0.5.1",
27
- "_where": "/Users/eshanker/Code/fsevents",
23
+ "_shasum": "30057438eac6cf7f8c4767f38648d6697d75c903",
24
+ "_spec": "mkdirp@^0.5.1",
25
+ "_where": "/Users/pipobscure/fsevents/node_modules/node-pre-gyp",
28
26
  "author": {
29
27
  "name": "James Halliday",
30
28
  "email": "mail@substack.net",
@@ -36,9 +34,11 @@
36
34
  "bugs": {
37
35
  "url": "https://github.com/substack/node-mkdirp/issues"
38
36
  },
37
+ "bundleDependencies": false,
39
38
  "dependencies": {
40
39
  "minimist": "0.0.8"
41
40
  },
41
+ "deprecated": false,
42
42
  "description": "Recursively mkdir, like `mkdir -p`",
43
43
  "devDependencies": {
44
44
  "mock-fs": "2 >=2.7.0",