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
@@ -0,0 +1,53 @@
1
+ # call-bound <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
+
3
+ [![github actions][actions-image]][actions-url]
4
+ [![coverage][codecov-image]][codecov-url]
5
+ [![dependency status][deps-svg]][deps-url]
6
+ [![dev dependency status][dev-deps-svg]][dev-deps-url]
7
+ [![License][license-image]][license-url]
8
+ [![Downloads][downloads-image]][downloads-url]
9
+
10
+ [![npm badge][npm-badge-png]][package-url]
11
+
12
+ Robust call-bound JavaScript intrinsics, using `call-bind` and `get-intrinsic`.
13
+
14
+ ## Getting started
15
+
16
+ ```sh
17
+ npm install --save call-bound
18
+ ```
19
+
20
+ ## Usage/Examples
21
+
22
+ ```js
23
+ const assert = require('assert');
24
+ const callBound = require('call-bound');
25
+
26
+ const slice = callBound('Array.prototype.slice');
27
+
28
+ delete Function.prototype.call;
29
+ delete Function.prototype.bind;
30
+ delete Array.prototype.slice;
31
+
32
+ assert.deepEqual(slice([1, 2, 3, 4], 1, -1), [2, 3]);
33
+ ```
34
+
35
+ ## Tests
36
+
37
+ Clone the repo, `npm install`, and run `npm test`
38
+
39
+ [package-url]: https://npmjs.org/package/call-bound
40
+ [npm-version-svg]: https://versionbadg.es/ljharb/call-bound.svg
41
+ [deps-svg]: https://david-dm.org/ljharb/call-bound.svg
42
+ [deps-url]: https://david-dm.org/ljharb/call-bound
43
+ [dev-deps-svg]: https://david-dm.org/ljharb/call-bound/dev-status.svg
44
+ [dev-deps-url]: https://david-dm.org/ljharb/call-bound#info=devDependencies
45
+ [npm-badge-png]: https://nodei.co/npm/call-bound.png?downloads=true&stars=true
46
+ [license-image]: https://img.shields.io/npm/l/call-bound.svg
47
+ [license-url]: LICENSE
48
+ [downloads-image]: https://img.shields.io/npm/dm/call-bound.svg
49
+ [downloads-url]: https://npm-stat.com/charts.html?package=call-bound
50
+ [codecov-image]: https://codecov.io/gh/ljharb/call-bound/branch/main/graphs/badge.svg
51
+ [codecov-url]: https://app.codecov.io/gh/ljharb/call-bound/
52
+ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/call-bound
53
+ [actions-url]: https://github.com/ljharb/call-bound/actions
@@ -0,0 +1,94 @@
1
+ type Intrinsic = typeof globalThis;
2
+
3
+ type IntrinsicName = keyof Intrinsic | `%${keyof Intrinsic}%`;
4
+
5
+ type IntrinsicPath = IntrinsicName | `${StripPercents<IntrinsicName>}.${string}` | `%${StripPercents<IntrinsicName>}.${string}%`;
6
+
7
+ type AllowMissing = boolean;
8
+
9
+ type StripPercents<T extends string> = T extends `%${infer U}%` ? U : T;
10
+
11
+ type BindMethodPrecise<F> =
12
+ F extends (this: infer This, ...args: infer Args) => infer R
13
+ ? (obj: This, ...args: Args) => R
14
+ : F extends {
15
+ (this: infer This1, ...args: infer Args1): infer R1;
16
+ (this: infer This2, ...args: infer Args2): infer R2
17
+ }
18
+ ? {
19
+ (obj: This1, ...args: Args1): R1;
20
+ (obj: This2, ...args: Args2): R2
21
+ }
22
+ : never
23
+
24
+ // Extract method type from a prototype
25
+ type GetPrototypeMethod<T extends keyof typeof globalThis, M extends string> =
26
+ (typeof globalThis)[T] extends { prototype: any }
27
+ ? M extends keyof (typeof globalThis)[T]['prototype']
28
+ ? (typeof globalThis)[T]['prototype'][M]
29
+ : never
30
+ : never
31
+
32
+ // Get static property/method
33
+ type GetStaticMember<T extends keyof typeof globalThis, P extends string> =
34
+ P extends keyof (typeof globalThis)[T] ? (typeof globalThis)[T][P] : never
35
+
36
+ // Type that maps string path to actual bound function or value with better precision
37
+ type BoundIntrinsic<S extends string> =
38
+ S extends `${infer Obj}.prototype.${infer Method}`
39
+ ? Obj extends keyof typeof globalThis
40
+ ? BindMethodPrecise<GetPrototypeMethod<Obj, Method & string>>
41
+ : unknown
42
+ : S extends `${infer Obj}.${infer Prop}`
43
+ ? Obj extends keyof typeof globalThis
44
+ ? GetStaticMember<Obj, Prop & string>
45
+ : unknown
46
+ : unknown
47
+
48
+ declare function arraySlice<T>(array: readonly T[], start?: number, end?: number): T[];
49
+ declare function arraySlice<T>(array: ArrayLike<T>, start?: number, end?: number): T[];
50
+ declare function arraySlice<T>(array: IArguments, start?: number, end?: number): T[];
51
+
52
+ // Special cases for methods that need explicit typing
53
+ interface SpecialCases {
54
+ '%Object.prototype.isPrototypeOf%': (thisArg: {}, obj: unknown) => boolean;
55
+ '%String.prototype.replace%': {
56
+ (str: string, searchValue: string | RegExp, replaceValue: string): string;
57
+ (str: string, searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string
58
+ };
59
+ '%Object.prototype.toString%': (obj: {}) => string;
60
+ '%Object.prototype.hasOwnProperty%': (obj: {}, v: PropertyKey) => boolean;
61
+ '%Array.prototype.slice%': typeof arraySlice;
62
+ '%Array.prototype.map%': <T, U>(array: readonly T[], callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any) => U[];
63
+ '%Array.prototype.filter%': <T>(array: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any) => T[];
64
+ '%Array.prototype.indexOf%': <T>(array: readonly T[], searchElement: T, fromIndex?: number) => number;
65
+ '%Function.prototype.apply%': <T, A extends any[], R>(fn: (...args: A) => R, thisArg: any, args: A) => R;
66
+ '%Function.prototype.call%': <T, A extends any[], R>(fn: (...args: A) => R, thisArg: any, ...args: A) => R;
67
+ '%Function.prototype.bind%': <T, A extends any[], R>(fn: (...args: A) => R, thisArg: any, ...args: A) => (...remainingArgs: A) => R;
68
+ '%Promise.prototype.then%': {
69
+ <T, R>(promise: Promise<T>, onfulfilled: (value: T) => R | PromiseLike<R>): Promise<R>;
70
+ <T, R>(promise: Promise<T>, onfulfilled: ((value: T) => R | PromiseLike<R>) | undefined | null, onrejected: (reason: any) => R | PromiseLike<R>): Promise<R>;
71
+ };
72
+ '%RegExp.prototype.test%': (regexp: RegExp, str: string) => boolean;
73
+ '%RegExp.prototype.exec%': (regexp: RegExp, str: string) => RegExpExecArray | null;
74
+ '%Error.prototype.toString%': (error: Error) => string;
75
+ '%TypeError.prototype.toString%': (error: TypeError) => string;
76
+ '%String.prototype.split%': (
77
+ obj: unknown,
78
+ splitter: string | RegExp | {
79
+ [Symbol.split](string: string, limit?: number): string[];
80
+ },
81
+ limit?: number | undefined
82
+ ) => string[];
83
+ }
84
+
85
+ /**
86
+ * Returns a bound function for a prototype method, or a value for a static property.
87
+ *
88
+ * @param name - The name of the intrinsic (e.g. 'Array.prototype.slice')
89
+ * @param {AllowMissing} [allowMissing] - Whether to allow missing intrinsics (default: false)
90
+ */
91
+ declare function callBound<K extends keyof SpecialCases | StripPercents<keyof SpecialCases>, S extends IntrinsicPath>(name: K, allowMissing?: AllowMissing): SpecialCases[`%${StripPercents<K>}%`];
92
+ declare function callBound<K extends keyof SpecialCases | StripPercents<keyof SpecialCases>, S extends IntrinsicPath>(name: S, allowMissing?: AllowMissing): BoundIntrinsic<S>;
93
+
94
+ export = callBound;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var GetIntrinsic = require('get-intrinsic');
4
+
5
+ var callBindBasic = require('call-bind-apply-helpers');
6
+
7
+ /** @type {(thisArg: string, searchString: string, position?: number) => number} */
8
+ var $indexOf = callBindBasic([GetIntrinsic('%String.prototype.indexOf%')]);
9
+
10
+ /** @type {import('.')} */
11
+ module.exports = function callBoundIntrinsic(name, allowMissing) {
12
+ /* eslint no-extra-parens: 0 */
13
+
14
+ var intrinsic = /** @type {(this: unknown, ...args: unknown[]) => unknown} */ (GetIntrinsic(name, !!allowMissing));
15
+ if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
16
+ return callBindBasic(/** @type {const} */ ([intrinsic]));
17
+ }
18
+ return intrinsic;
19
+ };
@@ -1,29 +1,30 @@
1
1
  {
2
- "name": "call-bind",
3
- "version": "1.0.7",
4
- "description": "Robustly `.call.bind()` a function",
2
+ "name": "call-bound",
3
+ "version": "1.0.4",
4
+ "description": "Robust call-bound JavaScript intrinsics, using `call-bind` and `get-intrinsic`.",
5
5
  "main": "index.js",
6
6
  "exports": {
7
7
  ".": "./index.js",
8
- "./callBound": "./callBound.js",
9
8
  "./package.json": "./package.json"
10
9
  },
10
+ "sideEffects": false,
11
11
  "scripts": {
12
12
  "prepack": "npmignore --auto --commentLines=auto",
13
13
  "prepublish": "not-in-publish || npm run prepublishOnly",
14
14
  "prepublishOnly": "safe-publish-latest",
15
+ "prelint": "evalmd README.md",
15
16
  "lint": "eslint --ext=.js,.mjs .",
16
- "postlint": "evalmd README.md",
17
+ "postlint": "tsc -p . && attw -P",
17
18
  "pretest": "npm run lint",
18
19
  "tests-only": "nyc tape 'test/**/*.js'",
19
20
  "test": "npm run tests-only",
20
- "posttest": "aud --production",
21
+ "posttest": "npx npm@'>=10.2' audit --production",
21
22
  "version": "auto-changelog && git add CHANGELOG.md",
22
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)\")\""
23
24
  },
24
25
  "repository": {
25
26
  "type": "git",
26
- "url": "git+https://github.com/ljharb/call-bind.git"
27
+ "url": "git+https://github.com/ljharb/call-bound.git"
27
28
  },
28
29
  "keywords": [
29
30
  "javascript",
@@ -46,32 +47,35 @@
46
47
  },
47
48
  "license": "MIT",
48
49
  "bugs": {
49
- "url": "https://github.com/ljharb/call-bind/issues"
50
+ "url": "https://github.com/ljharb/call-bound/issues"
51
+ },
52
+ "homepage": "https://github.com/ljharb/call-bound#readme",
53
+ "dependencies": {
54
+ "call-bind-apply-helpers": "^1.0.2",
55
+ "get-intrinsic": "^1.3.0"
50
56
  },
51
- "homepage": "https://github.com/ljharb/call-bind#readme",
52
57
  "devDependencies": {
53
- "@ljharb/eslint-config": "^21.1.0",
54
- "aud": "^2.0.4",
55
- "auto-changelog": "^2.4.0",
56
- "es-value-fixtures": "^1.4.2",
58
+ "@arethetypeswrong/cli": "^0.17.4",
59
+ "@ljharb/eslint-config": "^21.1.1",
60
+ "@ljharb/tsconfig": "^0.3.0",
61
+ "@types/call-bind": "^1.0.5",
62
+ "@types/get-intrinsic": "^1.2.3",
63
+ "@types/tape": "^5.8.1",
64
+ "auto-changelog": "^2.5.0",
65
+ "encoding": "^0.1.13",
66
+ "es-value-fixtures": "^1.7.1",
57
67
  "eslint": "=8.8.0",
58
68
  "evalmd": "^0.0.19",
59
- "for-each": "^0.3.3",
60
- "gopd": "^1.0.1",
61
- "has-strict-mode": "^1.0.1",
69
+ "for-each": "^0.3.5",
70
+ "gopd": "^1.2.0",
71
+ "has-strict-mode": "^1.1.0",
62
72
  "in-publish": "^2.0.1",
63
73
  "npmignore": "^0.3.1",
64
74
  "nyc": "^10.3.2",
65
- "object-inspect": "^1.13.1",
75
+ "object-inspect": "^1.13.4",
66
76
  "safe-publish-latest": "^2.0.0",
67
- "tape": "^5.7.4"
68
- },
69
- "dependencies": {
70
- "es-define-property": "^1.0.0",
71
- "es-errors": "^1.3.0",
72
- "function-bind": "^1.1.2",
73
- "get-intrinsic": "^1.2.4",
74
- "set-function-length": "^1.2.1"
77
+ "tape": "^5.9.0",
78
+ "typescript": "next"
75
79
  },
76
80
  "testling": {
77
81
  "files": "test/index.js"
@@ -2,7 +2,9 @@
2
2
 
3
3
  var test = require('tape');
4
4
 
5
- var callBound = require('../callBound');
5
+ var callBound = require('../');
6
+
7
+ /** @template {true} T @template U @typedef {T extends U ? T : never} AssertType */
6
8
 
7
9
  test('callBound', function (t) {
8
10
  // static primitive
@@ -23,18 +25,23 @@ test('callBound', function (t) {
23
25
  t.equal(callBound('Error.prototype.message'), Error.prototype.message, 'Error.prototype.message yields itself');
24
26
  t.equal(callBound('%Error.prototype.message%'), Error.prototype.message, '%Error.prototype.message% yields itself');
25
27
 
28
+ var x = callBound('Object.prototype.toString');
29
+ var y = callBound('%Object.prototype.toString%');
30
+
26
31
  // prototype function
27
- t.notEqual(callBound('Object.prototype.toString'), Object.prototype.toString, 'Object.prototype.toString does not yield itself');
28
- t.notEqual(callBound('%Object.prototype.toString%'), Object.prototype.toString, '%Object.prototype.toString% does not yield itself');
29
- t.equal(callBound('Object.prototype.toString')(true), Object.prototype.toString.call(true), 'call-bound Object.prototype.toString calls into the original');
30
- t.equal(callBound('%Object.prototype.toString%')(true), Object.prototype.toString.call(true), 'call-bound %Object.prototype.toString% calls into the original');
32
+ t.notEqual(x, Object.prototype.toString, 'Object.prototype.toString does not yield itself');
33
+ t.notEqual(y, Object.prototype.toString, '%Object.prototype.toString% does not yield itself');
34
+ t.equal(x(true), Object.prototype.toString.call(true), 'call-bound Object.prototype.toString calls into the original');
35
+ t.equal(y(true), Object.prototype.toString.call(true), 'call-bound %Object.prototype.toString% calls into the original');
31
36
 
32
37
  t['throws'](
38
+ // @ts-expect-error
33
39
  function () { callBound('does not exist'); },
34
40
  SyntaxError,
35
41
  'nonexistent intrinsic throws'
36
42
  );
37
43
  t['throws'](
44
+ // @ts-expect-error
38
45
  function () { callBound('does not exist', true); },
39
46
  SyntaxError,
40
47
  'allowMissing arg still throws for unknown intrinsic'
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@ljharb/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ESNext",
5
+ "lib": ["es2024"],
6
+ },
7
+ "exclude": [
8
+ "coverage",
9
+ ],
10
+ }
@@ -1,5 +1,13 @@
1
+ 1.8.0 / 2025-02-10
2
+ ==================
3
+
4
+ * Use `res.headersSent` when available
5
+ * Replace `_implicitHeader` with `writeHead` property
6
+ * add brotli support for versions of node that support it
7
+ * Add the enforceEncoding option for requests without `Accept-Encoding` header
8
+
1
9
  1.7.5 / 2024-10-31
2
- ==========
10
+ ==================
3
11
 
4
12
  * deps: Replace accepts with negotiator@~0.6.4
5
13
  - Add preference option
@@ -3,7 +3,9 @@
3
3
  [![NPM Version][npm-image]][npm-url]
4
4
  [![NPM Downloads][downloads-image]][downloads-url]
5
5
  [![Build Status][github-actions-ci-image]][github-actions-ci-url]
6
- [![Test Coverage][coveralls-image]][coveralls-url]
6
+ [![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]
7
+ [![Funding][funding-image]][funding-url]
8
+
7
9
 
8
10
  Node.js compression middleware.
9
11
 
@@ -11,6 +13,9 @@ The following compression codings are supported:
11
13
 
12
14
  - deflate
13
15
  - gzip
16
+ - br (brotli)
17
+
18
+ **Note** Brotli is supported only since Node.js versions v11.7.0 and v10.16.0.
14
19
 
15
20
  ## Install
16
21
 
@@ -42,17 +47,21 @@ as compressing will transform the body.
42
47
 
43
48
  `compression()` accepts these properties in the options object. In addition to
44
49
  those listed below, [zlib](http://nodejs.org/api/zlib.html) options may be
45
- passed in to the options object.
50
+ passed in to the options object or
51
+ [brotli](https://nodejs.org/api/zlib.html#zlib_class_brotlioptions) options.
46
52
 
47
53
  ##### chunkSize
48
54
 
49
- The default value is `zlib.Z_DEFAULT_CHUNK`, or `16384`.
55
+ Type: `Number`<br>
56
+ Default: `zlib.constants.Z_DEFAULT_CHUNK`, or `16384`.
50
57
 
51
58
  See [Node.js documentation](http://nodejs.org/api/zlib.html#zlib_memory_usage_tuning)
52
59
  regarding the usage.
53
60
 
54
61
  ##### filter
55
62
 
63
+ Type: `Function`
64
+
56
65
  A function to decide if the response should be considered for compression.
57
66
  This function is called as `filter(req, res)` and is expected to return
58
67
  `true` to consider the response for compression, or `false` to not compress
@@ -63,6 +72,9 @@ module to determine if `res.getHeader('Content-Type')` is compressible.
63
72
 
64
73
  ##### level
65
74
 
75
+ Type: `Number`<br>
76
+ Default: `zlib.constants.Z_DEFAULT_COMPRESSION`, or `-1`
77
+
66
78
  The level of zlib compression to apply to responses. A higher level will result
67
79
  in better compression, but will take longer to complete. A lower level will
68
80
  result in less compression, but will be much faster.
@@ -72,59 +84,71 @@ compression). The special value `-1` can be used to mean the "default
72
84
  compression level", which is a default compromise between speed and
73
85
  compression (currently equivalent to level 6).
74
86
 
75
- - `-1` Default compression level (also `zlib.Z_DEFAULT_COMPRESSION`).
76
- - `0` No compression (also `zlib.Z_NO_COMPRESSION`).
77
- - `1` Fastest compression (also `zlib.Z_BEST_SPEED`).
87
+ - `-1` Default compression level (also `zlib.constants.Z_DEFAULT_COMPRESSION`).
88
+ - `0` No compression (also `zlib.constants.Z_NO_COMPRESSION`).
89
+ - `1` Fastest compression (also `zlib.constants.Z_BEST_SPEED`).
78
90
  - `2`
79
91
  - `3`
80
92
  - `4`
81
93
  - `5`
82
- - `6` (currently what `zlib.Z_DEFAULT_COMPRESSION` points to).
94
+ - `6` (currently what `zlib.constants.Z_DEFAULT_COMPRESSION` points to).
83
95
  - `7`
84
96
  - `8`
85
- - `9` Best compression (also `zlib.Z_BEST_COMPRESSION`).
86
-
87
- The default value is `zlib.Z_DEFAULT_COMPRESSION`, or `-1`.
97
+ - `9` Best compression (also `zlib.constants.Z_BEST_COMPRESSION`).
88
98
 
89
99
  **Note** in the list above, `zlib` is from `zlib = require('zlib')`.
90
100
 
91
101
  ##### memLevel
92
102
 
103
+ Type: `Number`<br>
104
+ Default: `zlib.constants.Z_DEFAULT_MEMLEVEL`, or `8`
105
+
93
106
  This specifies how much memory should be allocated for the internal compression
94
107
  state and is an integer in the range of `1` (minimum level) and `9` (maximum
95
108
  level).
96
109
 
97
- The default value is `zlib.Z_DEFAULT_MEMLEVEL`, or `8`.
98
-
99
110
  See [Node.js documentation](http://nodejs.org/api/zlib.html#zlib_memory_usage_tuning)
100
111
  regarding the usage.
101
112
 
113
+ ##### brotli
114
+
115
+ Type: `Object`
116
+
117
+ This specifies the options for configuring Brotli. See [Node.js documentation](https://nodejs.org/api/zlib.html#class-brotlioptions) for a complete list of available options.
118
+
119
+
102
120
  ##### strategy
103
121
 
122
+ Type: `Number`<br>
123
+ Default: `zlib.constants.Z_DEFAULT_STRATEGY`
124
+
104
125
  This is used to tune the compression algorithm. This value only affects the
105
126
  compression ratio, not the correctness of the compressed output, even if it
106
127
  is not set appropriately.
107
128
 
108
- - `zlib.Z_DEFAULT_STRATEGY` Use for normal data.
109
- - `zlib.Z_FILTERED` Use for data produced by a filter (or predictor).
129
+ - `zlib.constants.Z_DEFAULT_STRATEGY` Use for normal data.
130
+ - `zlib.constants.Z_FILTERED` Use for data produced by a filter (or predictor).
110
131
  Filtered data consists mostly of small values with a somewhat random
111
132
  distribution. In this case, the compression algorithm is tuned to
112
133
  compress them better. The effect is to force more Huffman coding and less
113
- string matching; it is somewhat intermediate between `zlib.Z_DEFAULT_STRATEGY`
114
- and `zlib.Z_HUFFMAN_ONLY`.
115
- - `zlib.Z_FIXED` Use to prevent the use of dynamic Huffman codes, allowing
134
+ string matching; it is somewhat intermediate between `zlib.constants.Z_DEFAULT_STRATEGY`
135
+ and `zlib.constants.Z_HUFFMAN_ONLY`.
136
+ - `zlib.constants.Z_FIXED` Use to prevent the use of dynamic Huffman codes, allowing
116
137
  for a simpler decoder for special applications.
117
- - `zlib.Z_HUFFMAN_ONLY` Use to force Huffman encoding only (no string match).
118
- - `zlib.Z_RLE` Use to limit match distances to one (run-length encoding).
119
- This is designed to be almost as fast as `zlib.Z_HUFFMAN_ONLY`, but give
138
+ - `zlib.constants.Z_HUFFMAN_ONLY` Use to force Huffman encoding only (no string match).
139
+ - `zlib.constants.Z_RLE` Use to limit match distances to one (run-length encoding).
140
+ This is designed to be almost as fast as `zlib.constants.Z_HUFFMAN_ONLY`, but give
120
141
  better compression for PNG image data.
121
142
 
122
143
  **Note** in the list above, `zlib` is from `zlib = require('zlib')`.
123
144
 
124
145
  ##### threshold
125
146
 
147
+ Type: `Number` or `String`<br>
148
+ Default: `1kb`
149
+
126
150
  The byte threshold for the response body size before compression is considered
127
- for the response, defaults to `1kb`. This is a number of bytes or any string
151
+ for the response. This is a number of bytes or any string
128
152
  accepted by the [bytes](https://www.npmjs.com/package/bytes) module.
129
153
 
130
154
  **Note** this is only an advisory setting; if the response size cannot be determined
@@ -134,11 +158,19 @@ set a `Content-Length` response header.
134
158
 
135
159
  ##### windowBits
136
160
 
137
- The default value is `zlib.Z_DEFAULT_WINDOWBITS`, or `15`.
161
+ Type: `Number`<br>
162
+ Default: `zlib.constants.Z_DEFAULT_WINDOWBITS`, or `15`
138
163
 
139
164
  See [Node.js documentation](http://nodejs.org/api/zlib.html#zlib_memory_usage_tuning)
140
165
  regarding the usage.
141
166
 
167
+ ##### enforceEncoding
168
+
169
+ Type: `String`<br>
170
+ Default: `identity`
171
+
172
+ This is the default encoding to use when the client does not specify an encoding in the request's [Accept-Encoding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) header.
173
+
142
174
  #### .filter
143
175
 
144
176
  The default `filter` function. This is used to construct a custom filter
@@ -149,6 +181,7 @@ var compression = require('compression')
149
181
  var express = require('express')
150
182
 
151
183
  var app = express()
184
+
152
185
  app.use(compression({ filter: shouldCompress }))
153
186
 
154
187
  function shouldCompress (req, res) {
@@ -169,9 +202,9 @@ response to be flushed to the client.
169
202
 
170
203
  ## Examples
171
204
 
172
- ### express/connect
205
+ ### express
173
206
 
174
- When using this module with express or connect, simply `app.use` the module as
207
+ When using this module with express, simply `app.use` the module as
175
208
  high as you like. Requests that pass through the middleware will be compressed.
176
209
 
177
210
  ```js
@@ -186,6 +219,36 @@ app.use(compression())
186
219
  // add all routes
187
220
  ```
188
221
 
222
+ ### Node.js HTTP server
223
+
224
+ ```js
225
+ var compression = require('compression')({ threshold: 0 })
226
+ var http = require('http')
227
+
228
+ function createServer (fn) {
229
+ return http.createServer(function (req, res) {
230
+ compression(req, res, function (err) {
231
+ if (err) {
232
+ res.statusCode = err.status || 500
233
+ res.end(err.message)
234
+ return
235
+ }
236
+
237
+ fn(req, res)
238
+ })
239
+ })
240
+ }
241
+
242
+ var server = createServer(function (req, res) {
243
+ res.setHeader('Content-Type', 'text/plain')
244
+ res.end('hello world!')
245
+ })
246
+
247
+ server.listen(3000, () => {
248
+ console.log('> Listening at http://localhost:3000')
249
+ })
250
+ ```
251
+
189
252
  ### Server-Sent Events
190
253
 
191
254
  Because of the nature of compression this module does not work out of the box
@@ -224,15 +287,25 @@ app.get('/events', function (req, res) {
224
287
  })
225
288
  ```
226
289
 
290
+ ## Contributing
291
+
292
+ The Express.js project welcomes all constructive contributions. Contributions take many forms,
293
+ from code for bug fixes and enhancements, to additions and fixes to documentation, additional
294
+ tests, triaging incoming pull requests and issues, and more!
295
+
296
+ See the [Contributing Guide](https://github.com/expressjs/express/blob/master/Contributing.md) for more technical details on contributing.
297
+
227
298
  ## License
228
299
 
229
300
  [MIT](LICENSE)
230
301
 
231
- [npm-image]: https://img.shields.io/npm/v/compression.svg
302
+ [npm-image]: https://badgen.net/npm/v/compression
232
303
  [npm-url]: https://npmjs.org/package/compression
233
- [coveralls-image]: https://img.shields.io/coveralls/expressjs/compression/master.svg
234
- [coveralls-url]: https://coveralls.io/r/expressjs/compression?branch=master
235
- [downloads-image]: https://img.shields.io/npm/dm/compression.svg
236
- [downloads-url]: https://npmjs.org/package/compression
237
- [github-actions-ci-image]: https://badgen.net/github/checks/expressjs/compression/master?label=ci
304
+ [downloads-image]: https://badgen.net/npm/dm/compression
305
+ [downloads-url]: https://npmcharts.com/compare/compression?minimal=true
306
+ [github-actions-ci-image]: https://badgen.net/github/checks/expressjs/compression/master?label=CI
238
307
  [github-actions-ci-url]: https://github.com/expressjs/compression/actions?query=workflow%3Aci
308
+ [ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/compression/badge
309
+ [ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/compression
310
+ [funding-url]: https://opencollective.com/express
311
+ [funding-image]: https://badgen.net/badge/icon/sponsor/pink?icon=github&label=Open%20Collective