node-red-contrib-web-worldmap 5.1.5 → 5.2.0

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 (247) hide show
  1. package/CHANGELOG.md +6 -4
  2. package/README.md +6 -4
  3. package/node_modules/@types/geojson/README.md +1 -1
  4. package/node_modules/@types/geojson/index.d.ts +36 -2
  5. package/node_modules/@types/geojson/package.json +2 -2
  6. package/node_modules/{call-bind → call-bind-apply-helpers}/.eslintrc +1 -0
  7. package/node_modules/{has-property-descriptors → call-bind-apply-helpers}/.github/FUNDING.yml +1 -1
  8. package/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
  9. package/node_modules/{call-bind → call-bind-apply-helpers}/LICENSE +1 -1
  10. package/node_modules/call-bind-apply-helpers/README.md +62 -0
  11. package/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
  12. package/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
  13. package/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
  14. package/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
  15. package/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
  16. package/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
  17. package/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
  18. package/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
  19. package/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
  20. package/node_modules/call-bind-apply-helpers/index.js +15 -0
  21. package/node_modules/call-bind-apply-helpers/package.json +85 -0
  22. package/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
  23. package/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
  24. package/node_modules/call-bind-apply-helpers/test/index.js +63 -0
  25. package/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
  26. package/node_modules/call-bound/.eslintrc +13 -0
  27. package/node_modules/{call-bind → call-bound}/.github/FUNDING.yml +1 -1
  28. package/node_modules/call-bound/CHANGELOG.md +42 -0
  29. package/node_modules/{has-property-descriptors → call-bound}/LICENSE +1 -1
  30. package/node_modules/call-bound/README.md +53 -0
  31. package/node_modules/call-bound/index.d.ts +94 -0
  32. package/node_modules/call-bound/index.js +19 -0
  33. package/node_modules/{call-bind → call-bound}/package.json +29 -25
  34. package/node_modules/{call-bind/test/callBound.js → call-bound/test/index.js} +12 -5
  35. package/node_modules/call-bound/tsconfig.json +10 -0
  36. package/node_modules/compression/HISTORY.md +9 -1
  37. package/node_modules/compression/README.md +103 -30
  38. package/node_modules/compression/index.js +55 -13
  39. package/node_modules/compression/package.json +3 -2
  40. package/node_modules/{define-data-property → dunder-proto}/.github/FUNDING.yml +1 -1
  41. package/node_modules/dunder-proto/CHANGELOG.md +24 -0
  42. package/node_modules/dunder-proto/LICENSE +21 -0
  43. package/node_modules/dunder-proto/README.md +54 -0
  44. package/node_modules/dunder-proto/get.d.ts +5 -0
  45. package/node_modules/dunder-proto/get.js +30 -0
  46. package/node_modules/{has-proto → dunder-proto}/package.json +34 -36
  47. package/node_modules/dunder-proto/set.d.ts +5 -0
  48. package/node_modules/dunder-proto/set.js +35 -0
  49. package/node_modules/dunder-proto/test/get.js +34 -0
  50. package/node_modules/dunder-proto/test/index.js +4 -0
  51. package/node_modules/dunder-proto/test/set.js +50 -0
  52. package/node_modules/dunder-proto/tsconfig.json +9 -0
  53. package/node_modules/es-define-property/CHANGELOG.md +14 -0
  54. package/node_modules/es-define-property/index.js +1 -3
  55. package/node_modules/es-define-property/package.json +12 -12
  56. package/node_modules/es-define-property/test/index.js +1 -0
  57. package/node_modules/es-define-property/tsconfig.json +2 -42
  58. package/node_modules/es-object-atoms/.eslintrc +16 -0
  59. package/node_modules/{set-function-length → es-object-atoms}/.github/FUNDING.yml +1 -1
  60. package/node_modules/es-object-atoms/CHANGELOG.md +37 -0
  61. package/node_modules/{define-data-property → es-object-atoms}/LICENSE +1 -1
  62. package/node_modules/es-object-atoms/README.md +63 -0
  63. package/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
  64. package/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
  65. package/node_modules/es-object-atoms/ToObject.d.ts +7 -0
  66. package/node_modules/es-object-atoms/ToObject.js +10 -0
  67. package/node_modules/es-object-atoms/index.d.ts +3 -0
  68. package/node_modules/es-object-atoms/index.js +4 -0
  69. package/node_modules/es-object-atoms/isObject.d.ts +3 -0
  70. package/node_modules/es-object-atoms/isObject.js +6 -0
  71. package/node_modules/es-object-atoms/package.json +80 -0
  72. package/node_modules/es-object-atoms/test/index.js +38 -0
  73. package/node_modules/es-object-atoms/tsconfig.json +6 -0
  74. package/node_modules/get-intrinsic/.eslintrc +4 -0
  75. package/node_modules/get-intrinsic/CHANGELOG.md +43 -0
  76. package/node_modules/get-intrinsic/index.js +40 -21
  77. package/node_modules/get-intrinsic/package.json +24 -20
  78. package/node_modules/get-intrinsic/test/GetIntrinsic.js +2 -2
  79. package/node_modules/get-proto/.eslintrc +10 -0
  80. package/node_modules/{has-proto → get-proto}/.github/FUNDING.yml +1 -1
  81. package/node_modules/get-proto/.nycrc +9 -0
  82. package/node_modules/get-proto/CHANGELOG.md +21 -0
  83. package/node_modules/{has-proto → get-proto}/LICENSE +1 -1
  84. package/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
  85. package/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
  86. package/node_modules/get-proto/README.md +50 -0
  87. package/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
  88. package/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
  89. package/node_modules/get-proto/index.d.ts +5 -0
  90. package/node_modules/get-proto/index.js +27 -0
  91. package/node_modules/{has-property-descriptors → get-proto}/package.json +35 -31
  92. package/node_modules/get-proto/test/index.js +68 -0
  93. package/node_modules/get-proto/tsconfig.json +9 -0
  94. package/node_modules/gopd/CHANGELOG.md +20 -0
  95. package/node_modules/gopd/gOPD.d.ts +1 -0
  96. package/node_modules/gopd/gOPD.js +4 -0
  97. package/node_modules/gopd/index.d.ts +5 -0
  98. package/node_modules/gopd/index.js +2 -3
  99. package/node_modules/gopd/package.json +16 -10
  100. package/node_modules/gopd/test/index.js +2 -1
  101. package/node_modules/has-symbols/CHANGELOG.md +16 -0
  102. package/node_modules/has-symbols/index.d.ts +3 -0
  103. package/node_modules/has-symbols/index.js +1 -0
  104. package/node_modules/has-symbols/package.json +19 -9
  105. package/node_modules/has-symbols/shams.d.ts +3 -0
  106. package/node_modules/has-symbols/shams.js +5 -2
  107. package/node_modules/has-symbols/test/shams/core-js.js +1 -0
  108. package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +1 -0
  109. package/node_modules/has-symbols/test/tests.js +4 -2
  110. package/node_modules/has-symbols/tsconfig.json +10 -0
  111. package/node_modules/http-parser-js/http-parser.d.ts +6 -0
  112. package/node_modules/http-parser-js/http-parser.js +16 -9
  113. package/node_modules/http-parser-js/package.json +1 -1
  114. package/node_modules/math-intrinsics/.eslintrc +16 -0
  115. package/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
  116. package/node_modules/math-intrinsics/CHANGELOG.md +24 -0
  117. package/node_modules/math-intrinsics/LICENSE +21 -0
  118. package/node_modules/math-intrinsics/README.md +50 -0
  119. package/node_modules/math-intrinsics/abs.d.ts +1 -0
  120. package/node_modules/math-intrinsics/abs.js +4 -0
  121. package/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
  122. package/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
  123. package/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
  124. package/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
  125. package/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
  126. package/node_modules/math-intrinsics/constants/maxValue.js +5 -0
  127. package/node_modules/math-intrinsics/floor.d.ts +1 -0
  128. package/node_modules/math-intrinsics/floor.js +4 -0
  129. package/node_modules/math-intrinsics/isFinite.d.ts +3 -0
  130. package/node_modules/math-intrinsics/isFinite.js +12 -0
  131. package/node_modules/math-intrinsics/isInteger.d.ts +3 -0
  132. package/node_modules/math-intrinsics/isInteger.js +16 -0
  133. package/node_modules/math-intrinsics/isNaN.d.ts +1 -0
  134. package/node_modules/math-intrinsics/isNaN.js +6 -0
  135. package/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
  136. package/node_modules/math-intrinsics/isNegativeZero.js +6 -0
  137. package/node_modules/math-intrinsics/max.d.ts +1 -0
  138. package/node_modules/math-intrinsics/max.js +4 -0
  139. package/node_modules/math-intrinsics/min.d.ts +1 -0
  140. package/node_modules/math-intrinsics/min.js +4 -0
  141. package/node_modules/math-intrinsics/mod.d.ts +3 -0
  142. package/node_modules/math-intrinsics/mod.js +9 -0
  143. package/node_modules/math-intrinsics/package.json +86 -0
  144. package/node_modules/math-intrinsics/pow.d.ts +1 -0
  145. package/node_modules/math-intrinsics/pow.js +4 -0
  146. package/node_modules/math-intrinsics/round.d.ts +1 -0
  147. package/node_modules/math-intrinsics/round.js +4 -0
  148. package/node_modules/math-intrinsics/sign.d.ts +3 -0
  149. package/node_modules/math-intrinsics/sign.js +11 -0
  150. package/node_modules/math-intrinsics/test/index.js +192 -0
  151. package/node_modules/math-intrinsics/tsconfig.json +3 -0
  152. package/node_modules/mime-db/HISTORY.md +21 -1
  153. package/node_modules/mime-db/README.md +7 -1
  154. package/node_modules/mime-db/db.json +252 -13
  155. package/node_modules/mime-db/package.json +4 -4
  156. package/node_modules/object-inspect/CHANGELOG.md +8 -0
  157. package/node_modules/object-inspect/index.js +10 -7
  158. package/node_modules/object-inspect/package.json +5 -4
  159. package/node_modules/object-inspect/test/values.js +50 -0
  160. package/node_modules/side-channel/.eslintrc +1 -0
  161. package/node_modules/side-channel/CHANGELOG.md +15 -0
  162. package/node_modules/side-channel/README.md +60 -1
  163. package/node_modules/side-channel/index.d.ts +9 -22
  164. package/node_modules/side-channel/index.js +20 -106
  165. package/node_modules/side-channel/package.json +20 -19
  166. package/node_modules/side-channel/test/index.js +76 -55
  167. package/node_modules/side-channel/tsconfig.json +2 -43
  168. package/node_modules/side-channel-list/.editorconfig +9 -0
  169. package/node_modules/side-channel-list/.eslintrc +11 -0
  170. package/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
  171. package/node_modules/side-channel-list/CHANGELOG.md +15 -0
  172. package/node_modules/side-channel-list/LICENSE +21 -0
  173. package/node_modules/side-channel-list/README.md +62 -0
  174. package/node_modules/side-channel-list/index.d.ts +13 -0
  175. package/node_modules/side-channel-list/index.js +113 -0
  176. package/node_modules/side-channel-list/list.d.ts +14 -0
  177. package/node_modules/side-channel-list/package.json +77 -0
  178. package/node_modules/side-channel-list/test/index.js +104 -0
  179. package/node_modules/side-channel-list/tsconfig.json +9 -0
  180. package/node_modules/side-channel-map/.editorconfig +9 -0
  181. package/node_modules/side-channel-map/.eslintrc +11 -0
  182. package/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
  183. package/node_modules/side-channel-map/.nycrc +13 -0
  184. package/node_modules/side-channel-map/CHANGELOG.md +22 -0
  185. package/node_modules/side-channel-map/LICENSE +21 -0
  186. package/node_modules/side-channel-map/README.md +62 -0
  187. package/node_modules/side-channel-map/index.d.ts +15 -0
  188. package/node_modules/side-channel-map/index.js +68 -0
  189. package/node_modules/side-channel-map/package.json +80 -0
  190. package/node_modules/side-channel-map/test/index.js +114 -0
  191. package/node_modules/side-channel-map/tsconfig.json +9 -0
  192. package/node_modules/side-channel-weakmap/.editorconfig +9 -0
  193. package/node_modules/side-channel-weakmap/.eslintrc +12 -0
  194. package/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
  195. package/node_modules/side-channel-weakmap/.nycrc +13 -0
  196. package/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
  197. package/node_modules/side-channel-weakmap/LICENSE +21 -0
  198. package/node_modules/side-channel-weakmap/README.md +62 -0
  199. package/node_modules/side-channel-weakmap/index.d.ts +15 -0
  200. package/node_modules/side-channel-weakmap/index.js +84 -0
  201. package/node_modules/side-channel-weakmap/package.json +87 -0
  202. package/node_modules/side-channel-weakmap/test/index.js +114 -0
  203. package/node_modules/side-channel-weakmap/tsconfig.json +9 -0
  204. package/package.json +1 -1
  205. package/worldmap/worldmap.js +29 -22
  206. package/worldmap.html +1 -0
  207. package/worldmap.js +5 -2
  208. package/node_modules/call-bind/.eslintignore +0 -1
  209. package/node_modules/call-bind/CHANGELOG.md +0 -93
  210. package/node_modules/call-bind/README.md +0 -64
  211. package/node_modules/call-bind/callBound.js +0 -15
  212. package/node_modules/call-bind/index.js +0 -35
  213. package/node_modules/call-bind/test/index.js +0 -80
  214. package/node_modules/define-data-property/.eslintrc +0 -24
  215. package/node_modules/define-data-property/CHANGELOG.md +0 -70
  216. package/node_modules/define-data-property/README.md +0 -67
  217. package/node_modules/define-data-property/index.d.ts +0 -12
  218. package/node_modules/define-data-property/index.js +0 -56
  219. package/node_modules/define-data-property/package.json +0 -106
  220. package/node_modules/define-data-property/test/index.js +0 -392
  221. package/node_modules/define-data-property/tsconfig.json +0 -59
  222. package/node_modules/has-property-descriptors/.eslintrc +0 -13
  223. package/node_modules/has-property-descriptors/CHANGELOG.md +0 -35
  224. package/node_modules/has-property-descriptors/README.md +0 -43
  225. package/node_modules/has-property-descriptors/index.js +0 -22
  226. package/node_modules/has-property-descriptors/test/index.js +0 -57
  227. package/node_modules/has-proto/CHANGELOG.md +0 -38
  228. package/node_modules/has-proto/README.md +0 -38
  229. package/node_modules/has-proto/index.d.ts +0 -3
  230. package/node_modules/has-proto/index.js +0 -15
  231. package/node_modules/has-proto/test/index.js +0 -19
  232. package/node_modules/has-proto/tsconfig.json +0 -49
  233. package/node_modules/set-function-length/.eslintrc +0 -27
  234. package/node_modules/set-function-length/CHANGELOG.md +0 -70
  235. package/node_modules/set-function-length/LICENSE +0 -21
  236. package/node_modules/set-function-length/README.md +0 -56
  237. package/node_modules/set-function-length/env.d.ts +0 -9
  238. package/node_modules/set-function-length/env.js +0 -25
  239. package/node_modules/set-function-length/index.d.ts +0 -7
  240. package/node_modules/set-function-length/index.js +0 -42
  241. package/node_modules/set-function-length/package.json +0 -102
  242. /package/node_modules/{call-bind → call-bind-apply-helpers}/.nycrc +0 -0
  243. /package/node_modules/{has-property-descriptors → call-bound}/.nycrc +0 -0
  244. /package/node_modules/{has-proto → dunder-proto}/.eslintrc +0 -0
  245. /package/node_modules/{define-data-property → dunder-proto}/.nycrc +0 -0
  246. /package/node_modules/{set-function-length → gopd}/tsconfig.json +0 -0
  247. /package/node_modules/{set-function-length → side-channel-list}/.nycrc +0 -0
@@ -287,13 +287,16 @@ function quote(s) {
287
287
  return $replace.call(String(s), /"/g, '"');
288
288
  }
289
289
 
290
- function isArray(obj) { return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
291
- function isDate(obj) { return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
292
- function isRegExp(obj) { return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
293
- function isError(obj) { return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
294
- function isString(obj) { return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
295
- function isNumber(obj) { return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
296
- function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
290
+ function canTrustToString(obj) {
291
+ return !toStringTag || !(typeof obj === 'object' && (toStringTag in obj || typeof obj[toStringTag] !== 'undefined'));
292
+ }
293
+ function isArray(obj) { return toStr(obj) === '[object Array]' && canTrustToString(obj); }
294
+ function isDate(obj) { return toStr(obj) === '[object Date]' && canTrustToString(obj); }
295
+ function isRegExp(obj) { return toStr(obj) === '[object RegExp]' && canTrustToString(obj); }
296
+ function isError(obj) { return toStr(obj) === '[object Error]' && canTrustToString(obj); }
297
+ function isString(obj) { return toStr(obj) === '[object String]' && canTrustToString(obj); }
298
+ function isNumber(obj) { return toStr(obj) === '[object Number]' && canTrustToString(obj); }
299
+ function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && canTrustToString(obj); }
297
300
 
298
301
  // Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
299
302
  function isSymbol(obj) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "object-inspect",
3
- "version": "1.13.3",
3
+ "version": "1.13.4",
4
4
  "description": "string representations of objects in node and the browser",
5
5
  "main": "index.js",
6
6
  "sideEffects": false,
@@ -10,13 +10,13 @@
10
10
  "auto-changelog": "^2.5.0",
11
11
  "core-js": "^2.6.12",
12
12
  "error-cause": "^1.0.8",
13
- "es-value-fixtures": "^1.5.0",
13
+ "es-value-fixtures": "^1.7.1",
14
14
  "eslint": "=8.8.0",
15
- "for-each": "^0.3.3",
15
+ "for-each": "^0.3.4",
16
16
  "functions-have-names": "^1.2.3",
17
17
  "glob": "=10.3.7",
18
18
  "globalthis": "^1.0.4",
19
- "has-symbols": "^1.0.3",
19
+ "has-symbols": "^1.1.0",
20
20
  "has-tostringtag": "^1.0.2",
21
21
  "in-publish": "^2.0.1",
22
22
  "jackspeak": "=2.1.1",
@@ -26,6 +26,7 @@
26
26
  "nyc": "^10.3.2",
27
27
  "safe-publish-latest": "^2.0.0",
28
28
  "safer-buffer": "^2.1.2",
29
+ "semver": "^6.3.1",
29
30
  "string.prototype.repeat": "^1.0.0",
30
31
  "tape": "^5.9.0"
31
32
  },
@@ -5,6 +5,8 @@ var test = require('tape');
5
5
  var mockProperty = require('mock-property');
6
6
  var hasSymbols = require('has-symbols/shams')();
7
7
  var hasToStringTag = require('has-tostringtag/shams')();
8
+ var forEach = require('for-each');
9
+ var semver = require('semver');
8
10
 
9
11
  test('values', function (t) {
10
12
  t.plan(1);
@@ -209,3 +211,51 @@ test('RegExps', function (t) {
209
211
 
210
212
  t.end();
211
213
  });
214
+
215
+ test('Proxies', { skip: typeof Proxy !== 'function' || !hasToStringTag }, function (t) {
216
+ var target = { proxy: true };
217
+ var fake = new Proxy(target, { has: function () { return false; } });
218
+
219
+ // needed to work around a weird difference in node v6.0 - v6.4 where non-present properties are not logged
220
+ var isNode60 = semver.satisfies(process.version, '6.0 - 6.4');
221
+
222
+ forEach([
223
+ 'Boolean',
224
+ 'Number',
225
+ 'String',
226
+ 'Symbol',
227
+ 'Date'
228
+ ], function (tag) {
229
+ target[Symbol.toStringTag] = tag;
230
+
231
+ t.equal(
232
+ inspect(fake),
233
+ '{ ' + (isNode60 ? '' : 'proxy: true, ') + '[Symbol(Symbol.toStringTag)]: \'' + tag + '\' }',
234
+ 'Proxy for + ' + tag + ' shows as the target, which has no slots'
235
+ );
236
+ });
237
+
238
+ t.end();
239
+ });
240
+
241
+ test('fakers', { skip: !hasToStringTag }, function (t) {
242
+ var target = { proxy: false };
243
+
244
+ forEach([
245
+ 'Boolean',
246
+ 'Number',
247
+ 'String',
248
+ 'Symbol',
249
+ 'Date'
250
+ ], function (tag) {
251
+ target[Symbol.toStringTag] = tag;
252
+
253
+ t.equal(
254
+ inspect(target),
255
+ '{ proxy: false, [Symbol(Symbol.toStringTag)]: \'' + tag + '\' }',
256
+ 'Object pretending to be ' + tag + ' does not trick us'
257
+ );
258
+ });
259
+
260
+ t.end();
261
+ });
@@ -4,6 +4,7 @@
4
4
  "extends": "@ljharb",
5
5
 
6
6
  "rules": {
7
+ "id-length": 0,
7
8
  "max-lines-per-function": 0,
8
9
  "multiline-comment-style": 1,
9
10
  "new-cap": [2, { "capIsNewExceptions": ["GetIntrinsic"] }],
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [v1.1.0](https://github.com/ljharb/side-channel/compare/v1.0.6...v1.1.0) - 2024-12-11
9
+
10
+ ### Commits
11
+
12
+ - [Refactor] extract implementations to `side-channel-weakmap`, `side-channel-map`, `side-channel-list` [`ada5955`](https://github.com/ljharb/side-channel/commit/ada595549a5c4c6c853756d598846b180941c6da)
13
+ - [New] add `channel.delete` [`c01d2d3`](https://github.com/ljharb/side-channel/commit/c01d2d3fd51dbb1ce6da72ad7916e61bd6172aad)
14
+ - [types] improve types [`0c54356`](https://github.com/ljharb/side-channel/commit/0c5435651417df41b8cc1a5f7cdce8bffae68cde)
15
+ - [readme] add content [`be24868`](https://github.com/ljharb/side-channel/commit/be248682ac294b0e22c883092c45985aa91c490a)
16
+ - [actions] split out node 10-20, and 20+ [`c4488e2`](https://github.com/ljharb/side-channel/commit/c4488e241ef3d49a19fe266ac830a2e644305911)
17
+ - [types] use shared tsconfig [`0e0d57c`](https://github.com/ljharb/side-channel/commit/0e0d57c2ff17c7b45c6cbd43ebcf553edc9e3adc)
18
+ - [Dev Deps] update `@ljharb/eslint-config`, `@ljharb/tsconfig`, `@types/get-intrinsic`, `@types/object-inspect`, `@types/tape`, `auto-changelog`, `tape` [`fb4f622`](https://github.com/ljharb/side-channel/commit/fb4f622e64a99a1e40b6e5cd7691674a9dc429e4)
19
+ - [Deps] update `call-bind`, `get-intrinsic`, `object-inspect` [`b78336b`](https://github.com/ljharb/side-channel/commit/b78336b886172d1b457d414ac9e28de8c5fecc78)
20
+ - [Tests] replace `aud` with `npm audit` [`ee3ab46`](https://github.com/ljharb/side-channel/commit/ee3ab4690d954311c35115651bcfd45edd205aa1)
21
+ - [Dev Deps] add missing peer dep [`c03e21a`](https://github.com/ljharb/side-channel/commit/c03e21a7def3b67cdc15ae22316884fefcb2f6a8)
22
+
8
23
  ## [v1.0.6](https://github.com/ljharb/side-channel/compare/v1.0.5...v1.0.6) - 2024-02-29
9
24
 
10
25
  ### Commits
@@ -1,2 +1,61 @@
1
- # side-channel
1
+ # side-channel <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
+
3
+ [![github actions][actions-image]][actions-url]
4
+ [![coverage][codecov-image]][codecov-url]
5
+ [![License][license-image]][license-url]
6
+ [![Downloads][downloads-image]][downloads-url]
7
+
8
+ [![npm badge][npm-badge-png]][package-url]
9
+
2
10
  Store information about any JS value in a side channel. Uses WeakMap if available.
11
+
12
+ Warning: in an environment that lacks `WeakMap`, this implementation will leak memory until you `delete` the `key`.
13
+
14
+ ## Getting started
15
+
16
+ ```sh
17
+ npm install --save side-channel
18
+ ```
19
+
20
+ ## Usage/Examples
21
+
22
+ ```js
23
+ const assert = require('assert');
24
+ const getSideChannel = require('side-channel');
25
+
26
+ const channel = getSideChannel();
27
+
28
+ const key = {};
29
+ assert.equal(channel.has(key), false);
30
+ assert.throws(() => channel.assert(key), TypeError);
31
+
32
+ channel.set(key, 42);
33
+
34
+ channel.assert(key); // does not throw
35
+ assert.equal(channel.has(key), true);
36
+ assert.equal(channel.get(key), 42);
37
+
38
+ channel.delete(key);
39
+ assert.equal(channel.has(key), false);
40
+ assert.throws(() => channel.assert(key), TypeError);
41
+ ```
42
+
43
+ ## Tests
44
+
45
+ Clone the repo, `npm install`, and run `npm test`
46
+
47
+ [package-url]: https://npmjs.org/package/side-channel
48
+ [npm-version-svg]: https://versionbadg.es/ljharb/side-channel.svg
49
+ [deps-svg]: https://david-dm.org/ljharb/side-channel.svg
50
+ [deps-url]: https://david-dm.org/ljharb/side-channel
51
+ [dev-deps-svg]: https://david-dm.org/ljharb/side-channel/dev-status.svg
52
+ [dev-deps-url]: https://david-dm.org/ljharb/side-channel#info=devDependencies
53
+ [npm-badge-png]: https://nodei.co/npm/side-channel.png?downloads=true&stars=true
54
+ [license-image]: https://img.shields.io/npm/l/side-channel.svg
55
+ [license-url]: LICENSE
56
+ [downloads-image]: https://img.shields.io/npm/dm/side-channel.svg
57
+ [downloads-url]: https://npm-stat.com/charts.html?package=side-channel
58
+ [codecov-image]: https://codecov.io/gh/ljharb/side-channel/branch/main/graphs/badge.svg
59
+ [codecov-url]: https://app.codecov.io/gh/ljharb/side-channel/
60
+ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/side-channel
61
+ [actions-url]: https://github.com/ljharb/side-channel/actions
@@ -1,27 +1,14 @@
1
- declare namespace getSideChannel {
2
- type Key = unknown;
3
- type ListNode<T> = {
4
- key: Key;
5
- next: ListNode<T>;
6
- value: T;
7
- };
8
- type RootNode<T> = {
9
- key: object;
10
- next: null | ListNode<T>;
11
- };
12
- function listGetNode<T>(list: RootNode<T>, key: ListNode<T>['key']): ListNode<T> | void;
13
- function listGet<T>(objects: RootNode<T>, key: ListNode<T>['key']): T | void;
14
- function listSet<T>(objects: RootNode<T>, key: ListNode<T>['key'], value: T): void;
15
- function listHas<T>(objects: RootNode<T>, key: ListNode<T>['key']): boolean;
1
+ import getSideChannelList from 'side-channel-list';
2
+ import getSideChannelMap from 'side-channel-map';
3
+ import getSideChannelWeakMap from 'side-channel-weakmap';
16
4
 
17
- type Channel = {
18
- assert: (key: Key) => void;
19
- has: (key: Key) => boolean;
20
- get: <T>(key: Key) => T;
21
- set: <T>(key: Key, value: T) => void;
22
- }
5
+ declare namespace getSideChannel {
6
+ type Channel<K, V> =
7
+ | getSideChannelList.Channel<K, V>
8
+ | ReturnType<Exclude<typeof getSideChannelMap<K, V>, false>>
9
+ | ReturnType<Exclude<typeof getSideChannelWeakMap<K, V>, false>>;
23
10
  }
24
11
 
25
- declare function getSideChannel(): getSideChannel.Channel;
12
+ declare function getSideChannel<K, V>(): getSideChannel.Channel<K, V>;
26
13
 
27
14
  export = getSideChannel;
@@ -1,129 +1,43 @@
1
1
  'use strict';
2
2
 
3
- var GetIntrinsic = require('get-intrinsic');
4
- var callBound = require('call-bind/callBound');
5
- var inspect = require('object-inspect');
6
-
7
3
  var $TypeError = require('es-errors/type');
8
- var $WeakMap = GetIntrinsic('%WeakMap%', true);
9
- var $Map = GetIntrinsic('%Map%', true);
10
-
11
- var $weakMapGet = callBound('WeakMap.prototype.get', true);
12
- var $weakMapSet = callBound('WeakMap.prototype.set', true);
13
- var $weakMapHas = callBound('WeakMap.prototype.has', true);
14
- var $mapGet = callBound('Map.prototype.get', true);
15
- var $mapSet = callBound('Map.prototype.set', true);
16
- var $mapHas = callBound('Map.prototype.has', true);
4
+ var inspect = require('object-inspect');
5
+ var getSideChannelList = require('side-channel-list');
6
+ var getSideChannelMap = require('side-channel-map');
7
+ var getSideChannelWeakMap = require('side-channel-weakmap');
17
8
 
18
- /*
19
- * This function traverses the list returning the node corresponding to the given key.
20
- *
21
- * That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list. By doing so, all the recently used nodes can be accessed relatively quickly.
22
- */
23
- /** @type {import('.').listGetNode} */
24
- var listGetNode = function (list, key) { // eslint-disable-line consistent-return
25
- /** @type {typeof list | NonNullable<(typeof list)['next']>} */
26
- var prev = list;
27
- /** @type {(typeof list)['next']} */
28
- var curr;
29
- for (; (curr = prev.next) !== null; prev = curr) {
30
- if (curr.key === key) {
31
- prev.next = curr.next;
32
- // eslint-disable-next-line no-extra-parens
33
- curr.next = /** @type {NonNullable<typeof list.next>} */ (list.next);
34
- list.next = curr; // eslint-disable-line no-param-reassign
35
- return curr;
36
- }
37
- }
38
- };
39
-
40
- /** @type {import('.').listGet} */
41
- var listGet = function (objects, key) {
42
- var node = listGetNode(objects, key);
43
- return node && node.value;
44
- };
45
- /** @type {import('.').listSet} */
46
- var listSet = function (objects, key, value) {
47
- var node = listGetNode(objects, key);
48
- if (node) {
49
- node.value = value;
50
- } else {
51
- // Prepend the new node to the beginning of the list
52
- objects.next = /** @type {import('.').ListNode<typeof value>} */ ({ // eslint-disable-line no-param-reassign, no-extra-parens
53
- key: key,
54
- next: objects.next,
55
- value: value
56
- });
57
- }
58
- };
59
- /** @type {import('.').listHas} */
60
- var listHas = function (objects, key) {
61
- return !!listGetNode(objects, key);
62
- };
9
+ var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList;
63
10
 
64
11
  /** @type {import('.')} */
65
12
  module.exports = function getSideChannel() {
66
- /** @type {WeakMap<object, unknown>} */ var $wm;
67
- /** @type {Map<object, unknown>} */ var $m;
68
- /** @type {import('.').RootNode<unknown>} */ var $o;
13
+ /** @typedef {ReturnType<typeof getSideChannel>} Channel */
69
14
 
70
- /** @type {import('.').Channel} */
15
+ /** @type {Channel | undefined} */ var $channelData;
16
+
17
+ /** @type {Channel} */
71
18
  var channel = {
72
19
  assert: function (key) {
73
20
  if (!channel.has(key)) {
74
21
  throw new $TypeError('Side channel does not contain ' + inspect(key));
75
22
  }
76
23
  },
77
- get: function (key) { // eslint-disable-line consistent-return
78
- if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
79
- if ($wm) {
80
- return $weakMapGet($wm, key);
81
- }
82
- } else if ($Map) {
83
- if ($m) {
84
- return $mapGet($m, key);
85
- }
86
- } else {
87
- if ($o) { // eslint-disable-line no-lonely-if
88
- return listGet($o, key);
89
- }
90
- }
24
+ 'delete': function (key) {
25
+ return !!$channelData && $channelData['delete'](key);
26
+ },
27
+ get: function (key) {
28
+ return $channelData && $channelData.get(key);
91
29
  },
92
30
  has: function (key) {
93
- if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
94
- if ($wm) {
95
- return $weakMapHas($wm, key);
96
- }
97
- } else if ($Map) {
98
- if ($m) {
99
- return $mapHas($m, key);
100
- }
101
- } else {
102
- if ($o) { // eslint-disable-line no-lonely-if
103
- return listHas($o, key);
104
- }
105
- }
106
- return false;
31
+ return !!$channelData && $channelData.has(key);
107
32
  },
108
33
  set: function (key, value) {
109
- if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
110
- if (!$wm) {
111
- $wm = new $WeakMap();
112
- }
113
- $weakMapSet($wm, key, value);
114
- } else if ($Map) {
115
- if (!$m) {
116
- $m = new $Map();
117
- }
118
- $mapSet($m, key, value);
119
- } else {
120
- if (!$o) {
121
- // Initialize the linked list as an empty node, so that we don't have to special-case handling of the first node: we can always refer to it as (previous node).next, instead of something like (list).head
122
- $o = { key: {}, next: null };
123
- }
124
- listSet($o, key, value);
34
+ if (!$channelData) {
35
+ $channelData = makeChannel();
125
36
  }
37
+
38
+ $channelData.set(key, value);
126
39
  }
127
40
  };
41
+ // @ts-expect-error TODO: figure out why this is erroring
128
42
  return channel;
129
43
  };
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "side-channel",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "description": "Store information about any JS value in a side channel. Uses WeakMap if available.",
5
5
  "main": "index.js",
6
6
  "exports": {
7
- "./package.json": "./package.json",
8
- ".": "./index.js"
7
+ ".": "./index.js",
8
+ "./package.json": "./package.json"
9
9
  },
10
10
  "types": "./index.d.ts",
11
11
  "scripts": {
@@ -14,11 +14,11 @@
14
14
  "prepublish": "not-in-publish || npm run prepublishOnly",
15
15
  "prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
16
16
  "lint": "eslint --ext=js,mjs .",
17
- "postlint": "tsc -p .",
17
+ "postlint": "tsc -p . && attw -P",
18
18
  "pretest": "npm run lint",
19
19
  "tests-only": "nyc tape 'test/**/*.js'",
20
20
  "test": "npm run tests-only",
21
- "posttest": "aud --production",
21
+ "posttest": "npx npm@'>=10.2' audit --production",
22
22
  "version": "auto-changelog && git add CHANGELOG.md",
23
23
  "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
24
24
  },
@@ -42,29 +42,30 @@
42
42
  "url": "https://github.com/ljharb/side-channel/issues"
43
43
  },
44
44
  "homepage": "https://github.com/ljharb/side-channel#readme",
45
+ "dependencies": {
46
+ "es-errors": "^1.3.0",
47
+ "object-inspect": "^1.13.3",
48
+ "side-channel-list": "^1.0.0",
49
+ "side-channel-map": "^1.0.1",
50
+ "side-channel-weakmap": "^1.0.2"
51
+ },
45
52
  "devDependencies": {
46
- "@ljharb/eslint-config": "^21.1.0",
47
- "@types/call-bind": "^1.0.5",
48
- "@types/get-intrinsic": "^1.2.2",
49
- "@types/object-inspect": "^1.8.4",
50
- "@types/tape": "^5.6.4",
51
- "aud": "^2.0.4",
52
- "auto-changelog": "^2.4.0",
53
+ "@arethetypeswrong/cli": "^0.17.1",
54
+ "@ljharb/eslint-config": "^21.1.1",
55
+ "@ljharb/tsconfig": "^0.2.2",
56
+ "@types/object-inspect": "^1.13.0",
57
+ "@types/tape": "^5.6.5",
58
+ "auto-changelog": "^2.5.0",
53
59
  "eclint": "^2.8.1",
60
+ "encoding": "^0.1.13",
54
61
  "eslint": "=8.8.0",
55
62
  "in-publish": "^2.0.1",
56
63
  "npmignore": "^0.3.1",
57
64
  "nyc": "^10.3.2",
58
65
  "safe-publish-latest": "^2.0.0",
59
- "tape": "^5.7.5",
66
+ "tape": "^5.9.0",
60
67
  "typescript": "next"
61
68
  },
62
- "dependencies": {
63
- "call-bind": "^1.0.7",
64
- "es-errors": "^1.3.0",
65
- "get-intrinsic": "^1.2.4",
66
- "object-inspect": "^1.13.1"
67
- },
68
69
  "auto-changelog": {
69
70
  "output": "CHANGELOG.md",
70
71
  "template": "keepachangelog",
@@ -4,80 +4,101 @@ var test = require('tape');
4
4
 
5
5
  var getSideChannel = require('../');
6
6
 
7
- test('export', function (t) {
8
- t.equal(typeof getSideChannel, 'function', 'is a function');
9
- t.equal(getSideChannel.length, 0, 'takes no arguments');
7
+ test('getSideChannel', function (t) {
8
+ t.test('export', function (st) {
9
+ st.equal(typeof getSideChannel, 'function', 'is a function');
10
10
 
11
- var channel = getSideChannel();
12
- t.ok(channel, 'is truthy');
13
- t.equal(typeof channel, 'object', 'is an object');
11
+ st.equal(getSideChannel.length, 0, 'takes no arguments');
14
12
 
15
- t.end();
16
- });
13
+ var channel = getSideChannel();
14
+ st.ok(channel, 'is truthy');
15
+ st.equal(typeof channel, 'object', 'is an object');
16
+ st.end();
17
+ });
17
18
 
18
- test('assert', function (t) {
19
- var channel = getSideChannel();
20
- t['throws'](
21
- function () { channel.assert({}); },
22
- TypeError,
23
- 'nonexistent value throws'
24
- );
19
+ t.test('assert', function (st) {
20
+ var channel = getSideChannel();
21
+ st['throws'](
22
+ function () { channel.assert({}); },
23
+ TypeError,
24
+ 'nonexistent value throws'
25
+ );
25
26
 
26
- var o = {};
27
- channel.set(o, 'data');
28
- t.doesNotThrow(function () { channel.assert(o); }, 'existent value noops');
27
+ var o = {};
28
+ channel.set(o, 'data');
29
+ st.doesNotThrow(function () { channel.assert(o); }, 'existent value noops');
29
30
 
30
- t.end();
31
- });
31
+ st.end();
32
+ });
32
33
 
33
- test('has', function (t) {
34
- var channel = getSideChannel();
35
- /** @type {unknown[]} */ var o = [];
34
+ t.test('has', function (st) {
35
+ var channel = getSideChannel();
36
+ /** @type {unknown[]} */ var o = [];
36
37
 
37
- t.equal(channel.has(o), false, 'nonexistent value yields false');
38
+ st.equal(channel.has(o), false, 'nonexistent value yields false');
38
39
 
39
- channel.set(o, 'foo');
40
- t.equal(channel.has(o), true, 'existent value yields true');
40
+ channel.set(o, 'foo');
41
+ st.equal(channel.has(o), true, 'existent value yields true');
41
42
 
42
- t.equal(channel.has('abc'), false, 'non object value non existent yields false');
43
+ st.equal(channel.has('abc'), false, 'non object value non existent yields false');
43
44
 
44
- channel.set('abc', 'foo');
45
- t.equal(channel.has('abc'), true, 'non object value that exists yields true');
45
+ channel.set('abc', 'foo');
46
+ st.equal(channel.has('abc'), true, 'non object value that exists yields true');
46
47
 
47
- t.end();
48
- });
48
+ st.end();
49
+ });
49
50
 
50
- test('get', function (t) {
51
- var channel = getSideChannel();
52
- var o = {};
53
- t.equal(channel.get(o), undefined, 'nonexistent value yields undefined');
51
+ t.test('get', function (st) {
52
+ var channel = getSideChannel();
53
+ var o = {};
54
+ st.equal(channel.get(o), undefined, 'nonexistent value yields undefined');
54
55
 
55
- var data = {};
56
- channel.set(o, data);
57
- t.equal(channel.get(o), data, '"get" yields data set by "set"');
56
+ var data = {};
57
+ channel.set(o, data);
58
+ st.equal(channel.get(o), data, '"get" yields data set by "set"');
58
59
 
59
- t.end();
60
- });
60
+ st.end();
61
+ });
62
+
63
+ t.test('set', function (st) {
64
+ var channel = getSideChannel();
65
+ var o = function () {};
66
+ st.equal(channel.get(o), undefined, 'value not set');
67
+
68
+ channel.set(o, 42);
69
+ st.equal(channel.get(o), 42, 'value was set');
70
+
71
+ channel.set(o, Infinity);
72
+ st.equal(channel.get(o), Infinity, 'value was set again');
73
+
74
+ var o2 = {};
75
+ channel.set(o2, 17);
76
+ st.equal(channel.get(o), Infinity, 'o is not modified');
77
+ st.equal(channel.get(o2), 17, 'o2 is set');
78
+
79
+ channel.set(o, 14);
80
+ st.equal(channel.get(o), 14, 'o is modified');
81
+ st.equal(channel.get(o2), 17, 'o2 is not modified');
82
+
83
+ st.end();
84
+ });
85
+
86
+ t.test('delete', function (st) {
87
+ var channel = getSideChannel();
88
+ var o = {};
89
+ st.equal(channel['delete']({}), false, 'nonexistent value yields false');
61
90
 
62
- test('set', function (t) {
63
- var channel = getSideChannel();
64
- var o = function () {};
65
- t.equal(channel.get(o), undefined, 'value not set');
91
+ channel.set(o, 42);
92
+ st.equal(channel.has(o), true, 'value is set');
66
93
 
67
- channel.set(o, 42);
68
- t.equal(channel.get(o), 42, 'value was set');
94
+ st.equal(channel['delete']({}), false, 'nonexistent value still yields false');
69
95
 
70
- channel.set(o, Infinity);
71
- t.equal(channel.get(o), Infinity, 'value was set again');
96
+ st.equal(channel['delete'](o), true, 'deleted value yields true');
72
97
 
73
- var o2 = {};
74
- channel.set(o2, 17);
75
- t.equal(channel.get(o), Infinity, 'o is not modified');
76
- t.equal(channel.get(o2), 17, 'o2 is set');
98
+ st.equal(channel.has(o), false, 'value is no longer set');
77
99
 
78
- channel.set(o, 14);
79
- t.equal(channel.get(o), 14, 'o is modified');
80
- t.equal(channel.get(o2), 17, 'o2 is not modified');
100
+ st.end();
101
+ });
81
102
 
82
103
  t.end();
83
104
  });