node-red-contrib-web-worldmap 2.29.0 → 2.30.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 (188) hide show
  1. package/.github/FUNDING.yml +13 -0
  2. package/CHANGELOG.md +5 -2
  3. package/README.md +3 -0
  4. package/node_modules/array-flatten/package.json +6 -9
  5. package/node_modules/body-parser/HISTORY.md +18 -0
  6. package/node_modules/body-parser/README.md +9 -1
  7. package/node_modules/body-parser/SECURITY.md +25 -0
  8. package/node_modules/body-parser/lib/read.js +26 -2
  9. package/node_modules/body-parser/lib/types/json.js +10 -4
  10. package/node_modules/body-parser/package.json +24 -20
  11. package/node_modules/call-bind/.eslintignore +1 -0
  12. package/node_modules/call-bind/.eslintrc +17 -0
  13. package/node_modules/call-bind/.github/FUNDING.yml +12 -0
  14. package/node_modules/call-bind/.nycrc +13 -0
  15. package/node_modules/call-bind/CHANGELOG.md +42 -0
  16. package/node_modules/call-bind/LICENSE +21 -0
  17. package/node_modules/call-bind/README.md +2 -0
  18. package/node_modules/call-bind/callBound.js +15 -0
  19. package/node_modules/call-bind/index.js +47 -0
  20. package/node_modules/call-bind/package.json +108 -0
  21. package/node_modules/call-bind/test/callBound.js +55 -0
  22. package/node_modules/call-bind/test/index.js +66 -0
  23. package/node_modules/cookie/HISTORY.md +8 -0
  24. package/node_modules/cookie/README.md +50 -34
  25. package/node_modules/cookie/SECURITY.md +25 -0
  26. package/node_modules/cookie/index.js +83 -15
  27. package/node_modules/cookie/package.json +17 -15
  28. package/node_modules/cookie-signature/package.json +6 -9
  29. package/node_modules/depd/History.md +7 -0
  30. package/node_modules/depd/LICENSE +1 -1
  31. package/node_modules/depd/Readme.md +8 -8
  32. package/node_modules/depd/index.js +29 -13
  33. package/node_modules/depd/package.json +25 -24
  34. package/node_modules/destroy/LICENSE +1 -0
  35. package/node_modules/destroy/README.md +15 -12
  36. package/node_modules/destroy/index.js +147 -13
  37. package/node_modules/destroy/package.json +29 -20
  38. package/node_modules/ee-first/package.json +6 -9
  39. package/node_modules/encodeurl/package.json +11 -14
  40. package/node_modules/escape-html/package.json +11 -14
  41. package/node_modules/etag/package.json +11 -14
  42. package/node_modules/express/History.md +54 -0
  43. package/node_modules/express/Readme.md +39 -31
  44. package/node_modules/express/lib/application.js +18 -1
  45. package/node_modules/express/lib/response.js +40 -18
  46. package/node_modules/express/lib/router/index.js +20 -15
  47. package/node_modules/express/lib/router/route.js +9 -0
  48. package/node_modules/express/lib/utils.js +1 -0
  49. package/node_modules/express/lib/view.js +1 -1
  50. package/node_modules/express/package.json +25 -26
  51. package/node_modules/finalhandler/HISTORY.md +8 -0
  52. package/node_modules/finalhandler/LICENSE +1 -1
  53. package/node_modules/finalhandler/README.md +5 -6
  54. package/node_modules/finalhandler/SECURITY.md +25 -0
  55. package/node_modules/finalhandler/index.js +8 -3
  56. package/node_modules/finalhandler/package.json +30 -32
  57. package/node_modules/fresh/package.json +6 -9
  58. package/node_modules/function-bind/.editorconfig +20 -0
  59. package/node_modules/function-bind/.eslintrc +15 -0
  60. package/node_modules/function-bind/.jscs.json +176 -0
  61. package/node_modules/function-bind/.npmignore +22 -0
  62. package/node_modules/function-bind/.travis.yml +168 -0
  63. package/node_modules/function-bind/LICENSE +20 -0
  64. package/node_modules/function-bind/README.md +48 -0
  65. package/node_modules/function-bind/implementation.js +52 -0
  66. package/node_modules/function-bind/index.js +5 -0
  67. package/node_modules/function-bind/package.json +96 -0
  68. package/node_modules/function-bind/test/.eslintrc +9 -0
  69. package/node_modules/function-bind/test/index.js +252 -0
  70. package/node_modules/get-intrinsic/.eslintrc +37 -0
  71. package/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  72. package/node_modules/get-intrinsic/.nycrc +9 -0
  73. package/node_modules/get-intrinsic/CHANGELOG.md +98 -0
  74. package/node_modules/get-intrinsic/LICENSE +21 -0
  75. package/node_modules/get-intrinsic/README.md +71 -0
  76. package/node_modules/get-intrinsic/index.js +334 -0
  77. package/node_modules/get-intrinsic/package.json +120 -0
  78. package/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
  79. package/node_modules/has/LICENSE-MIT +22 -0
  80. package/node_modules/has/README.md +18 -0
  81. package/node_modules/has/package.json +73 -0
  82. package/node_modules/has/src/index.js +5 -0
  83. package/node_modules/has/test/index.js +10 -0
  84. package/node_modules/has-symbols/.eslintrc +11 -0
  85. package/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  86. package/node_modules/has-symbols/.nycrc +9 -0
  87. package/node_modules/has-symbols/CHANGELOG.md +75 -0
  88. package/node_modules/has-symbols/LICENSE +21 -0
  89. package/node_modules/has-symbols/README.md +46 -0
  90. package/node_modules/has-symbols/index.js +13 -0
  91. package/node_modules/has-symbols/package.json +126 -0
  92. package/node_modules/has-symbols/shams.js +42 -0
  93. package/node_modules/has-symbols/test/index.js +22 -0
  94. package/node_modules/has-symbols/test/shams/core-js.js +28 -0
  95. package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +28 -0
  96. package/node_modules/has-symbols/test/tests.js +56 -0
  97. package/node_modules/http-errors/HISTORY.md +15 -0
  98. package/node_modules/http-errors/README.md +2 -2
  99. package/node_modules/http-errors/index.js +15 -25
  100. package/node_modules/http-errors/package.json +22 -20
  101. package/node_modules/media-typer/package.json +6 -9
  102. package/node_modules/merge-descriptors/package.json +6 -9
  103. package/node_modules/methods/package.json +11 -14
  104. package/node_modules/object-inspect/.eslintrc +53 -0
  105. package/node_modules/object-inspect/.github/FUNDING.yml +12 -0
  106. package/node_modules/object-inspect/.nycrc +13 -0
  107. package/node_modules/object-inspect/CHANGELOG.md +360 -0
  108. package/node_modules/object-inspect/LICENSE +21 -0
  109. package/node_modules/object-inspect/example/all.js +23 -0
  110. package/node_modules/object-inspect/example/circular.js +6 -0
  111. package/node_modules/object-inspect/example/fn.js +5 -0
  112. package/node_modules/object-inspect/example/inspect.js +10 -0
  113. package/node_modules/object-inspect/index.js +512 -0
  114. package/node_modules/object-inspect/package-support.json +20 -0
  115. package/node_modules/object-inspect/package.json +122 -0
  116. package/node_modules/object-inspect/readme.markdown +86 -0
  117. package/node_modules/object-inspect/test/bigint.js +58 -0
  118. package/node_modules/object-inspect/test/browser/dom.js +15 -0
  119. package/node_modules/object-inspect/test/circular.js +16 -0
  120. package/node_modules/object-inspect/test/deep.js +12 -0
  121. package/node_modules/object-inspect/test/element.js +53 -0
  122. package/node_modules/object-inspect/test/err.js +48 -0
  123. package/node_modules/object-inspect/test/fakes.js +29 -0
  124. package/node_modules/object-inspect/test/fn.js +76 -0
  125. package/node_modules/object-inspect/test/has.js +15 -0
  126. package/node_modules/object-inspect/test/holes.js +15 -0
  127. package/node_modules/object-inspect/test/indent-option.js +271 -0
  128. package/node_modules/object-inspect/test/inspect.js +139 -0
  129. package/node_modules/object-inspect/test/lowbyte.js +12 -0
  130. package/node_modules/object-inspect/test/number.js +58 -0
  131. package/node_modules/object-inspect/test/quoteStyle.js +17 -0
  132. package/node_modules/object-inspect/test/toStringTag.js +40 -0
  133. package/node_modules/object-inspect/test/undef.js +12 -0
  134. package/node_modules/object-inspect/test/values.js +211 -0
  135. package/node_modules/object-inspect/test-core-js.js +26 -0
  136. package/node_modules/object-inspect/util.inspect.js +1 -0
  137. package/node_modules/on-finished/HISTORY.md +10 -0
  138. package/node_modules/on-finished/README.md +28 -20
  139. package/node_modules/on-finished/index.js +51 -13
  140. package/node_modules/on-finished/package.json +25 -20
  141. package/node_modules/path-to-regexp/package.json +6 -9
  142. package/node_modules/qs/CHANGELOG.md +22 -5
  143. package/node_modules/qs/README.md +7 -0
  144. package/node_modules/qs/dist/qs.js +1207 -5
  145. package/node_modules/qs/lib/parse.js +6 -0
  146. package/node_modules/qs/lib/stringify.js +33 -3
  147. package/node_modules/qs/package.json +16 -13
  148. package/node_modules/qs/test/parse.js +9 -0
  149. package/node_modules/qs/test/stringify.js +62 -1
  150. package/node_modules/raw-body/HISTORY.md +14 -0
  151. package/node_modules/raw-body/LICENSE +1 -1
  152. package/node_modules/raw-body/README.md +4 -0
  153. package/node_modules/raw-body/SECURITY.md +24 -0
  154. package/node_modules/raw-body/index.js +45 -2
  155. package/node_modules/raw-body/package.json +16 -15
  156. package/node_modules/send/HISTORY.md +15 -0
  157. package/node_modules/send/LICENSE +1 -1
  158. package/node_modules/send/README.md +2 -2
  159. package/node_modules/send/SECURITY.md +24 -0
  160. package/node_modules/send/index.js +37 -27
  161. package/node_modules/send/package.json +22 -21
  162. package/node_modules/serve-static/HISTORY.md +12 -0
  163. package/node_modules/serve-static/README.md +1 -1
  164. package/node_modules/serve-static/package.json +16 -16
  165. package/node_modules/side-channel/.eslintignore +1 -0
  166. package/node_modules/side-channel/.eslintrc +11 -0
  167. package/node_modules/side-channel/.github/FUNDING.yml +12 -0
  168. package/node_modules/side-channel/.nycrc +13 -0
  169. package/node_modules/side-channel/CHANGELOG.md +65 -0
  170. package/node_modules/side-channel/LICENSE +21 -0
  171. package/node_modules/side-channel/README.md +2 -0
  172. package/node_modules/side-channel/index.js +124 -0
  173. package/node_modules/side-channel/package.json +95 -0
  174. package/node_modules/side-channel/test/index.js +78 -0
  175. package/node_modules/statuses/HISTORY.md +17 -0
  176. package/node_modules/statuses/README.md +51 -42
  177. package/node_modules/statuses/codes.json +2 -3
  178. package/node_modules/statuses/index.js +52 -19
  179. package/node_modules/statuses/package.json +29 -31
  180. package/node_modules/unpipe/package.json +7 -9
  181. package/node_modules/utils-merge/package.json +6 -9
  182. package/package.json +2 -2
  183. package/worldmap/worldmap.js +22 -7
  184. package/worldmap.html +16 -0
  185. package/worldmap.js +553 -551
  186. package/node_modules/depd/lib/compat/callsite-tostring.js +0 -103
  187. package/node_modules/depd/lib/compat/event-listener-count.js +0 -22
  188. package/node_modules/depd/lib/compat/index.js +0 -79
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * depd
3
- * Copyright(c) 2014-2017 Douglas Christopher Wilson
3
+ * Copyright(c) 2014-2018 Douglas Christopher Wilson
4
4
  * MIT Licensed
5
5
  */
6
6
 
@@ -8,8 +8,6 @@
8
8
  * Module dependencies.
9
9
  */
10
10
 
11
- var callSiteToString = require('./lib/compat').callSiteToString
12
- var eventListenerCount = require('./lib/compat').eventListenerCount
13
11
  var relative = require('path').relative
14
12
 
15
13
  /**
@@ -92,7 +90,7 @@ function createStackString (stack) {
92
90
  }
93
91
 
94
92
  for (var i = 0; i < stack.length; i++) {
95
- str += '\n at ' + callSiteToString(stack[i])
93
+ str += '\n at ' + stack[i].toString()
96
94
  }
97
95
 
98
96
  return str
@@ -128,12 +126,31 @@ function depd (namespace) {
128
126
  return deprecate
129
127
  }
130
128
 
129
+ /**
130
+ * Determine if event emitter has listeners of a given type.
131
+ *
132
+ * The way to do this check is done three different ways in Node.js >= 0.8
133
+ * so this consolidates them into a minimal set using instance methods.
134
+ *
135
+ * @param {EventEmitter} emitter
136
+ * @param {string} type
137
+ * @returns {boolean}
138
+ * @private
139
+ */
140
+
141
+ function eehaslisteners (emitter, type) {
142
+ var count = typeof emitter.listenerCount !== 'function'
143
+ ? emitter.listeners(type).length
144
+ : emitter.listenerCount(type)
145
+
146
+ return count > 0
147
+ }
148
+
131
149
  /**
132
150
  * Determine if namespace is ignored.
133
151
  */
134
152
 
135
153
  function isignored (namespace) {
136
- /* istanbul ignore next: tested in a child processs */
137
154
  if (process.noDeprecation) {
138
155
  // --no-deprecation support
139
156
  return true
@@ -150,7 +167,6 @@ function isignored (namespace) {
150
167
  */
151
168
 
152
169
  function istraced (namespace) {
153
- /* istanbul ignore next: tested in a child processs */
154
170
  if (process.traceDeprecation) {
155
171
  // --trace-deprecation support
156
172
  return true
@@ -167,7 +183,7 @@ function istraced (namespace) {
167
183
  */
168
184
 
169
185
  function log (message, site) {
170
- var haslisteners = eventListenerCount(process, 'deprecation') !== 0
186
+ var haslisteners = eehaslisteners(process, 'deprecation')
171
187
 
172
188
  // abort early if no destination
173
189
  if (!haslisteners && this._ignored) {
@@ -310,7 +326,7 @@ function formatPlain (msg, caller, stack) {
310
326
  // add stack trace
311
327
  if (this._traced) {
312
328
  for (var i = 0; i < stack.length; i++) {
313
- formatted += '\n at ' + callSiteToString(stack[i])
329
+ formatted += '\n at ' + stack[i].toString()
314
330
  }
315
331
 
316
332
  return formatted
@@ -335,7 +351,7 @@ function formatColor (msg, caller, stack) {
335
351
  // add stack trace
336
352
  if (this._traced) {
337
353
  for (var i = 0; i < stack.length; i++) {
338
- formatted += '\n \x1b[36mat ' + callSiteToString(stack[i]) + '\x1b[39m' // cyan
354
+ formatted += '\n \x1b[36mat ' + stack[i].toString() + '\x1b[39m' // cyan
339
355
  }
340
356
 
341
357
  return formatted
@@ -400,18 +416,18 @@ function wrapfunction (fn, message) {
400
416
  }
401
417
 
402
418
  var args = createArgumentsString(fn.length)
403
- var deprecate = this // eslint-disable-line no-unused-vars
404
419
  var stack = getStack()
405
420
  var site = callSiteLocation(stack[1])
406
421
 
407
422
  site.name = fn.name
408
423
 
409
- // eslint-disable-next-line no-eval
410
- var deprecatedfn = eval('(function (' + args + ') {\n' +
424
+ // eslint-disable-next-line no-new-func
425
+ var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site',
411
426
  '"use strict"\n' +
427
+ 'return function (' + args + ') {' +
412
428
  'log.call(deprecate, message, site)\n' +
413
429
  'return fn.apply(this, arguments)\n' +
414
- '})')
430
+ '}')(fn, log, this, message, site)
415
431
 
416
432
  return deprecatedfn
417
433
  }
@@ -1,25 +1,19 @@
1
1
  {
2
- "_args": [
3
- [
4
- "depd@1.1.2",
5
- "/Users/conway/Projects/worldmap"
6
- ]
7
- ],
8
- "_from": "depd@1.1.2",
9
- "_id": "depd@1.1.2",
2
+ "_from": "depd@2.0.0",
3
+ "_id": "depd@2.0.0",
10
4
  "_inBundle": false,
11
- "_integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=",
5
+ "_integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
12
6
  "_location": "/depd",
13
7
  "_phantomChildren": {},
14
8
  "_requested": {
15
9
  "type": "version",
16
10
  "registry": true,
17
- "raw": "depd@1.1.2",
11
+ "raw": "depd@2.0.0",
18
12
  "name": "depd",
19
13
  "escapedName": "depd",
20
- "rawSpec": "1.1.2",
14
+ "rawSpec": "2.0.0",
21
15
  "saveSpec": null,
22
- "fetchSpec": "1.1.2"
16
+ "fetchSpec": "2.0.0"
23
17
  },
24
18
  "_requiredBy": [
25
19
  "/body-parser",
@@ -27,9 +21,10 @@
27
21
  "/http-errors",
28
22
  "/send"
29
23
  ],
30
- "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
31
- "_spec": "1.1.2",
32
- "_where": "/Users/conway/Projects/worldmap",
24
+ "_resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
25
+ "_shasum": "b696163cc757560d09cf22cc8fad1571b79e76df",
26
+ "_spec": "depd@2.0.0",
27
+ "_where": "/Users/conway/Projects/worldmap/node_modules/express",
33
28
  "author": {
34
29
  "name": "Douglas Christopher Wilson",
35
30
  "email": "doug@somethingdoug.com"
@@ -38,20 +33,26 @@
38
33
  "bugs": {
39
34
  "url": "https://github.com/dougwilson/nodejs-depd/issues"
40
35
  },
36
+ "bundleDependencies": false,
37
+ "deprecated": false,
41
38
  "description": "Deprecate all the things",
42
39
  "devDependencies": {
43
40
  "beautify-benchmark": "0.2.4",
44
41
  "benchmark": "2.1.4",
45
- "eslint": "3.19.0",
46
- "eslint-config-standard": "7.1.0",
42
+ "eslint": "5.7.0",
43
+ "eslint-config-standard": "12.0.0",
44
+ "eslint-plugin-import": "2.14.0",
47
45
  "eslint-plugin-markdown": "1.0.0-beta.7",
48
- "eslint-plugin-promise": "3.6.0",
49
- "eslint-plugin-standard": "3.0.1",
46
+ "eslint-plugin-node": "7.0.1",
47
+ "eslint-plugin-promise": "4.0.1",
48
+ "eslint-plugin-standard": "4.0.0",
50
49
  "istanbul": "0.4.5",
51
- "mocha": "~1.21.5"
50
+ "mocha": "5.2.0",
51
+ "safe-buffer": "5.1.2",
52
+ "uid-safe": "2.1.5"
52
53
  },
53
54
  "engines": {
54
- "node": ">= 0.6"
55
+ "node": ">= 0.8"
55
56
  },
56
57
  "files": [
57
58
  "lib/",
@@ -75,8 +76,8 @@
75
76
  "bench": "node benchmark/index.js",
76
77
  "lint": "eslint --plugin markdown --ext js,md .",
77
78
  "test": "mocha --reporter spec --bail test/",
78
- "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/",
79
- "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/"
79
+ "test-ci": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter spec test/ && istanbul report lcovonly text-summary",
80
+ "test-cov": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter dot test/ && istanbul report lcov text-summary"
80
81
  },
81
- "version": "1.1.2"
82
+ "version": "2.0.0"
82
83
  }
@@ -2,6 +2,7 @@
2
2
  The MIT License (MIT)
3
3
 
4
4
  Copyright (c) 2014 Jonathan Ong me@jongleberry.com
5
+ Copyright (c) 2015-2022 Douglas Christopher Wilson doug@somethingdoug.com
5
6
 
6
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
8
  of this software and associated documentation files (the "Software"), to deal
@@ -1,11 +1,10 @@
1
- # Destroy
1
+ # destroy
2
2
 
3
3
  [![NPM version][npm-image]][npm-url]
4
- [![Build status][travis-image]][travis-url]
4
+ [![Build Status][github-actions-ci-image]][github-actions-ci-url]
5
5
  [![Test coverage][coveralls-image]][coveralls-url]
6
6
  [![License][license-image]][license-url]
7
7
  [![Downloads][downloads-image]][downloads-url]
8
- [![Gittip][gittip-image]][gittip-url]
9
8
 
10
9
  Destroy a stream.
11
10
 
@@ -18,17 +17,23 @@ and Node.js bugs.
18
17
  var destroy = require('destroy')
19
18
  ```
20
19
 
21
- ### destroy(stream)
20
+ ### destroy(stream [, suppress])
22
21
 
23
- Destroy the given stream. In most cases, this is identical to a simple
24
- `stream.destroy()` call. The rules are as follows for a given stream:
22
+ Destroy the given stream, and optionally suppress any future `error` events.
23
+
24
+ In most cases, this is identical to a simple `stream.destroy()` call. The rules
25
+ are as follows for a given stream:
25
26
 
26
27
  1. If the `stream` is an instance of `ReadStream`, then call `stream.destroy()`
27
28
  and add a listener to the `open` event to call `stream.close()` if it is
28
29
  fired. This is for a Node.js bug that will leak a file descriptor if
29
30
  `.destroy()` is called before `open`.
30
- 2. If the `stream` is not an instance of `Stream`, then nothing happens.
31
- 3. If the `stream` has a `.destroy()` method, then call it.
31
+ 2. If the `stream` is an instance of a zlib stream, then call `stream.destroy()`
32
+ and close the underlying zlib handle if open, otherwise call `stream.close()`.
33
+ This is for consistency across Node.js versions and a Node.js bug that will
34
+ leak a native zlib handle.
35
+ 3. If the `stream` is not an instance of `Stream`, then nothing happens.
36
+ 4. If the `stream` has a `.destroy()` method, then call it.
32
37
 
33
38
  The function returns the `stream` passed in as the argument.
34
39
 
@@ -48,13 +53,11 @@ destroy(stream)
48
53
  [npm-url]: https://npmjs.org/package/destroy
49
54
  [github-tag]: http://img.shields.io/github/tag/stream-utils/destroy.svg?style=flat-square
50
55
  [github-url]: https://github.com/stream-utils/destroy/tags
51
- [travis-image]: https://img.shields.io/travis/stream-utils/destroy.svg?style=flat-square
52
- [travis-url]: https://travis-ci.org/stream-utils/destroy
53
56
  [coveralls-image]: https://img.shields.io/coveralls/stream-utils/destroy.svg?style=flat-square
54
57
  [coveralls-url]: https://coveralls.io/r/stream-utils/destroy?branch=master
55
58
  [license-image]: http://img.shields.io/npm/l/destroy.svg?style=flat-square
56
59
  [license-url]: LICENSE.md
57
60
  [downloads-image]: http://img.shields.io/npm/dm/destroy.svg?style=flat-square
58
61
  [downloads-url]: https://npmjs.org/package/destroy
59
- [gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square
60
- [gittip-url]: https://www.gittip.com/jonathanong/
62
+ [github-actions-ci-image]: https://img.shields.io/github/workflow/status/stream-utils/destroy/ci/master?label=ci&style=flat-square
63
+ [github-actions-ci-url]: https://github.com/stream-utils/destroy/actions/workflows/ci.yml
@@ -1,6 +1,7 @@
1
1
  /*!
2
2
  * destroy
3
3
  * Copyright(c) 2014 Jonathan Ong
4
+ * Copyright(c) 2015-2022 Douglas Christopher Wilson
4
5
  * MIT Licensed
5
6
  */
6
7
 
@@ -11,8 +12,10 @@
11
12
  * @private
12
13
  */
13
14
 
15
+ var EventEmitter = require('events').EventEmitter
14
16
  var ReadStream = require('fs').ReadStream
15
17
  var Stream = require('stream')
18
+ var Zlib = require('zlib')
16
19
 
17
20
  /**
18
21
  * Module exports.
@@ -22,23 +25,25 @@ var Stream = require('stream')
22
25
  module.exports = destroy
23
26
 
24
27
  /**
25
- * Destroy a stream.
28
+ * Destroy the given stream, and optionally suppress any future `error` events.
26
29
  *
27
30
  * @param {object} stream
31
+ * @param {boolean} suppress
28
32
  * @public
29
33
  */
30
34
 
31
- function destroy(stream) {
32
- if (stream instanceof ReadStream) {
33
- return destroyReadStream(stream)
34
- }
35
-
36
- if (!(stream instanceof Stream)) {
37
- return stream
35
+ function destroy (stream, suppress) {
36
+ if (isFsReadStream(stream)) {
37
+ destroyReadStream(stream)
38
+ } else if (isZlibStream(stream)) {
39
+ destroyZlibStream(stream)
40
+ } else if (hasDestroy(stream)) {
41
+ stream.destroy()
38
42
  }
39
43
 
40
- if (typeof stream.destroy === 'function') {
41
- stream.destroy()
44
+ if (isEventEmitter(stream) && suppress) {
45
+ stream.removeAllListeners('error')
46
+ stream.addListener('error', noop)
42
47
  }
43
48
 
44
49
  return stream
@@ -51,15 +56,144 @@ function destroy(stream) {
51
56
  * @private
52
57
  */
53
58
 
54
- function destroyReadStream(stream) {
59
+ function destroyReadStream (stream) {
55
60
  stream.destroy()
56
61
 
57
62
  if (typeof stream.close === 'function') {
58
63
  // node.js core bug work-around
59
64
  stream.on('open', onOpenClose)
60
65
  }
66
+ }
61
67
 
62
- return stream
68
+ /**
69
+ * Close a Zlib stream.
70
+ *
71
+ * Zlib streams below Node.js 4.5.5 have a buggy implementation
72
+ * of .close() when zlib encountered an error.
73
+ *
74
+ * @param {object} stream
75
+ * @private
76
+ */
77
+
78
+ function closeZlibStream (stream) {
79
+ if (stream._hadError === true) {
80
+ var prop = stream._binding === null
81
+ ? '_binding'
82
+ : '_handle'
83
+
84
+ stream[prop] = {
85
+ close: function () { this[prop] = null }
86
+ }
87
+ }
88
+
89
+ stream.close()
90
+ }
91
+
92
+ /**
93
+ * Destroy a Zlib stream.
94
+ *
95
+ * Zlib streams don't have a destroy function in Node.js 6. On top of that
96
+ * simply calling destroy on a zlib stream in Node.js 8+ will result in a
97
+ * memory leak. So until that is fixed, we need to call both close AND destroy.
98
+ *
99
+ * PR to fix memory leak: https://github.com/nodejs/node/pull/23734
100
+ *
101
+ * In Node.js 6+8, it's important that destroy is called before close as the
102
+ * stream would otherwise emit the error 'zlib binding closed'.
103
+ *
104
+ * @param {object} stream
105
+ * @private
106
+ */
107
+
108
+ function destroyZlibStream (stream) {
109
+ if (typeof stream.destroy === 'function') {
110
+ // node.js core bug work-around
111
+ // istanbul ignore if: node.js 0.8
112
+ if (stream._binding) {
113
+ // node.js < 0.10.0
114
+ stream.destroy()
115
+ if (stream._processing) {
116
+ stream._needDrain = true
117
+ stream.once('drain', onDrainClearBinding)
118
+ } else {
119
+ stream._binding.clear()
120
+ }
121
+ } else if (stream._destroy && stream._destroy !== Stream.Transform.prototype._destroy) {
122
+ // node.js >= 12, ^11.1.0, ^10.15.1
123
+ stream.destroy()
124
+ } else if (stream._destroy && typeof stream.close === 'function') {
125
+ // node.js 7, 8
126
+ stream.destroyed = true
127
+ stream.close()
128
+ } else {
129
+ // fallback
130
+ // istanbul ignore next
131
+ stream.destroy()
132
+ }
133
+ } else if (typeof stream.close === 'function') {
134
+ // node.js < 8 fallback
135
+ closeZlibStream(stream)
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Determine if stream has destroy.
141
+ * @private
142
+ */
143
+
144
+ function hasDestroy (stream) {
145
+ return stream instanceof Stream &&
146
+ typeof stream.destroy === 'function'
147
+ }
148
+
149
+ /**
150
+ * Determine if val is EventEmitter.
151
+ * @private
152
+ */
153
+
154
+ function isEventEmitter (val) {
155
+ return val instanceof EventEmitter
156
+ }
157
+
158
+ /**
159
+ * Determine if stream is fs.ReadStream stream.
160
+ * @private
161
+ */
162
+
163
+ function isFsReadStream (stream) {
164
+ return stream instanceof ReadStream
165
+ }
166
+
167
+ /**
168
+ * Determine if stream is Zlib stream.
169
+ * @private
170
+ */
171
+
172
+ function isZlibStream (stream) {
173
+ return stream instanceof Zlib.Gzip ||
174
+ stream instanceof Zlib.Gunzip ||
175
+ stream instanceof Zlib.Deflate ||
176
+ stream instanceof Zlib.DeflateRaw ||
177
+ stream instanceof Zlib.Inflate ||
178
+ stream instanceof Zlib.InflateRaw ||
179
+ stream instanceof Zlib.Unzip
180
+ }
181
+
182
+ /**
183
+ * No-op function.
184
+ * @private
185
+ */
186
+
187
+ function noop () {}
188
+
189
+ /**
190
+ * On drain handler to clear binding.
191
+ * @private
192
+ */
193
+
194
+ // istanbul ignore next: node.js 0.8
195
+ function onDrainClearBinding () {
196
+ this._binding.clear()
63
197
  }
64
198
 
65
199
  /**
@@ -67,7 +201,7 @@ function destroyReadStream(stream) {
67
201
  * @private
68
202
  */
69
203
 
70
- function onOpenClose() {
204
+ function onOpenClose () {
71
205
  if (typeof this.fd === 'number') {
72
206
  // actually close down the fd
73
207
  this.close()
@@ -1,32 +1,28 @@
1
1
  {
2
- "_args": [
3
- [
4
- "destroy@1.0.4",
5
- "/Users/conway/Projects/worldmap"
6
- ]
7
- ],
8
- "_from": "destroy@1.0.4",
9
- "_id": "destroy@1.0.4",
2
+ "_from": "destroy@1.2.0",
3
+ "_id": "destroy@1.2.0",
10
4
  "_inBundle": false,
11
- "_integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=",
5
+ "_integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
12
6
  "_location": "/destroy",
13
7
  "_phantomChildren": {},
14
8
  "_requested": {
15
9
  "type": "version",
16
10
  "registry": true,
17
- "raw": "destroy@1.0.4",
11
+ "raw": "destroy@1.2.0",
18
12
  "name": "destroy",
19
13
  "escapedName": "destroy",
20
- "rawSpec": "1.0.4",
14
+ "rawSpec": "1.2.0",
21
15
  "saveSpec": null,
22
- "fetchSpec": "1.0.4"
16
+ "fetchSpec": "1.2.0"
23
17
  },
24
18
  "_requiredBy": [
19
+ "/body-parser",
25
20
  "/send"
26
21
  ],
27
- "_resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
28
- "_spec": "1.0.4",
29
- "_where": "/Users/conway/Projects/worldmap",
22
+ "_resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
23
+ "_shasum": "4803735509ad8be552934c67df614f94e66fa015",
24
+ "_spec": "destroy@1.2.0",
25
+ "_where": "/Users/conway/Projects/worldmap/node_modules/body-parser",
30
26
  "author": {
31
27
  "name": "Jonathan Ong",
32
28
  "email": "me@jongleberry.com",
@@ -35,16 +31,28 @@
35
31
  "bugs": {
36
32
  "url": "https://github.com/stream-utils/destroy/issues"
37
33
  },
34
+ "bundleDependencies": false,
38
35
  "contributors": [
39
36
  {
40
37
  "name": "Douglas Christopher Wilson",
41
38
  "email": "doug@somethingdoug.com"
42
39
  }
43
40
  ],
41
+ "deprecated": false,
44
42
  "description": "destroy a stream if possible",
45
43
  "devDependencies": {
46
- "istanbul": "0.4.2",
47
- "mocha": "2.3.4"
44
+ "eslint": "7.32.0",
45
+ "eslint-config-standard": "14.1.1",
46
+ "eslint-plugin-import": "2.25.4",
47
+ "eslint-plugin-node": "11.1.0",
48
+ "eslint-plugin-promise": "5.2.0",
49
+ "eslint-plugin-standard": "4.1.0",
50
+ "mocha": "9.2.2",
51
+ "nyc": "15.1.0"
52
+ },
53
+ "engines": {
54
+ "node": ">= 0.8",
55
+ "npm": "1.2.8000 || >= 1.4.16"
48
56
  },
49
57
  "files": [
50
58
  "index.js",
@@ -66,9 +74,10 @@
66
74
  "url": "git+https://github.com/stream-utils/destroy.git"
67
75
  },
68
76
  "scripts": {
77
+ "lint": "eslint .",
69
78
  "test": "mocha --reporter spec",
70
- "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
71
- "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
79
+ "test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
80
+ "test-cov": "nyc --reporter=html --reporter=text npm test"
72
81
  },
73
- "version": "1.0.4"
82
+ "version": "1.2.0"
74
83
  }
@@ -1,14 +1,8 @@
1
1
  {
2
- "_args": [
3
- [
4
- "ee-first@1.1.1",
5
- "/Users/conway/Projects/worldmap"
6
- ]
7
- ],
8
2
  "_from": "ee-first@1.1.1",
9
3
  "_id": "ee-first@1.1.1",
10
4
  "_inBundle": false,
11
- "_integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=",
5
+ "_integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
12
6
  "_location": "/ee-first",
13
7
  "_phantomChildren": {},
14
8
  "_requested": {
@@ -25,8 +19,9 @@
25
19
  "/on-finished"
26
20
  ],
27
21
  "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
28
- "_spec": "1.1.1",
29
- "_where": "/Users/conway/Projects/worldmap",
22
+ "_shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d",
23
+ "_spec": "ee-first@1.1.1",
24
+ "_where": "/Users/conway/Projects/worldmap/node_modules/on-finished",
30
25
  "author": {
31
26
  "name": "Jonathan Ong",
32
27
  "email": "me@jongleberry.com",
@@ -35,12 +30,14 @@
35
30
  "bugs": {
36
31
  "url": "https://github.com/jonathanong/ee-first/issues"
37
32
  },
33
+ "bundleDependencies": false,
38
34
  "contributors": [
39
35
  {
40
36
  "name": "Douglas Christopher Wilson",
41
37
  "email": "doug@somethingdoug.com"
42
38
  }
43
39
  ],
40
+ "deprecated": false,
44
41
  "description": "return the first event in a set of ee/event pairs",
45
42
  "devDependencies": {
46
43
  "istanbul": "0.3.9",
@@ -1,25 +1,19 @@
1
1
  {
2
- "_args": [
3
- [
4
- "encodeurl@1.0.2",
5
- "/Users/conway/Projects/worldmap"
6
- ]
7
- ],
8
- "_from": "encodeurl@1.0.2",
2
+ "_from": "encodeurl@~1.0.2",
9
3
  "_id": "encodeurl@1.0.2",
10
4
  "_inBundle": false,
11
- "_integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=",
5
+ "_integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
12
6
  "_location": "/encodeurl",
13
7
  "_phantomChildren": {},
14
8
  "_requested": {
15
- "type": "version",
9
+ "type": "range",
16
10
  "registry": true,
17
- "raw": "encodeurl@1.0.2",
11
+ "raw": "encodeurl@~1.0.2",
18
12
  "name": "encodeurl",
19
13
  "escapedName": "encodeurl",
20
- "rawSpec": "1.0.2",
14
+ "rawSpec": "~1.0.2",
21
15
  "saveSpec": null,
22
- "fetchSpec": "1.0.2"
16
+ "fetchSpec": "~1.0.2"
23
17
  },
24
18
  "_requiredBy": [
25
19
  "/express",
@@ -28,17 +22,20 @@
28
22
  "/serve-static"
29
23
  ],
30
24
  "_resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
31
- "_spec": "1.0.2",
32
- "_where": "/Users/conway/Projects/worldmap",
25
+ "_shasum": "ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59",
26
+ "_spec": "encodeurl@~1.0.2",
27
+ "_where": "/Users/conway/Projects/worldmap/node_modules/express",
33
28
  "bugs": {
34
29
  "url": "https://github.com/pillarjs/encodeurl/issues"
35
30
  },
31
+ "bundleDependencies": false,
36
32
  "contributors": [
37
33
  {
38
34
  "name": "Douglas Christopher Wilson",
39
35
  "email": "doug@somethingdoug.com"
40
36
  }
41
37
  ],
38
+ "deprecated": false,
42
39
  "description": "Encode a URL to a percent-encoded form, excluding already-encoded sequences",
43
40
  "devDependencies": {
44
41
  "eslint": "3.19.0",