@openfn/language-dhis2 3.0.4 → 3.0.5

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 (114) hide show
  1. package/node_modules/call-bind/.eslintignore +1 -0
  2. package/node_modules/call-bind/.eslintrc +17 -0
  3. package/node_modules/call-bind/.github/FUNDING.yml +12 -0
  4. package/node_modules/call-bind/.nycrc +13 -0
  5. package/node_modules/call-bind/CHANGELOG.md +42 -0
  6. package/node_modules/call-bind/LICENSE +21 -0
  7. package/node_modules/call-bind/README.md +2 -0
  8. package/node_modules/call-bind/callBound.js +15 -0
  9. package/node_modules/call-bind/index.js +47 -0
  10. package/node_modules/call-bind/package.json +108 -0
  11. package/node_modules/call-bind/test/callBound.js +55 -0
  12. package/node_modules/call-bind/test/index.js +66 -0
  13. package/node_modules/function-bind/.editorconfig +20 -0
  14. package/node_modules/function-bind/.eslintrc +15 -0
  15. package/node_modules/function-bind/.jscs.json +176 -0
  16. package/node_modules/function-bind/.npmignore +22 -0
  17. package/node_modules/function-bind/.travis.yml +168 -0
  18. package/node_modules/function-bind/LICENSE +20 -0
  19. package/node_modules/function-bind/README.md +48 -0
  20. package/node_modules/function-bind/implementation.js +52 -0
  21. package/node_modules/function-bind/index.js +5 -0
  22. package/node_modules/function-bind/package.json +100 -0
  23. package/node_modules/function-bind/test/.eslintrc +9 -0
  24. package/node_modules/function-bind/test/index.js +252 -0
  25. package/node_modules/get-intrinsic/.eslintignore +1 -0
  26. package/node_modules/get-intrinsic/.eslintrc +43 -0
  27. package/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  28. package/node_modules/get-intrinsic/.nycrc +13 -0
  29. package/node_modules/get-intrinsic/CHANGELOG.md +64 -0
  30. package/node_modules/get-intrinsic/LICENSE +21 -0
  31. package/node_modules/get-intrinsic/README.md +65 -0
  32. package/node_modules/get-intrinsic/index.js +330 -0
  33. package/node_modules/get-intrinsic/package.json +107 -0
  34. package/node_modules/get-intrinsic/test/GetIntrinsic.js +260 -0
  35. package/node_modules/has/LICENSE-MIT +22 -0
  36. package/node_modules/has/README.md +18 -0
  37. package/node_modules/has/package.json +79 -0
  38. package/node_modules/has/src/index.js +5 -0
  39. package/node_modules/has/test/index.js +10 -0
  40. package/node_modules/has-symbols/.eslintrc +11 -0
  41. package/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  42. package/node_modules/has-symbols/.github/workflows/rebase.yml +15 -0
  43. package/node_modules/has-symbols/.travis.yml +12 -0
  44. package/node_modules/has-symbols/CHANGELOG.md +34 -0
  45. package/node_modules/has-symbols/LICENSE +21 -0
  46. package/node_modules/has-symbols/README.md +45 -0
  47. package/node_modules/has-symbols/index.js +13 -0
  48. package/node_modules/has-symbols/package.json +124 -0
  49. package/node_modules/has-symbols/shams.js +42 -0
  50. package/node_modules/has-symbols/test/index.js +22 -0
  51. package/node_modules/has-symbols/test/shams/core-js.js +28 -0
  52. package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +28 -0
  53. package/node_modules/has-symbols/test/tests.js +54 -0
  54. package/node_modules/qs/.editorconfig +40 -0
  55. package/node_modules/qs/.eslintrc +38 -0
  56. package/node_modules/qs/.github/FUNDING.yml +12 -0
  57. package/node_modules/qs/.nycrc +13 -0
  58. package/node_modules/qs/CHANGELOG.md +388 -0
  59. package/node_modules/qs/LICENSE.md +29 -0
  60. package/node_modules/qs/README.md +623 -0
  61. package/node_modules/qs/dist/qs.js +2044 -0
  62. package/node_modules/qs/lib/formats.js +23 -0
  63. package/node_modules/qs/lib/index.js +11 -0
  64. package/node_modules/qs/lib/parse.js +263 -0
  65. package/node_modules/qs/lib/stringify.js +317 -0
  66. package/node_modules/qs/lib/utils.js +252 -0
  67. package/node_modules/qs/package.json +104 -0
  68. package/node_modules/qs/test/parse.js +841 -0
  69. package/node_modules/qs/test/stringify.js +865 -0
  70. package/node_modules/qs/test/utils.js +136 -0
  71. package/node_modules/side-channel/.eslintignore +1 -0
  72. package/node_modules/side-channel/.eslintrc +11 -0
  73. package/node_modules/side-channel/.github/FUNDING.yml +12 -0
  74. package/node_modules/side-channel/.nycrc +13 -0
  75. package/node_modules/side-channel/CHANGELOG.md +65 -0
  76. package/node_modules/side-channel/LICENSE +21 -0
  77. package/node_modules/side-channel/README.md +2 -0
  78. package/node_modules/side-channel/index.js +124 -0
  79. package/node_modules/side-channel/node_modules/object-inspect/.eslintignore +1 -0
  80. package/node_modules/side-channel/node_modules/object-inspect/.eslintrc +53 -0
  81. package/node_modules/side-channel/node_modules/object-inspect/.github/FUNDING.yml +12 -0
  82. package/node_modules/side-channel/node_modules/object-inspect/.nycrc +13 -0
  83. package/node_modules/side-channel/node_modules/object-inspect/CHANGELOG.md +342 -0
  84. package/node_modules/side-channel/node_modules/object-inspect/LICENSE +21 -0
  85. package/node_modules/side-channel/node_modules/object-inspect/example/all.js +23 -0
  86. package/node_modules/side-channel/node_modules/object-inspect/example/circular.js +6 -0
  87. package/node_modules/side-channel/node_modules/object-inspect/example/fn.js +5 -0
  88. package/node_modules/side-channel/node_modules/object-inspect/example/inspect.js +10 -0
  89. package/node_modules/side-channel/node_modules/object-inspect/index.js +511 -0
  90. package/node_modules/side-channel/node_modules/object-inspect/package.json +112 -0
  91. package/node_modules/side-channel/node_modules/object-inspect/readme.markdown +86 -0
  92. package/node_modules/side-channel/node_modules/object-inspect/test/bigint.js +58 -0
  93. package/node_modules/side-channel/node_modules/object-inspect/test/browser/dom.js +15 -0
  94. package/node_modules/side-channel/node_modules/object-inspect/test/circular.js +16 -0
  95. package/node_modules/side-channel/node_modules/object-inspect/test/deep.js +12 -0
  96. package/node_modules/side-channel/node_modules/object-inspect/test/element.js +53 -0
  97. package/node_modules/side-channel/node_modules/object-inspect/test/err.js +48 -0
  98. package/node_modules/side-channel/node_modules/object-inspect/test/fakes.js +29 -0
  99. package/node_modules/side-channel/node_modules/object-inspect/test/fn.js +76 -0
  100. package/node_modules/side-channel/node_modules/object-inspect/test/has.js +34 -0
  101. package/node_modules/side-channel/node_modules/object-inspect/test/holes.js +15 -0
  102. package/node_modules/side-channel/node_modules/object-inspect/test/indent-option.js +271 -0
  103. package/node_modules/side-channel/node_modules/object-inspect/test/inspect.js +102 -0
  104. package/node_modules/side-channel/node_modules/object-inspect/test/lowbyte.js +12 -0
  105. package/node_modules/side-channel/node_modules/object-inspect/test/number.js +58 -0
  106. package/node_modules/side-channel/node_modules/object-inspect/test/quoteStyle.js +17 -0
  107. package/node_modules/side-channel/node_modules/object-inspect/test/toStringTag.js +40 -0
  108. package/node_modules/side-channel/node_modules/object-inspect/test/undef.js +12 -0
  109. package/node_modules/side-channel/node_modules/object-inspect/test/values.js +211 -0
  110. package/node_modules/side-channel/node_modules/object-inspect/test-core-js.js +26 -0
  111. package/node_modules/side-channel/node_modules/object-inspect/util.inspect.js +1 -0
  112. package/node_modules/side-channel/package.json +95 -0
  113. package/node_modules/side-channel/test/index.js +78 -0
  114. package/package.json +3 -2
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+
3
+ var test = require('tape');
4
+ var inspect = require('object-inspect');
5
+ var SaferBuffer = require('safer-buffer').Buffer;
6
+ var forEach = require('for-each');
7
+ var utils = require('../lib/utils');
8
+
9
+ test('merge()', function (t) {
10
+ t.deepEqual(utils.merge(null, true), [null, true], 'merges true into null');
11
+
12
+ t.deepEqual(utils.merge(null, [42]), [null, 42], 'merges null into an array');
13
+
14
+ t.deepEqual(utils.merge({ a: 'b' }, { a: 'c' }), { a: ['b', 'c'] }, 'merges two objects with the same key');
15
+
16
+ var oneMerged = utils.merge({ foo: 'bar' }, { foo: { first: '123' } });
17
+ t.deepEqual(oneMerged, { foo: ['bar', { first: '123' }] }, 'merges a standalone and an object into an array');
18
+
19
+ var twoMerged = utils.merge({ foo: ['bar', { first: '123' }] }, { foo: { second: '456' } });
20
+ t.deepEqual(twoMerged, { foo: { 0: 'bar', 1: { first: '123' }, second: '456' } }, 'merges a standalone and two objects into an array');
21
+
22
+ var sandwiched = utils.merge({ foo: ['bar', { first: '123', second: '456' }] }, { foo: 'baz' });
23
+ t.deepEqual(sandwiched, { foo: ['bar', { first: '123', second: '456' }, 'baz'] }, 'merges an object sandwiched by two standalones into an array');
24
+
25
+ var nestedArrays = utils.merge({ foo: ['baz'] }, { foo: ['bar', 'xyzzy'] });
26
+ t.deepEqual(nestedArrays, { foo: ['baz', 'bar', 'xyzzy'] });
27
+
28
+ var noOptionsNonObjectSource = utils.merge({ foo: 'baz' }, 'bar');
29
+ t.deepEqual(noOptionsNonObjectSource, { foo: 'baz', bar: true });
30
+
31
+ t.test(
32
+ 'avoids invoking array setters unnecessarily',
33
+ { skip: typeof Object.defineProperty !== 'function' },
34
+ function (st) {
35
+ var setCount = 0;
36
+ var getCount = 0;
37
+ var observed = [];
38
+ Object.defineProperty(observed, 0, {
39
+ get: function () {
40
+ getCount += 1;
41
+ return { bar: 'baz' };
42
+ },
43
+ set: function () { setCount += 1; }
44
+ });
45
+ utils.merge(observed, [null]);
46
+ st.equal(setCount, 0);
47
+ st.equal(getCount, 1);
48
+ observed[0] = observed[0]; // eslint-disable-line no-self-assign
49
+ st.equal(setCount, 1);
50
+ st.equal(getCount, 2);
51
+ st.end();
52
+ }
53
+ );
54
+
55
+ t.end();
56
+ });
57
+
58
+ test('assign()', function (t) {
59
+ var target = { a: 1, b: 2 };
60
+ var source = { b: 3, c: 4 };
61
+ var result = utils.assign(target, source);
62
+
63
+ t.equal(result, target, 'returns the target');
64
+ t.deepEqual(target, { a: 1, b: 3, c: 4 }, 'target and source are merged');
65
+ t.deepEqual(source, { b: 3, c: 4 }, 'source is untouched');
66
+
67
+ t.end();
68
+ });
69
+
70
+ test('combine()', function (t) {
71
+ t.test('both arrays', function (st) {
72
+ var a = [1];
73
+ var b = [2];
74
+ var combined = utils.combine(a, b);
75
+
76
+ st.deepEqual(a, [1], 'a is not mutated');
77
+ st.deepEqual(b, [2], 'b is not mutated');
78
+ st.notEqual(a, combined, 'a !== combined');
79
+ st.notEqual(b, combined, 'b !== combined');
80
+ st.deepEqual(combined, [1, 2], 'combined is a + b');
81
+
82
+ st.end();
83
+ });
84
+
85
+ t.test('one array, one non-array', function (st) {
86
+ var aN = 1;
87
+ var a = [aN];
88
+ var bN = 2;
89
+ var b = [bN];
90
+
91
+ var combinedAnB = utils.combine(aN, b);
92
+ st.deepEqual(b, [bN], 'b is not mutated');
93
+ st.notEqual(aN, combinedAnB, 'aN + b !== aN');
94
+ st.notEqual(a, combinedAnB, 'aN + b !== a');
95
+ st.notEqual(bN, combinedAnB, 'aN + b !== bN');
96
+ st.notEqual(b, combinedAnB, 'aN + b !== b');
97
+ st.deepEqual([1, 2], combinedAnB, 'first argument is array-wrapped when not an array');
98
+
99
+ var combinedABn = utils.combine(a, bN);
100
+ st.deepEqual(a, [aN], 'a is not mutated');
101
+ st.notEqual(aN, combinedABn, 'a + bN !== aN');
102
+ st.notEqual(a, combinedABn, 'a + bN !== a');
103
+ st.notEqual(bN, combinedABn, 'a + bN !== bN');
104
+ st.notEqual(b, combinedABn, 'a + bN !== b');
105
+ st.deepEqual([1, 2], combinedABn, 'second argument is array-wrapped when not an array');
106
+
107
+ st.end();
108
+ });
109
+
110
+ t.test('neither is an array', function (st) {
111
+ var combined = utils.combine(1, 2);
112
+ st.notEqual(1, combined, '1 + 2 !== 1');
113
+ st.notEqual(2, combined, '1 + 2 !== 2');
114
+ st.deepEqual([1, 2], combined, 'both arguments are array-wrapped when not an array');
115
+
116
+ st.end();
117
+ });
118
+
119
+ t.end();
120
+ });
121
+
122
+ test('isBuffer()', function (t) {
123
+ forEach([null, undefined, true, false, '', 'abc', 42, 0, NaN, {}, [], function () {}, /a/g], function (x) {
124
+ t.equal(utils.isBuffer(x), false, inspect(x) + ' is not a buffer');
125
+ });
126
+
127
+ var fakeBuffer = { constructor: Buffer };
128
+ t.equal(utils.isBuffer(fakeBuffer), false, 'fake buffer is not a buffer');
129
+
130
+ var saferBuffer = SaferBuffer.from('abc');
131
+ t.equal(utils.isBuffer(saferBuffer), true, 'SaferBuffer instance is a buffer');
132
+
133
+ var buffer = Buffer.from && Buffer.alloc ? Buffer.from('abc') : new Buffer('abc');
134
+ t.equal(utils.isBuffer(buffer), true, 'real Buffer instance is a buffer');
135
+ t.end();
136
+ });
@@ -0,0 +1 @@
1
+ coverage/
@@ -0,0 +1,11 @@
1
+ {
2
+ "root": true,
3
+
4
+ "extends": "@ljharb",
5
+
6
+ "rules": {
7
+ "max-lines-per-function": 0,
8
+ "max-params": 0,
9
+ "new-cap": [2, { "capIsNewExceptions": ["GetIntrinsic"] }],
10
+ },
11
+ }
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [ljharb]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: npm/side-channel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
@@ -0,0 +1,13 @@
1
+ {
2
+ "all": true,
3
+ "check-coverage": false,
4
+ "reporter": ["text-summary", "text", "html", "json"],
5
+ "lines": 86,
6
+ "statements": 85.93,
7
+ "functions": 82.43,
8
+ "branches": 76.06,
9
+ "exclude": [
10
+ "coverage",
11
+ "test"
12
+ ]
13
+ }
@@ -0,0 +1,65 @@
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.4](https://github.com/ljharb/side-channel/compare/v1.0.3...v1.0.4) - 2020-12-29
9
+
10
+ ### Commits
11
+
12
+ - [Tests] migrate tests to Github Actions [`10909cb`](https://github.com/ljharb/side-channel/commit/10909cbf8ce9c0bf96f604cf13d7ffd5a22c2d40)
13
+ - [Refactor] Use a linked list rather than an array, and move accessed nodes to the beginning [`195613f`](https://github.com/ljharb/side-channel/commit/195613f28b5c1e6072ef0b61b5beebaf2b6a304e)
14
+ - [meta] do not publish github action workflow files [`290ec29`](https://github.com/ljharb/side-channel/commit/290ec29cd21a60585145b4a7237ec55228c52c27)
15
+ - [Tests] run `nyc` on all tests; use `tape` runner [`ea6d030`](https://github.com/ljharb/side-channel/commit/ea6d030ff3fe6be2eca39e859d644c51ecd88869)
16
+ - [actions] add "Allow Edits" workflow [`d464d8f`](https://github.com/ljharb/side-channel/commit/d464d8fe52b5eddf1504a0ed97f0941a90f32c15)
17
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog` [`02daca8`](https://github.com/ljharb/side-channel/commit/02daca87c6809821c97be468d1afa2f5ef447383)
18
+ - [Refactor] use `call-bind` and `get-intrinsic` instead of `es-abstract` [`e09d481`](https://github.com/ljharb/side-channel/commit/e09d481528452ebafa5cdeae1af665c35aa2deee)
19
+ - [Deps] update `object.assign` [`ee83aa8`](https://github.com/ljharb/side-channel/commit/ee83aa81df313b5e46319a63adb05cf0c179079a)
20
+ - [actions] update rebase action to use checkout v2 [`7726b0b`](https://github.com/ljharb/side-channel/commit/7726b0b058b632fccea709f58960871defaaa9d7)
21
+
22
+ ## [v1.0.3](https://github.com/ljharb/side-channel/compare/v1.0.2...v1.0.3) - 2020-08-23
23
+
24
+ ### Commits
25
+
26
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`1f10561`](https://github.com/ljharb/side-channel/commit/1f105611ef3acf32dec8032ae5c0baa5e56bb868)
27
+ - [Deps] update `es-abstract`, `object-inspect` [`bc20159`](https://github.com/ljharb/side-channel/commit/bc201597949a505e37cef9eaf24c7010831e6f03)
28
+ - [Dev Deps] update `@ljharb/eslint-config`, `tape` [`b9b2b22`](https://github.com/ljharb/side-channel/commit/b9b2b225f9e0ea72a6ec2b89348f0bd690bc9ed1)
29
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`7055ab4`](https://github.com/ljharb/side-channel/commit/7055ab4de0860606efd2003674a74f1fe6ebc07e)
30
+ - [Dev Deps] update `auto-changelog`; add `aud` [`d278c37`](https://github.com/ljharb/side-channel/commit/d278c37d08227be4f84aa769fcd919e73feeba40)
31
+ - [actions] switch Automatic Rebase workflow to `pull_request_target` event [`3bcf982`](https://github.com/ljharb/side-channel/commit/3bcf982faa122745b39c33ce83d32fdf003741c6)
32
+ - [Tests] only audit prod deps [`18d01c4`](https://github.com/ljharb/side-channel/commit/18d01c4015b82a3d75044c4d5ba7917b2eac01ec)
33
+ - [Deps] update `es-abstract` [`6ab096d`](https://github.com/ljharb/side-channel/commit/6ab096d9de2b482cf5e0717e34e212f5b2b9bc9a)
34
+ - [Dev Deps] update `tape` [`9dc174c`](https://github.com/ljharb/side-channel/commit/9dc174cc651dfd300b4b72da936a0a7eda5f9452)
35
+ - [Deps] update `es-abstract` [`431d0f0`](https://github.com/ljharb/side-channel/commit/431d0f0ff11fbd2ae6f3115582a356d3a1cfce82)
36
+ - [Deps] update `es-abstract` [`49869fd`](https://github.com/ljharb/side-channel/commit/49869fd323bf4453f0ba515c0fb265cf5ab7b932)
37
+ - [meta] Add package.json to package's exports [`77d9cdc`](https://github.com/ljharb/side-channel/commit/77d9cdceb2a9e47700074f2ae0c0a202e7dac0d4)
38
+
39
+ ## [v1.0.2](https://github.com/ljharb/side-channel/compare/v1.0.1...v1.0.2) - 2019-12-20
40
+
41
+ ### Commits
42
+
43
+ - [Dev Deps] update `@ljharb/eslint-config`, `tape` [`4a526df`](https://github.com/ljharb/side-channel/commit/4a526df44e4701566ed001ec78546193f818b082)
44
+ - [Deps] update `es-abstract` [`d4f6e62`](https://github.com/ljharb/side-channel/commit/d4f6e629b6fb93a07415db7f30d3c90fd7f264fe)
45
+
46
+ ## [v1.0.1](https://github.com/ljharb/side-channel/compare/v1.0.0...v1.0.1) - 2019-12-01
47
+
48
+ ### Commits
49
+
50
+ - [Fix] add missing "exports" [`d212907`](https://github.com/ljharb/side-channel/commit/d2129073abf0701a5343bf28aa2145617604dc2e)
51
+
52
+ ## v1.0.0 - 2019-12-01
53
+
54
+ ### Commits
55
+
56
+ - Initial implementation [`dbebd3a`](https://github.com/ljharb/side-channel/commit/dbebd3a4b5ed64242f9a6810efe7c4214cd8cde4)
57
+ - Initial tests [`73bdefe`](https://github.com/ljharb/side-channel/commit/73bdefe568c9076cf8c0b8719bc2141aec0e19b8)
58
+ - Initial commit [`43c03e1`](https://github.com/ljharb/side-channel/commit/43c03e1c2849ec50a87b7a5cd76238a62b0b8770)
59
+ - npm init [`5c090a7`](https://github.com/ljharb/side-channel/commit/5c090a765d66a5527d9889b89aeff78dee91348c)
60
+ - [meta] add `auto-changelog` [`a5c4e56`](https://github.com/ljharb/side-channel/commit/a5c4e5675ec02d5eb4d84b4243aeea2a1d38fbec)
61
+ - [actions] add automatic rebasing / merge commit blocking [`bab1683`](https://github.com/ljharb/side-channel/commit/bab1683d8f9754b086e94397699fdc645e0d7077)
62
+ - [meta] add `funding` field; create FUNDING.yml [`63d7aea`](https://github.com/ljharb/side-channel/commit/63d7aeaf34f5650650ae97ca4b9fae685bd0937c)
63
+ - [Tests] add `npm run lint` [`46a5a81`](https://github.com/ljharb/side-channel/commit/46a5a81705cd2664f83df232c01dbbf2ee952885)
64
+ - Only apps should have lockfiles [`8b16b03`](https://github.com/ljharb/side-channel/commit/8b16b0305f00895d90c4e2e5773c854cfea0e448)
65
+ - [meta] add `safe-publish-latest` [`2f098ef`](https://github.com/ljharb/side-channel/commit/2f098ef092a39399cfe548b19a1fc03c2fd2f490)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Jordan Harband
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # side-channel
2
+ Store information about any JS value in a side channel. Uses WeakMap if available.
@@ -0,0 +1,124 @@
1
+ 'use strict';
2
+
3
+ var GetIntrinsic = require('get-intrinsic');
4
+ var callBound = require('call-bind/callBound');
5
+ var inspect = require('object-inspect');
6
+
7
+ var $TypeError = GetIntrinsic('%TypeError%');
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);
17
+
18
+ /*
19
+ * This function traverses the list returning the node corresponding to the
20
+ * given key.
21
+ *
22
+ * That node is also moved to the head of the list, so that if it's accessed
23
+ * again we don't need to traverse the whole list. By doing so, all the recently
24
+ * used nodes can be accessed relatively quickly.
25
+ */
26
+ var listGetNode = function (list, key) { // eslint-disable-line consistent-return
27
+ for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
28
+ if (curr.key === key) {
29
+ prev.next = curr.next;
30
+ curr.next = list.next;
31
+ list.next = curr; // eslint-disable-line no-param-reassign
32
+ return curr;
33
+ }
34
+ }
35
+ };
36
+
37
+ var listGet = function (objects, key) {
38
+ var node = listGetNode(objects, key);
39
+ return node && node.value;
40
+ };
41
+ var listSet = function (objects, key, value) {
42
+ var node = listGetNode(objects, key);
43
+ if (node) {
44
+ node.value = value;
45
+ } else {
46
+ // Prepend the new node to the beginning of the list
47
+ objects.next = { // eslint-disable-line no-param-reassign
48
+ key: key,
49
+ next: objects.next,
50
+ value: value
51
+ };
52
+ }
53
+ };
54
+ var listHas = function (objects, key) {
55
+ return !!listGetNode(objects, key);
56
+ };
57
+
58
+ module.exports = function getSideChannel() {
59
+ var $wm;
60
+ var $m;
61
+ var $o;
62
+ var channel = {
63
+ assert: function (key) {
64
+ if (!channel.has(key)) {
65
+ throw new $TypeError('Side channel does not contain ' + inspect(key));
66
+ }
67
+ },
68
+ get: function (key) { // eslint-disable-line consistent-return
69
+ if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
70
+ if ($wm) {
71
+ return $weakMapGet($wm, key);
72
+ }
73
+ } else if ($Map) {
74
+ if ($m) {
75
+ return $mapGet($m, key);
76
+ }
77
+ } else {
78
+ if ($o) { // eslint-disable-line no-lonely-if
79
+ return listGet($o, key);
80
+ }
81
+ }
82
+ },
83
+ has: function (key) {
84
+ if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
85
+ if ($wm) {
86
+ return $weakMapHas($wm, key);
87
+ }
88
+ } else if ($Map) {
89
+ if ($m) {
90
+ return $mapHas($m, key);
91
+ }
92
+ } else {
93
+ if ($o) { // eslint-disable-line no-lonely-if
94
+ return listHas($o, key);
95
+ }
96
+ }
97
+ return false;
98
+ },
99
+ set: function (key, value) {
100
+ if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
101
+ if (!$wm) {
102
+ $wm = new $WeakMap();
103
+ }
104
+ $weakMapSet($wm, key, value);
105
+ } else if ($Map) {
106
+ if (!$m) {
107
+ $m = new $Map();
108
+ }
109
+ $mapSet($m, key, value);
110
+ } else {
111
+ if (!$o) {
112
+ /*
113
+ * Initialize the linked list as an empty node, so that we don't have
114
+ * to special-case handling of the first node: we can always refer to
115
+ * it as (previous node).next, instead of something like (list).head
116
+ */
117
+ $o = { key: {}, next: null };
118
+ }
119
+ listSet($o, key, value);
120
+ }
121
+ }
122
+ };
123
+ return channel;
124
+ };
@@ -0,0 +1,53 @@
1
+ {
2
+ "root": true,
3
+ "extends": "@ljharb",
4
+ "rules": {
5
+ "complexity": 0,
6
+ "func-style": [2, "declaration"],
7
+ "indent": [2, 4],
8
+ "max-lines": 1,
9
+ "max-lines-per-function": 1,
10
+ "max-params": [2, 4],
11
+ "max-statements": 0,
12
+ "max-statements-per-line": [2, { "max": 2 }],
13
+ "no-magic-numbers": 0,
14
+ "no-param-reassign": 1,
15
+ "strict": 0, // TODO
16
+ },
17
+ "overrides": [
18
+ {
19
+ "files": ["test/**", "test-*", "example/**"],
20
+ "extends": "@ljharb/eslint-config/tests",
21
+ "rules": {
22
+ "id-length": 0,
23
+ },
24
+ },
25
+ {
26
+ "files": ["example/**"],
27
+ "rules": {
28
+ "no-console": 0,
29
+ },
30
+ },
31
+ {
32
+ "files": ["test/browser/**"],
33
+ "env": {
34
+ "browser": true,
35
+ },
36
+ },
37
+ {
38
+ "files": ["test/bigint*"],
39
+ "rules": {
40
+ "new-cap": [2, { "capIsNewExceptions": ["BigInt"] }],
41
+ },
42
+ },
43
+ {
44
+ "files": "index.js",
45
+ "globals": {
46
+ "HTMLElement": false,
47
+ },
48
+ "rules": {
49
+ "no-use-before-define": 1,
50
+ },
51
+ },
52
+ ],
53
+ }
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [ljharb]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: npm/object-inspect
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
@@ -0,0 +1,13 @@
1
+ {
2
+ "all": true,
3
+ "check-coverage": false,
4
+ "instrumentation": false,
5
+ "sourceMap": false,
6
+ "reporter": ["text-summary", "text", "html", "json"],
7
+ "exclude": [
8
+ "coverage",
9
+ "example",
10
+ "test",
11
+ "test-core-js.js"
12
+ ]
13
+ }