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,87 @@
1
+ {
2
+ "name": "side-channel-weakmap",
3
+ "version": "1.0.2",
4
+ "description": "Store information about any JS value in a side channel. Uses WeakMap if available.",
5
+ "main": "index.js",
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./package.json": "./package.json"
9
+ },
10
+ "types": "./index.d.ts",
11
+ "scripts": {
12
+ "prepack": "npmignore --auto --commentLines=autogenerated",
13
+ "prepublishOnly": "safe-publish-latest",
14
+ "prepublish": "not-in-publish || npm run prepublishOnly",
15
+ "prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
16
+ "lint": "eslint --ext=js,mjs .",
17
+ "postlint": "tsc -p . && attw -P",
18
+ "pretest": "npm run lint",
19
+ "tests-only": "nyc tape 'test/**/*.js'",
20
+ "test": "npm run tests-only",
21
+ "posttest": "npx npm@'>=10.2' audit --production",
22
+ "version": "auto-changelog && git add CHANGELOG.md",
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
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/ljharb/side-channel-weakmap.git"
28
+ },
29
+ "keywords": [
30
+ "weakmap",
31
+ "map",
32
+ "side",
33
+ "channel",
34
+ "metadata"
35
+ ],
36
+ "author": "Jordan Harband <ljharb@gmail.com>",
37
+ "funding": {
38
+ "url": "https://github.com/sponsors/ljharb"
39
+ },
40
+ "license": "MIT",
41
+ "bugs": {
42
+ "url": "https://github.com/ljharb/side-channel-weakmap/issues"
43
+ },
44
+ "homepage": "https://github.com/ljharb/side-channel-weakmap#readme",
45
+ "dependencies": {
46
+ "call-bound": "^1.0.2",
47
+ "es-errors": "^1.3.0",
48
+ "get-intrinsic": "^1.2.5",
49
+ "object-inspect": "^1.13.3",
50
+ "side-channel-map": "^1.0.1"
51
+ },
52
+ "devDependencies": {
53
+ "@arethetypeswrong/cli": "^0.17.1",
54
+ "@ljharb/eslint-config": "^21.1.1",
55
+ "@ljharb/tsconfig": "^0.2.2",
56
+ "@types/call-bind": "^1.0.5",
57
+ "@types/get-intrinsic": "^1.2.3",
58
+ "@types/object-inspect": "^1.13.0",
59
+ "@types/tape": "^5.6.5",
60
+ "auto-changelog": "^2.5.0",
61
+ "eclint": "^2.8.1",
62
+ "encoding": "^0.1.13",
63
+ "eslint": "=8.8.0",
64
+ "in-publish": "^2.0.1",
65
+ "npmignore": "^0.3.1",
66
+ "nyc": "^10.3.2",
67
+ "safe-publish-latest": "^2.0.0",
68
+ "tape": "^5.9.0",
69
+ "typescript": "next"
70
+ },
71
+ "auto-changelog": {
72
+ "output": "CHANGELOG.md",
73
+ "template": "keepachangelog",
74
+ "unreleased": false,
75
+ "commitLimit": false,
76
+ "backfillLimit": false,
77
+ "hideCredit": true
78
+ },
79
+ "publishConfig": {
80
+ "ignore": [
81
+ ".github/workflows"
82
+ ]
83
+ },
84
+ "engines": {
85
+ "node": ">= 0.4"
86
+ }
87
+ }
@@ -0,0 +1,114 @@
1
+ 'use strict';
2
+
3
+ var test = require('tape');
4
+
5
+ var getSideChannelWeakMap = require('../');
6
+
7
+ test('getSideChannelMap', { skip: typeof WeakMap !== 'function' && typeof Map !== 'function' }, function (t) {
8
+ var getSideChannel = getSideChannelWeakMap || function () {
9
+ throw new EvalError('should never happen');
10
+ };
11
+
12
+ t.test('export', function (st) {
13
+ st.equal(typeof getSideChannel, 'function', 'is a function');
14
+
15
+ st.equal(getSideChannel.length, 0, 'takes no arguments');
16
+
17
+ var channel = getSideChannel();
18
+ st.ok(channel, 'is truthy');
19
+ st.equal(typeof channel, 'object', 'is an object');
20
+ st.end();
21
+ });
22
+
23
+ t.test('assert', function (st) {
24
+ var channel = getSideChannel();
25
+ st['throws'](
26
+ function () { channel.assert({}); },
27
+ TypeError,
28
+ 'nonexistent value throws'
29
+ );
30
+
31
+ var o = {};
32
+ channel.set(o, 'data');
33
+ st.doesNotThrow(function () { channel.assert(o); }, 'existent value noops');
34
+
35
+ st.end();
36
+ });
37
+
38
+ t.test('has', function (st) {
39
+ var channel = getSideChannel();
40
+ /** @type {unknown[]} */ var o = [];
41
+
42
+ st.equal(channel.has(o), false, 'nonexistent value yields false');
43
+
44
+ channel.set(o, 'foo');
45
+ st.equal(channel.has(o), true, 'existent value yields true');
46
+
47
+ st.equal(channel.has('abc'), false, 'non object value non existent yields false');
48
+
49
+ channel.set('abc', 'foo');
50
+ st.equal(channel.has('abc'), true, 'non object value that exists yields true');
51
+
52
+ st.end();
53
+ });
54
+
55
+ t.test('get', function (st) {
56
+ var channel = getSideChannel();
57
+ var o = {};
58
+ st.equal(channel.get(o), undefined, 'nonexistent value yields undefined');
59
+
60
+ var data = {};
61
+ channel.set(o, data);
62
+ st.equal(channel.get(o), data, '"get" yields data set by "set"');
63
+
64
+ st.end();
65
+ });
66
+
67
+ t.test('set', function (st) {
68
+ var channel = getSideChannel();
69
+ var o = function () {};
70
+ st.equal(channel.get(o), undefined, 'value not set');
71
+
72
+ channel.set(o, 42);
73
+ st.equal(channel.get(o), 42, 'value was set');
74
+
75
+ channel.set(o, Infinity);
76
+ st.equal(channel.get(o), Infinity, 'value was set again');
77
+
78
+ var o2 = {};
79
+ channel.set(o2, 17);
80
+ st.equal(channel.get(o), Infinity, 'o is not modified');
81
+ st.equal(channel.get(o2), 17, 'o2 is set');
82
+
83
+ channel.set(o, 14);
84
+ st.equal(channel.get(o), 14, 'o is modified');
85
+ st.equal(channel.get(o2), 17, 'o2 is not modified');
86
+
87
+ st.end();
88
+ });
89
+
90
+ t.test('delete', function (st) {
91
+ var channel = getSideChannel();
92
+ var o = {};
93
+ st.equal(channel['delete']({}), false, 'nonexistent value yields false');
94
+
95
+ channel.set(o, 42);
96
+ st.equal(channel.has(o), true, 'value is set');
97
+
98
+ st.equal(channel['delete']({}), false, 'nonexistent value still yields false');
99
+
100
+ st.equal(channel['delete'](o), true, 'deleted value yields true');
101
+
102
+ st.equal(channel.has(o), false, 'value is no longer set');
103
+
104
+ st.end();
105
+ });
106
+
107
+ t.end();
108
+ });
109
+
110
+ test('getSideChannelMap, no WeakMaps and/or Maps', { skip: typeof WeakMap === 'function' || typeof Map === 'function' }, function (t) {
111
+ t.equal(getSideChannelWeakMap, false, 'is false');
112
+
113
+ t.end();
114
+ });
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@ljharb/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "es2021",
5
+ },
6
+ "exclude": [
7
+ "coverage",
8
+ ],
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-web-worldmap",
3
- "version": "5.1.5",
3
+ "version": "5.2.0",
4
4
  "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
5
5
  "dependencies": {
6
6
  "@turf/bezier-spline": "~7.2.0",
@@ -938,9 +938,9 @@ var feedback = function(n = "map",v,a = "feedback",c) {
938
938
  if (c === true) { map.closePopup(); }
939
939
  }
940
940
 
941
- // map.on('click', function(e) {
942
- // ws.send(JSON.stringify({action:"click", lat:e.latlng.lat.toFixed(5), lon:e.latlng.lng.toFixed(5)}));
943
- // });
941
+ map.on('click', function(e) {
942
+ ws.send(JSON.stringify({action:"click", lat:e.latlng.lat.toFixed(5), lon:e.latlng.lng.toFixed(5)}));
943
+ });
944
944
 
945
945
  // allow double right click to zoom out (if enabled)
946
946
  // single right click opens a message window that adds a marker
@@ -1966,7 +1966,6 @@ function setMarker(data) {
1966
1966
  iconAnchor: [sizc, sizc],
1967
1967
  html:'<img src="'+svgarrow+'" style="width:'+siz+'px; height:'+siz+'px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
1968
1968
  });
1969
- console.log("MM",myMarker)
1970
1969
  marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
1971
1970
  }
1972
1971
  else if (data.icon === "wind") {
@@ -2602,14 +2601,17 @@ function doCommand(cmd) {
2602
2601
  if (cmd.hasOwnProperty("button")) {
2603
2602
  if (!Array.isArray(cmd.button)) { cmd.button = [cmd.button]; }
2604
2603
  cmd.button.forEach(function(b) {
2605
- if (b.icon) {
2606
- if (!buttons[b.name]) {
2607
- buttons[b.name] = L.easyButton( b.icon, function() {
2608
- ws.send(JSON.stringify({action:"button", name:b.name}));
2609
- }, b.name, { position:b.position||'topright' }).addTo(map);
2604
+ if (b.name && b.icon) {
2605
+ if (buttons[b.name]) {
2606
+ buttons[b.name].removeFrom(map);
2607
+ delete buttons[b.name];
2610
2608
  }
2609
+ buttons[b.name] = L.easyButton( b.icon, function() {
2610
+ ws.send(JSON.stringify({action:"button", name:b.name, value:b?.value}));
2611
+ }, b.name, { position:b.position||'topright' });
2612
+ buttons[b.name].addTo(map);
2611
2613
  }
2612
- else {
2614
+ else if (b.name && !b.icon){
2613
2615
  if (buttons[b.name]) {
2614
2616
  buttons[b.name].removeFrom(map);
2615
2617
  delete buttons[b.name];
@@ -3472,18 +3474,23 @@ function createRings(r) {
3472
3474
 
3473
3475
  function handleCoTtypes(d,p) {
3474
3476
  if (d.type.indexOf('a-') === 0) { // handle a- types
3475
- var i = d.type.split('-').join('').toUpperCase();
3476
- i = 'S' + i.substr(1,2) + 'P' + i.substr(3);
3477
- if (d.role === 'Team Lead') { i = i + '----B'; }
3478
- if (d.role === 'HQ') { i = 'SFGPUH' };
3479
- if (d.role === "Medic") { i = 'SFGPUSM----A'; }
3480
- if (d.role === "RTO") { i = 'SFGPUUS'; }
3481
- if (d.role === 'K9') { i = 'SFGPUU'; }
3482
- d.SIDC = (i + '-------').substr(0,12);
3483
- // Handle "special" types
3484
- if (d.type === "a-h-X-i-o") { d.SIDC = "EHIP--------" }
3485
- if (d.type === "a-h-X-i-m-d") { d.SIDC = "EHNPBB------" }
3486
- if (d.type === "a-h-X-i-g-e") { d.SIDC = "EHNPAC------" }
3477
+ if (p?.detail?.__milsym?.id) {
3478
+ d.SIDC = p.detail.__milsym.id;
3479
+ }
3480
+ else {
3481
+ var i = d.type.split('-').join('').toUpperCase();
3482
+ i = 'S' + i.substr(1,2) + 'P' + i.substr(3);
3483
+ if (d.role === 'Team Lead') { i = i + '----B'; }
3484
+ if (d.role === 'HQ') { i = 'SFGPUH' };
3485
+ if (d.role === "Medic") { i = 'SFGPUSM----A'; }
3486
+ if (d.role === "RTO") { i = 'SFGPUUS'; }
3487
+ if (d.role === 'K9') { i = 'SFGPUU'; }
3488
+ d.SIDC = (i + '-------').substr(0,12);
3489
+ // Handle "special" types
3490
+ if (d.type === "a-h-X-i-o") { d.SIDC = "EHIP--------" }
3491
+ if (d.type === "a-h-X-i-m-d") { d.SIDC = "EHNPBB------" }
3492
+ if (d.type === "a-h-X-i-g-e") { d.SIDC = "EHNPAC------" }
3493
+ }
3487
3494
  return d;
3488
3495
  }
3489
3496
  else { // handle b- types
package/worldmap.html CHANGED
@@ -667,6 +667,7 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
667
667
  { value: "layer", label: "Add, remove layers"},
668
668
  { value: "bounds", label: "Boundary change"},
669
669
  { value: "files", label: "File drop"},
670
+ { value: "click", label: "Click on map"},
670
671
  { value: "other", label: "All other"}
671
672
  ]
672
673
  }]});
package/worldmap.js CHANGED
@@ -323,7 +323,7 @@ module.exports = function(RED) {
323
323
  var WorldMapIn = function(n) {
324
324
  RED.nodes.createNode(this,n);
325
325
  this.path = n.path || "/worldmap";
326
- this.events = n.events || "connect,disconnect,point,layer,bounds,files,draw,other";
326
+ this.events = n.events || "connect,disconnect,point,layer,bounds,files,draw,click,other";
327
327
  if (this.path.charAt(0) != "/") { this.path = "/" + this.path; }
328
328
  if (!sockets[this.path]) {
329
329
  var libPath = path.posix.join(RED.settings.httpNodeRoot, this.path, 'leaflet', 'sockjs.min.js');
@@ -349,6 +349,9 @@ module.exports = function(RED) {
349
349
  if ((node.events.indexOf("bounds")!==-1) && (message.action === "bounds")) {
350
350
  setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})});
351
351
  }
352
+ if ((node.events.indexOf("click")!==-1) && (message.action === "click")) {
353
+ setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})});
354
+ }
352
355
  if ((node.events.indexOf("point")!==-1) && ((message.action === "point")||(message.action === "move")||(message.action === "delete") )) {
353
356
  setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})});
354
357
  }
@@ -362,7 +365,7 @@ module.exports = function(RED) {
362
365
  if ((node.events.indexOf("draw")!==-1) && ((message.action === "draw")||(message.action === "drawdelete"))) {
363
366
  setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})});
364
367
  }
365
- if (node.events.indexOf("other")!==-1 && "connected,point,addlayer,dellayer,delete,move,draw,drawdelete,files,bounds".indexOf(message.action) === -1) {
368
+ if (node.events.indexOf("other")!==-1 && "connected,point,addlayer,dellayer,delete,move,draw,drawdelete,files,bounds,click".indexOf(message.action) === -1) {
366
369
  setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})});
367
370
  }
368
371
  }
@@ -1 +0,0 @@
1
- coverage/
@@ -1,93 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [v1.0.7](https://github.com/ljharb/call-bind/compare/v1.0.6...v1.0.7) - 2024-02-12
9
-
10
- ### Commits
11
-
12
- - [Refactor] use `es-define-property` [`09b76a0`](https://github.com/ljharb/call-bind/commit/09b76a01634440461d44a80c9924ec4b500f3b03)
13
- - [Deps] update `get-intrinsic`, `set-function-length` [`ad5136d`](https://github.com/ljharb/call-bind/commit/ad5136ddda2a45c590959829ad3dce0c9f4e3590)
14
-
15
- ## [v1.0.6](https://github.com/ljharb/call-bind/compare/v1.0.5...v1.0.6) - 2024-02-05
16
-
17
- ### Commits
18
-
19
- - [Dev Deps] update `aud`, `npmignore`, `tape` [`d564d5c`](https://github.com/ljharb/call-bind/commit/d564d5ce3e06a19df4d499c77f8d1a9da44e77aa)
20
- - [Deps] update `get-intrinsic`, `set-function-length` [`cfc2bdc`](https://github.com/ljharb/call-bind/commit/cfc2bdca7b633df0e0e689e6b637f668f1c6792e)
21
- - [Refactor] use `es-errors`, so things that only need those do not need `get-intrinsic` [`64cd289`](https://github.com/ljharb/call-bind/commit/64cd289ae5862c250a4ca80aa8d461047c166af5)
22
- - [meta] add missing `engines.node` [`32a4038`](https://github.com/ljharb/call-bind/commit/32a4038857b62179f7f9b7b3df2c5260036be582)
23
-
24
- ## [v1.0.5](https://github.com/ljharb/call-bind/compare/v1.0.4...v1.0.5) - 2023-10-19
25
-
26
- ### Commits
27
-
28
- - [Fix] throw an error on non-functions as early as possible [`f262408`](https://github.com/ljharb/call-bind/commit/f262408f822c840fbc268080f3ad7c429611066d)
29
- - [Deps] update `set-function-length` [`3fff271`](https://github.com/ljharb/call-bind/commit/3fff27145a1e3a76a5b74f1d7c3c43d0fa3b9871)
30
-
31
- ## [v1.0.4](https://github.com/ljharb/call-bind/compare/v1.0.3...v1.0.4) - 2023-10-19
32
-
33
- ## [v1.0.3](https://github.com/ljharb/call-bind/compare/v1.0.2...v1.0.3) - 2023-10-19
34
-
35
- ### Commits
36
-
37
- - [actions] reuse common workflows [`a994df6`](https://github.com/ljharb/call-bind/commit/a994df69f401f4bf735a4ccd77029b85d1549453)
38
- - [meta] use `npmignore` to autogenerate an npmignore file [`eef3ef2`](https://github.com/ljharb/call-bind/commit/eef3ef21e1f002790837fedb8af2679c761fbdf5)
39
- - [readme] flesh out content [`1845ccf`](https://github.com/ljharb/call-bind/commit/1845ccfd9976a607884cfc7157c93192cc16cf22)
40
- - [actions] use `node/install` instead of `node/run`; use `codecov` action [`5b47d53`](https://github.com/ljharb/call-bind/commit/5b47d53d2fd74af5ea0a44f1d51e503cd42f7a90)
41
- - [Refactor] use `set-function-length` [`a0e165c`](https://github.com/ljharb/call-bind/commit/a0e165c5dc61db781cbc919b586b1c2b8da0b150)
42
- - [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`9c50103`](https://github.com/ljharb/call-bind/commit/9c50103f44137279a817317cf6cc421a658f85b4)
43
- - [meta] simplify "exports" [`019c6d0`](https://github.com/ljharb/call-bind/commit/019c6d06b0e1246ceed8e579f57e44441cbbf6d9)
44
- - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `safe-publish-latest`, `tape` [`23bd718`](https://github.com/ljharb/call-bind/commit/23bd718a288d3b03042062b4ef5153b3cea83f11)
45
- - [actions] update codecov uploader [`62552d7`](https://github.com/ljharb/call-bind/commit/62552d79cc79e05825e99aaba134ae5b37f33da5)
46
- - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`ec81665`](https://github.com/ljharb/call-bind/commit/ec81665b300f87eabff597afdc8b8092adfa7afd)
47
- - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `tape` [`35d67fc`](https://github.com/ljharb/call-bind/commit/35d67fcea883e686650f736f61da5ddca2592de8)
48
- - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`0266d8d`](https://github.com/ljharb/call-bind/commit/0266d8d2a45086a922db366d0c2932fa463662ff)
49
- - [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`43a5b28`](https://github.com/ljharb/call-bind/commit/43a5b28a444e710e1bbf92adb8afb5cf7523a223)
50
- - [Deps] update `define-data-property`, `function-bind`, `get-intrinsic` [`780eb36`](https://github.com/ljharb/call-bind/commit/780eb36552514f8cc99c70821ce698697c2726a5)
51
- - [Dev Deps] update `aud`, `tape` [`90d50ad`](https://github.com/ljharb/call-bind/commit/90d50ad03b061e0268b3380b0065fcaec183dc05)
52
- - [meta] use `prepublishOnly` script for npm 7+ [`44c5433`](https://github.com/ljharb/call-bind/commit/44c5433b7980e02b4870007046407cf6fc543329)
53
- - [Deps] update `get-intrinsic` [`86bfbfc`](https://github.com/ljharb/call-bind/commit/86bfbfcf34afdc6eabc93ce3d408548d0e27d958)
54
- - [Deps] update `get-intrinsic` [`5c53354`](https://github.com/ljharb/call-bind/commit/5c5335489be0294c18cd7a8bb6e08226ee019ff5)
55
- - [actions] update checkout action [`4c393a8`](https://github.com/ljharb/call-bind/commit/4c393a8173b3c8e5b30d5b3297b3b94d48bf87f3)
56
- - [Deps] update `get-intrinsic` [`4e70bde`](https://github.com/ljharb/call-bind/commit/4e70bdec0626acb11616d66250fc14565e716e91)
57
- - [Deps] update `get-intrinsic` [`55ae803`](https://github.com/ljharb/call-bind/commit/55ae803a920bd93c369cd798c20de31f91e9fc60)
58
-
59
- ## [v1.0.2](https://github.com/ljharb/call-bind/compare/v1.0.1...v1.0.2) - 2021-01-11
60
-
61
- ### Commits
62
-
63
- - [Fix] properly include the receiver in the bound length [`dbae7bc`](https://github.com/ljharb/call-bind/commit/dbae7bc676c079a0d33c0a43e9ef92cb7b01345d)
64
-
65
- ## [v1.0.1](https://github.com/ljharb/call-bind/compare/v1.0.0...v1.0.1) - 2021-01-08
66
-
67
- ### Commits
68
-
69
- - [Tests] migrate tests to Github Actions [`b6db284`](https://github.com/ljharb/call-bind/commit/b6db284c36f8ccd195b88a6764fe84b7223a0da1)
70
- - [meta] do not publish github action workflow files [`ec7fe46`](https://github.com/ljharb/call-bind/commit/ec7fe46e60cfa4764ee943d2755f5e5a366e578e)
71
- - [Fix] preserve original function’s length when possible [`adbceaa`](https://github.com/ljharb/call-bind/commit/adbceaa3cac4b41ea78bb19d7ccdbaaf7e0bdadb)
72
- - [Tests] gather coverage data on every job [`d69e23c`](https://github.com/ljharb/call-bind/commit/d69e23cc65f101ba1d4c19bb07fa8eb0ec624be8)
73
- - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`2fd3586`](https://github.com/ljharb/call-bind/commit/2fd3586c5d47b335364c14293114c6b625ae1f71)
74
- - [Deps] update `get-intrinsic` [`f23e931`](https://github.com/ljharb/call-bind/commit/f23e9318cc271c2add8bb38cfded85ee7baf8eee)
75
- - [Deps] update `get-intrinsic` [`72d9f44`](https://github.com/ljharb/call-bind/commit/72d9f44e184465ba8dd3fb48260bbcff234985f2)
76
- - [meta] fix FUNDING.yml [`e723573`](https://github.com/ljharb/call-bind/commit/e723573438c5a68dcec31fb5d96ea6b7e4a93be8)
77
- - [eslint] ignore coverage output [`15e76d2`](https://github.com/ljharb/call-bind/commit/15e76d28a5f43e504696401e5b31ebb78ee1b532)
78
- - [meta] add Automatic Rebase and Require Allow Edits workflows [`8fa4dab`](https://github.com/ljharb/call-bind/commit/8fa4dabb23ba3dd7bb92c9571c1241c08b56e4b6)
79
-
80
- ## v1.0.0 - 2020-10-30
81
-
82
- ### Commits
83
-
84
- - Initial commit [`306cf98`](https://github.com/ljharb/call-bind/commit/306cf98c7ec9e7ef66b653ec152277ac1381eb50)
85
- - Tests [`e10d0bb`](https://github.com/ljharb/call-bind/commit/e10d0bbdadc7a10ecedc9a1c035112d3e368b8df)
86
- - Implementation [`43852ed`](https://github.com/ljharb/call-bind/commit/43852eda0f187327b7fad2423ca972149a52bd65)
87
- - npm init [`408f860`](https://github.com/ljharb/call-bind/commit/408f860b773a2f610805fd3613d0d71bac1b6249)
88
- - [meta] add Automatic Rebase and Require Allow Edits workflows [`fb349b2`](https://github.com/ljharb/call-bind/commit/fb349b2e48defbec8b5ec8a8395cc8f69f220b13)
89
- - [meta] add `auto-changelog` [`c4001fc`](https://github.com/ljharb/call-bind/commit/c4001fc43031799ef908211c98d3b0fb2b60fde4)
90
- - [meta] add "funding"; create `FUNDING.yml` [`d4d6d29`](https://github.com/ljharb/call-bind/commit/d4d6d2974a14bc2e98830468eda7fe6d6a776717)
91
- - [Tests] add `npm run lint` [`dedfb98`](https://github.com/ljharb/call-bind/commit/dedfb98bd0ecefb08ddb9a94061bd10cde4332af)
92
- - Only apps should have lockfiles [`54ac776`](https://github.com/ljharb/call-bind/commit/54ac77653db45a7361dc153d2f478e743f110650)
93
- - [meta] add `safe-publish-latest` [`9ea8e43`](https://github.com/ljharb/call-bind/commit/9ea8e435b950ce9b705559cd651039f9bf40140f)
@@ -1,64 +0,0 @@
1
- # call-bind <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
- Robustly `.call.bind()` a function.
13
-
14
- ## Getting started
15
-
16
- ```sh
17
- npm install --save call-bind
18
- ```
19
-
20
- ## Usage/Examples
21
-
22
- ```js
23
- const assert = require('assert');
24
- const callBind = require('call-bind');
25
- const callBound = require('call-bind/callBound');
26
-
27
- function f(a, b) {
28
- assert.equal(this, 1);
29
- assert.equal(a, 2);
30
- assert.equal(b, 3);
31
- assert.equal(arguments.length, 2);
32
- }
33
-
34
- const fBound = callBind(f);
35
-
36
- const slice = callBound('Array.prototype.slice');
37
-
38
- delete Function.prototype.call;
39
- delete Function.prototype.bind;
40
-
41
- fBound(1, 2, 3);
42
-
43
- assert.deepEqual(slice([1, 2, 3, 4], 1, -1), [2, 3]);
44
- ```
45
-
46
- ## Tests
47
-
48
- Clone the repo, `npm install`, and run `npm test`
49
-
50
- [package-url]: https://npmjs.org/package/call-bind
51
- [npm-version-svg]: https://versionbadg.es/ljharb/call-bind.svg
52
- [deps-svg]: https://david-dm.org/ljharb/call-bind.svg
53
- [deps-url]: https://david-dm.org/ljharb/call-bind
54
- [dev-deps-svg]: https://david-dm.org/ljharb/call-bind/dev-status.svg
55
- [dev-deps-url]: https://david-dm.org/ljharb/call-bind#info=devDependencies
56
- [npm-badge-png]: https://nodei.co/npm/call-bind.png?downloads=true&stars=true
57
- [license-image]: https://img.shields.io/npm/l/call-bind.svg
58
- [license-url]: LICENSE
59
- [downloads-image]: https://img.shields.io/npm/dm/call-bind.svg
60
- [downloads-url]: https://npm-stat.com/charts.html?package=call-bind
61
- [codecov-image]: https://codecov.io/gh/ljharb/call-bind/branch/main/graphs/badge.svg
62
- [codecov-url]: https://app.codecov.io/gh/ljharb/call-bind/
63
- [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/call-bind
64
- [actions-url]: https://github.com/ljharb/call-bind/actions
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- var GetIntrinsic = require('get-intrinsic');
4
-
5
- var callBind = require('./');
6
-
7
- var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
8
-
9
- module.exports = function callBoundIntrinsic(name, allowMissing) {
10
- var intrinsic = GetIntrinsic(name, !!allowMissing);
11
- if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
12
- return callBind(intrinsic);
13
- }
14
- return intrinsic;
15
- };
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- var bind = require('function-bind');
4
- var GetIntrinsic = require('get-intrinsic');
5
- var setFunctionLength = require('set-function-length');
6
-
7
- var $TypeError = require('es-errors/type');
8
- var $apply = GetIntrinsic('%Function.prototype.apply%');
9
- var $call = GetIntrinsic('%Function.prototype.call%');
10
- var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
11
-
12
- var $defineProperty = require('es-define-property');
13
- var $max = GetIntrinsic('%Math.max%');
14
-
15
- module.exports = function callBind(originalFunction) {
16
- if (typeof originalFunction !== 'function') {
17
- throw new $TypeError('a function is required');
18
- }
19
- var func = $reflectApply(bind, $call, arguments);
20
- return setFunctionLength(
21
- func,
22
- 1 + $max(0, originalFunction.length - (arguments.length - 1)),
23
- true
24
- );
25
- };
26
-
27
- var applyBind = function applyBind() {
28
- return $reflectApply(bind, $apply, arguments);
29
- };
30
-
31
- if ($defineProperty) {
32
- $defineProperty(module.exports, 'apply', { value: applyBind });
33
- } else {
34
- module.exports.apply = applyBind;
35
- }
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- var callBind = require('../');
4
- var bind = require('function-bind');
5
- var gOPD = require('gopd');
6
- var hasStrictMode = require('has-strict-mode')();
7
- var forEach = require('for-each');
8
- var inspect = require('object-inspect');
9
- var v = require('es-value-fixtures');
10
-
11
- var test = require('tape');
12
-
13
- /*
14
- * older engines have length nonconfigurable
15
- * in io.js v3, it is configurable except on bound functions, hence the .bind()
16
- */
17
- var functionsHaveConfigurableLengths = !!(
18
- gOPD
19
- && Object.getOwnPropertyDescriptor
20
- && Object.getOwnPropertyDescriptor(bind.call(function () {}), 'length').configurable
21
- );
22
-
23
- test('callBind', function (t) {
24
- forEach(v.nonFunctions, function (nonFunction) {
25
- t['throws'](
26
- function () { callBind(nonFunction); },
27
- TypeError,
28
- inspect(nonFunction) + ' is not a function'
29
- );
30
- });
31
-
32
- var sentinel = { sentinel: true };
33
- var func = function (a, b) {
34
- // eslint-disable-next-line no-invalid-this
35
- return [!hasStrictMode && this === global ? undefined : this, a, b];
36
- };
37
- t.equal(func.length, 2, 'original function length is 2');
38
- t.deepEqual(func(), [undefined, undefined, undefined], 'unbound func with too few args');
39
- t.deepEqual(func(1, 2), [undefined, 1, 2], 'unbound func with right args');
40
- t.deepEqual(func(1, 2, 3), [undefined, 1, 2], 'unbound func with too many args');
41
-
42
- var bound = callBind(func);
43
- t.equal(bound.length, func.length + 1, 'function length is preserved', { skip: !functionsHaveConfigurableLengths });
44
- t.deepEqual(bound(), [undefined, undefined, undefined], 'bound func with too few args');
45
- t.deepEqual(bound(1, 2), [hasStrictMode ? 1 : Object(1), 2, undefined], 'bound func with right args');
46
- t.deepEqual(bound(1, 2, 3), [hasStrictMode ? 1 : Object(1), 2, 3], 'bound func with too many args');
47
-
48
- var boundR = callBind(func, sentinel);
49
- t.equal(boundR.length, func.length, 'function length is preserved', { skip: !functionsHaveConfigurableLengths });
50
- t.deepEqual(boundR(), [sentinel, undefined, undefined], 'bound func with receiver, with too few args');
51
- t.deepEqual(boundR(1, 2), [sentinel, 1, 2], 'bound func with receiver, with right args');
52
- t.deepEqual(boundR(1, 2, 3), [sentinel, 1, 2], 'bound func with receiver, with too many args');
53
-
54
- var boundArg = callBind(func, sentinel, 1);
55
- t.equal(boundArg.length, func.length - 1, 'function length is preserved', { skip: !functionsHaveConfigurableLengths });
56
- t.deepEqual(boundArg(), [sentinel, 1, undefined], 'bound func with receiver and arg, with too few args');
57
- t.deepEqual(boundArg(2), [sentinel, 1, 2], 'bound func with receiver and arg, with right arg');
58
- t.deepEqual(boundArg(2, 3), [sentinel, 1, 2], 'bound func with receiver and arg, with too many args');
59
-
60
- t.test('callBind.apply', function (st) {
61
- var aBound = callBind.apply(func);
62
- st.deepEqual(aBound(sentinel), [sentinel, undefined, undefined], 'apply-bound func with no args');
63
- st.deepEqual(aBound(sentinel, [1], 4), [sentinel, 1, undefined], 'apply-bound func with too few args');
64
- st.deepEqual(aBound(sentinel, [1, 2], 4), [sentinel, 1, 2], 'apply-bound func with right args');
65
-
66
- var aBoundArg = callBind.apply(func);
67
- st.deepEqual(aBoundArg(sentinel, [1, 2, 3], 4), [sentinel, 1, 2], 'apply-bound func with too many args');
68
- st.deepEqual(aBoundArg(sentinel, [1, 2], 4), [sentinel, 1, 2], 'apply-bound func with right args');
69
- st.deepEqual(aBoundArg(sentinel, [1], 4), [sentinel, 1, undefined], 'apply-bound func with too few args');
70
-
71
- var aBoundR = callBind.apply(func, sentinel);
72
- st.deepEqual(aBoundR([1, 2, 3], 4), [sentinel, 1, 2], 'apply-bound func with receiver and too many args');
73
- st.deepEqual(aBoundR([1, 2], 4), [sentinel, 1, 2], 'apply-bound func with receiver and right args');
74
- st.deepEqual(aBoundR([1], 4), [sentinel, 1, undefined], 'apply-bound func with receiver and too few args');
75
-
76
- st.end();
77
- });
78
-
79
- t.end();
80
- });