typespeed 2.0.21 → 2.0.23

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 (219) hide show
  1. package/dist/core.decorator.js +1 -30
  2. package/dist/default/default-authentication.class.js +25 -0
  3. package/dist/default/express-server.class.js +11 -4
  4. package/dist/default/log-default.class.js +0 -6
  5. package/dist/factory/authentication-factory.class.js +11 -0
  6. package/dist/factory/log-factory.class.js +9 -0
  7. package/dist/route.decorator.js +92 -2
  8. package/dist/typespeed.d.ts +40 -3
  9. package/dist/typespeed.js +3 -1
  10. package/package.json +1 -1
  11. package/src/core.decorator.ts +1 -29
  12. package/src/default/default-authentication.class.ts +10 -0
  13. package/src/default/express-server.class.ts +12 -5
  14. package/src/default/log-default.class.ts +0 -10
  15. package/src/factory/authentication-factory.class.ts +9 -0
  16. package/src/factory/log-factory.class.ts +9 -2
  17. package/src/route.decorator.ts +91 -3
  18. package/src/typespeed.d.ts +40 -3
  19. package/src/typespeed.ts +1 -0
  20. package/test/node_modules/.package-lock.json +65 -101
  21. package/test/node_modules/@types/body-parser/LICENSE +21 -0
  22. package/test/node_modules/@types/body-parser/README.md +16 -0
  23. package/test/node_modules/@types/body-parser/index.d.ts +107 -0
  24. package/test/node_modules/@types/body-parser/package.json +58 -0
  25. package/test/node_modules/@types/connect/LICENSE +21 -0
  26. package/test/node_modules/@types/connect/README.md +16 -0
  27. package/test/node_modules/@types/connect/index.d.ts +93 -0
  28. package/test/node_modules/@types/connect/package.json +32 -0
  29. package/test/node_modules/@types/express/LICENSE +21 -0
  30. package/test/node_modules/@types/express/README.md +16 -0
  31. package/test/node_modules/@types/express/index.d.ts +136 -0
  32. package/test/node_modules/@types/express/package.json +45 -0
  33. package/test/node_modules/@types/express-serve-static-core/LICENSE +21 -0
  34. package/test/node_modules/@types/express-serve-static-core/README.md +16 -0
  35. package/test/node_modules/@types/express-serve-static-core/index.d.ts +1281 -0
  36. package/test/node_modules/@types/express-serve-static-core/package.json +55 -0
  37. package/test/node_modules/@types/mime/LICENSE +21 -0
  38. package/test/node_modules/@types/mime/Mime.d.ts +10 -0
  39. package/test/node_modules/@types/mime/README.md +16 -0
  40. package/test/node_modules/@types/mime/index.d.ts +35 -0
  41. package/test/node_modules/@types/mime/lite.d.ts +7 -0
  42. package/test/node_modules/@types/mime/package.json +29 -0
  43. package/test/node_modules/@types/qs/LICENSE +21 -0
  44. package/test/node_modules/@types/qs/README.md +16 -0
  45. package/test/node_modules/@types/qs/index.d.ts +62 -0
  46. package/test/node_modules/@types/qs/package.json +65 -0
  47. package/test/node_modules/@types/range-parser/LICENSE +21 -0
  48. package/test/node_modules/@types/range-parser/README.md +55 -0
  49. package/test/node_modules/@types/range-parser/index.d.ts +35 -0
  50. package/test/node_modules/@types/range-parser/package.json +25 -0
  51. package/test/node_modules/@types/send/LICENSE +21 -0
  52. package/test/node_modules/@types/send/README.md +16 -0
  53. package/test/node_modules/@types/send/index.d.ts +231 -0
  54. package/test/node_modules/@types/send/package.json +33 -0
  55. package/test/node_modules/@types/serve-static/LICENSE +21 -0
  56. package/test/node_modules/@types/serve-static/README.md +16 -0
  57. package/test/node_modules/@types/serve-static/index.d.ts +113 -0
  58. package/test/node_modules/@types/serve-static/package.json +38 -0
  59. package/test/src/config.json +5 -0
  60. package/test/src/custom-log.class.ts +6 -0
  61. package/test/src/jwt-authentication.class.ts +29 -0
  62. package/test/src/test-request.class.ts +36 -0
  63. package/test/node_modules/@acuminous/bitsyntax/.github/workflows/node-js-ci.yml +0 -17
  64. package/test/node_modules/@acuminous/bitsyntax/.github/workflows/node-js-publish.yml +0 -30
  65. package/test/node_modules/@acuminous/bitsyntax/LICENSE +0 -6
  66. package/test/node_modules/@acuminous/bitsyntax/LICENSE-MIT +0 -21
  67. package/test/node_modules/@acuminous/bitsyntax/Makefile +0 -15
  68. package/test/node_modules/@acuminous/bitsyntax/README.md +0 -308
  69. package/test/node_modules/@acuminous/bitsyntax/index.js +0 -10
  70. package/test/node_modules/@acuminous/bitsyntax/lib/compile.js +0 -303
  71. package/test/node_modules/@acuminous/bitsyntax/lib/constructor.js +0 -142
  72. package/test/node_modules/@acuminous/bitsyntax/lib/grammar.pegjs +0 -67
  73. package/test/node_modules/@acuminous/bitsyntax/lib/interp.js +0 -232
  74. package/test/node_modules/@acuminous/bitsyntax/lib/parse.js +0 -32
  75. package/test/node_modules/@acuminous/bitsyntax/lib/parser.js +0 -1173
  76. package/test/node_modules/@acuminous/bitsyntax/lib/pattern.js +0 -119
  77. package/test/node_modules/@acuminous/bitsyntax/package.json +0 -36
  78. package/test/node_modules/@acuminous/bitsyntax/test/consing.test.js +0 -50
  79. package/test/node_modules/@acuminous/bitsyntax/test/matching.test.js +0 -193
  80. package/test/node_modules/amqplib/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  81. package/test/node_modules/amqplib/.github/workflows/test.yml +0 -38
  82. package/test/node_modules/amqplib/CHANGELOG.md +0 -430
  83. package/test/node_modules/amqplib/LICENSE +0 -6
  84. package/test/node_modules/amqplib/LICENSE-MIT +0 -21
  85. package/test/node_modules/amqplib/Makefile +0 -47
  86. package/test/node_modules/amqplib/README.md +0 -157
  87. package/test/node_modules/amqplib/bin/generate-defs.js +0 -722
  88. package/test/node_modules/amqplib/callback_api.js +0 -22
  89. package/test/node_modules/amqplib/channel_api.js +0 -16
  90. package/test/node_modules/amqplib/examples/headers.js +0 -42
  91. package/test/node_modules/amqplib/examples/receive_generator.js +0 -39
  92. package/test/node_modules/amqplib/examples/send_generators.js +0 -42
  93. package/test/node_modules/amqplib/examples/ssl.js +0 -64
  94. package/test/node_modules/amqplib/examples/tutorials/README.md +0 -93
  95. package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log.js +0 -28
  96. package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log_direct.js +0 -30
  97. package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log_topic.js +0 -27
  98. package/test/node_modules/amqplib/examples/tutorials/callback_api/new_task.js +0 -27
  99. package/test/node_modules/amqplib/examples/tutorials/callback_api/receive.js +0 -30
  100. package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs.js +0 -36
  101. package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs_direct.js +0 -56
  102. package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs_topic.js +0 -55
  103. package/test/node_modules/amqplib/examples/tutorials/callback_api/rpc_client.js +0 -49
  104. package/test/node_modules/amqplib/examples/tutorials/callback_api/rpc_server.js +0 -45
  105. package/test/node_modules/amqplib/examples/tutorials/callback_api/send.js +0 -29
  106. package/test/node_modules/amqplib/examples/tutorials/callback_api/worker.js +0 -35
  107. package/test/node_modules/amqplib/examples/tutorials/emit_log.js +0 -19
  108. package/test/node_modules/amqplib/examples/tutorials/emit_log_direct.js +0 -20
  109. package/test/node_modules/amqplib/examples/tutorials/emit_log_topic.js +0 -19
  110. package/test/node_modules/amqplib/examples/tutorials/new_task.js +0 -18
  111. package/test/node_modules/amqplib/examples/tutorials/package.json +0 -16
  112. package/test/node_modules/amqplib/examples/tutorials/receive.js +0 -21
  113. package/test/node_modules/amqplib/examples/tutorials/receive_logs.js +0 -28
  114. package/test/node_modules/amqplib/examples/tutorials/receive_logs_direct.js +0 -44
  115. package/test/node_modules/amqplib/examples/tutorials/receive_logs_topic.js +0 -43
  116. package/test/node_modules/amqplib/examples/tutorials/rpc_client.js +0 -52
  117. package/test/node_modules/amqplib/examples/tutorials/rpc_server.js +0 -39
  118. package/test/node_modules/amqplib/examples/tutorials/send.js +0 -23
  119. package/test/node_modules/amqplib/examples/tutorials/worker.js +0 -28
  120. package/test/node_modules/amqplib/examples/waitForConfirms.js +0 -22
  121. package/test/node_modules/amqplib/lib/api_args.js +0 -314
  122. package/test/node_modules/amqplib/lib/bitset.js +0 -130
  123. package/test/node_modules/amqplib/lib/callback_model.js +0 -327
  124. package/test/node_modules/amqplib/lib/channel.js +0 -499
  125. package/test/node_modules/amqplib/lib/channel_model.js +0 -302
  126. package/test/node_modules/amqplib/lib/codec.js +0 -321
  127. package/test/node_modules/amqplib/lib/connect.js +0 -189
  128. package/test/node_modules/amqplib/lib/connection.js +0 -663
  129. package/test/node_modules/amqplib/lib/credentials.js +0 -42
  130. package/test/node_modules/amqplib/lib/defs.js +0 -4966
  131. package/test/node_modules/amqplib/lib/error.js +0 -24
  132. package/test/node_modules/amqplib/lib/format.js +0 -40
  133. package/test/node_modules/amqplib/lib/frame.js +0 -113
  134. package/test/node_modules/amqplib/lib/heartbeat.js +0 -89
  135. package/test/node_modules/amqplib/lib/mux.js +0 -129
  136. package/test/node_modules/amqplib/package.json +0 -37
  137. package/test/node_modules/amqplib/test/bitset.js +0 -69
  138. package/test/node_modules/amqplib/test/callback_api.js +0 -312
  139. package/test/node_modules/amqplib/test/channel.js +0 -621
  140. package/test/node_modules/amqplib/test/channel_api.js +0 -596
  141. package/test/node_modules/amqplib/test/codec.js +0 -237
  142. package/test/node_modules/amqplib/test/connect.js +0 -197
  143. package/test/node_modules/amqplib/test/connection.js +0 -390
  144. package/test/node_modules/amqplib/test/data.js +0 -254
  145. package/test/node_modules/amqplib/test/frame.js +0 -198
  146. package/test/node_modules/amqplib/test/mux.js +0 -204
  147. package/test/node_modules/amqplib/test/util.js +0 -219
  148. package/test/node_modules/buffer-more-ints/.travis.yml +0 -6
  149. package/test/node_modules/buffer-more-ints/LICENSE +0 -19
  150. package/test/node_modules/buffer-more-ints/README.md +0 -69
  151. package/test/node_modules/buffer-more-ints/buffer-more-ints-tests.js +0 -183
  152. package/test/node_modules/buffer-more-ints/buffer-more-ints.js +0 -432
  153. package/test/node_modules/buffer-more-ints/package.json +0 -19
  154. package/test/node_modules/buffer-more-ints/polyfill.js +0 -71
  155. package/test/node_modules/core-util-is/LICENSE +0 -19
  156. package/test/node_modules/core-util-is/README.md +0 -3
  157. package/test/node_modules/core-util-is/lib/util.js +0 -107
  158. package/test/node_modules/core-util-is/package.json +0 -38
  159. package/test/node_modules/debug/LICENSE +0 -20
  160. package/test/node_modules/debug/README.md +0 -481
  161. package/test/node_modules/debug/package.json +0 -59
  162. package/test/node_modules/debug/src/browser.js +0 -269
  163. package/test/node_modules/debug/src/common.js +0 -274
  164. package/test/node_modules/debug/src/index.js +0 -10
  165. package/test/node_modules/debug/src/node.js +0 -263
  166. package/test/node_modules/inherits/LICENSE +0 -16
  167. package/test/node_modules/inherits/README.md +0 -42
  168. package/test/node_modules/inherits/inherits.js +0 -9
  169. package/test/node_modules/inherits/inherits_browser.js +0 -27
  170. package/test/node_modules/inherits/package.json +0 -29
  171. package/test/node_modules/isarray/README.md +0 -54
  172. package/test/node_modules/isarray/build/build.js +0 -209
  173. package/test/node_modules/isarray/component.json +0 -19
  174. package/test/node_modules/isarray/index.js +0 -3
  175. package/test/node_modules/isarray/package.json +0 -25
  176. package/test/node_modules/ms/index.js +0 -162
  177. package/test/node_modules/ms/license.md +0 -21
  178. package/test/node_modules/ms/package.json +0 -37
  179. package/test/node_modules/ms/readme.md +0 -60
  180. package/test/node_modules/querystringify/LICENSE +0 -22
  181. package/test/node_modules/querystringify/README.md +0 -61
  182. package/test/node_modules/querystringify/index.js +0 -118
  183. package/test/node_modules/querystringify/package.json +0 -38
  184. package/test/node_modules/readable-stream/LICENSE +0 -18
  185. package/test/node_modules/readable-stream/README.md +0 -15
  186. package/test/node_modules/readable-stream/duplex.js +0 -1
  187. package/test/node_modules/readable-stream/float.patch +0 -923
  188. package/test/node_modules/readable-stream/lib/_stream_duplex.js +0 -89
  189. package/test/node_modules/readable-stream/lib/_stream_passthrough.js +0 -46
  190. package/test/node_modules/readable-stream/lib/_stream_readable.js +0 -951
  191. package/test/node_modules/readable-stream/lib/_stream_transform.js +0 -209
  192. package/test/node_modules/readable-stream/lib/_stream_writable.js +0 -477
  193. package/test/node_modules/readable-stream/package.json +0 -32
  194. package/test/node_modules/readable-stream/passthrough.js +0 -1
  195. package/test/node_modules/readable-stream/readable.js +0 -10
  196. package/test/node_modules/readable-stream/transform.js +0 -1
  197. package/test/node_modules/readable-stream/writable.js +0 -1
  198. package/test/node_modules/requires-port/.travis.yml +0 -19
  199. package/test/node_modules/requires-port/LICENSE +0 -22
  200. package/test/node_modules/requires-port/README.md +0 -47
  201. package/test/node_modules/requires-port/index.js +0 -38
  202. package/test/node_modules/requires-port/package.json +0 -47
  203. package/test/node_modules/requires-port/test.js +0 -98
  204. package/test/node_modules/safe-buffer/LICENSE +0 -21
  205. package/test/node_modules/safe-buffer/README.md +0 -584
  206. package/test/node_modules/safe-buffer/index.d.ts +0 -187
  207. package/test/node_modules/safe-buffer/index.js +0 -62
  208. package/test/node_modules/safe-buffer/package.json +0 -37
  209. package/test/node_modules/string_decoder/LICENSE +0 -20
  210. package/test/node_modules/string_decoder/README.md +0 -7
  211. package/test/node_modules/string_decoder/index.js +0 -221
  212. package/test/node_modules/string_decoder/package.json +0 -25
  213. package/test/node_modules/url-parse/LICENSE +0 -22
  214. package/test/node_modules/url-parse/README.md +0 -153
  215. package/test/node_modules/url-parse/dist/url-parse.js +0 -755
  216. package/test/node_modules/url-parse/dist/url-parse.min.js +0 -1
  217. package/test/node_modules/url-parse/dist/url-parse.min.js.map +0 -1
  218. package/test/node_modules/url-parse/index.js +0 -589
  219. package/test/node_modules/url-parse/package.json +0 -49
@@ -1,24 +0,0 @@
1
- var inherits = require('util').inherits;
2
-
3
- function trimStack(stack, num) {
4
- return stack && stack.split('\n').slice(num).join('\n');
5
- }
6
-
7
- function IllegalOperationError(msg, stack) {
8
- var tmp = new Error();
9
- this.message = msg;
10
- this.stack = this.toString() + '\n' + trimStack(tmp.stack, 2);
11
- this.stackAtStateChange = stack;
12
- }
13
- inherits(IllegalOperationError, Error);
14
-
15
- IllegalOperationError.prototype.name = 'IllegalOperationError';
16
-
17
- function stackCapture(reason) {
18
- var e = new Error();
19
- return 'Stack capture: ' + reason + '\n' +
20
- trimStack(e.stack, 2);
21
- }
22
-
23
- module.exports.IllegalOperationError = IllegalOperationError;
24
- module.exports.stackCapture = stackCapture;
@@ -1,40 +0,0 @@
1
- //
2
- //
3
- //
4
-
5
- // Stringifying various things
6
-
7
- 'use strict';
8
-
9
- var defs = require('./defs');
10
- var format = require('util').format;
11
- var inherits = require('util').inherits;
12
- var HEARTBEAT = require('./frame').HEARTBEAT;
13
-
14
- module.exports.closeMessage = function(close) {
15
- var code = close.fields.replyCode;
16
- return format('%d (%s) with message "%s"',
17
- code, defs.constant_strs[code],
18
- close.fields.replyText);
19
- }
20
-
21
- module.exports.methodName = function(id) {
22
- return defs.info(id).name;
23
- };
24
-
25
- module.exports.inspect = function(frame, showFields) {
26
- if (frame === HEARTBEAT) {
27
- return '<Heartbeat>';
28
- }
29
- else if (!frame.id) {
30
- return format('<Content channel:%d size:%d>',
31
- frame.channel, frame.size);
32
- }
33
- else {
34
- var info = defs.info(frame.id);
35
- return format('<%s channel:%d%s>', info.name, frame.channel,
36
- (showFields)
37
- ? ' ' + JSON.stringify(frame.fields, undefined, 2)
38
- : '');
39
- }
40
- }
@@ -1,113 +0,0 @@
1
- // The river sweeps through
2
- // Silt and twigs, gravel and leaves
3
- // Driving the wheel on
4
-
5
- 'use strict';
6
-
7
- var defs = require('./defs');
8
- var constants = defs.constants;
9
- var decode = defs.decode;
10
-
11
- var Bits = require('@acuminous/bitsyntax');
12
-
13
- module.exports.PROTOCOL_HEADER = "AMQP" + String.fromCharCode(0, 0, 9, 1);
14
-
15
- /*
16
- Frame format:
17
-
18
- 0 1 3 7 size+7 size+8
19
- +------+---------+-------------+ +------------+ +-----------+
20
- | type | channel | size | | payload | | frame-end |
21
- +------+---------+-------------+ +------------+ +-----------+
22
- octet short long size octets octet
23
-
24
- In general I want to know those first three things straight away, so I
25
- can discard frames early.
26
-
27
- */
28
-
29
- // framing constants
30
- var FRAME_METHOD = constants.FRAME_METHOD,
31
- FRAME_HEARTBEAT = constants.FRAME_HEARTBEAT,
32
- FRAME_HEADER = constants.FRAME_HEADER,
33
- FRAME_BODY = constants.FRAME_BODY,
34
- FRAME_END = constants.FRAME_END;
35
-
36
- var bodyCons =
37
- Bits.builder(FRAME_BODY,
38
- 'channel:16, size:32, payload:size/binary',
39
- FRAME_END);
40
-
41
- // %%% TESTME possibly better to cons the first bit and write the
42
- // second directly, in the absence of IO lists
43
- module.exports.makeBodyFrame = function(channel, payload) {
44
- return bodyCons({channel: channel, size: payload.length, payload: payload});
45
- };
46
-
47
- var frameHeaderPattern = Bits.matcher('type:8', 'channel:16',
48
- 'size:32', 'rest/binary');
49
-
50
- function parseFrame(bin, max) {
51
- var fh = frameHeaderPattern(bin);
52
- if (fh) {
53
- var size = fh.size, rest = fh.rest;
54
- if (size > max) {
55
- throw new Error('Frame size exceeds frame max');
56
- }
57
- else if (rest.length > size) {
58
- if (rest[size] !== FRAME_END)
59
- throw new Error('Invalid frame');
60
-
61
- return {
62
- type: fh.type,
63
- channel: fh.channel,
64
- size: size,
65
- payload: rest.slice(0, size),
66
- rest: rest.slice(size + 1)
67
- };
68
- }
69
- }
70
- return false;
71
- }
72
-
73
- module.exports.parseFrame = parseFrame;
74
-
75
- var headerPattern = Bits.matcher('class:16',
76
- '_weight:16',
77
- 'size:64',
78
- 'flagsAndfields/binary');
79
-
80
- var methodPattern = Bits.matcher('id:32, args/binary');
81
-
82
- var HEARTBEAT = {channel: 0};
83
-
84
- module.exports.decodeFrame = function(frame) {
85
- var payload = frame.payload;
86
- switch (frame.type) {
87
- case FRAME_METHOD:
88
- var idAndArgs = methodPattern(payload);
89
- var id = idAndArgs.id;
90
- var fields = decode(id, idAndArgs.args);
91
- return {id: id, channel: frame.channel, fields: fields};
92
- case FRAME_HEADER:
93
- var parts = headerPattern(payload);
94
- var id = parts['class'];
95
- var fields = decode(id, parts.flagsAndfields);
96
- return {id: id, channel: frame.channel,
97
- size: parts.size, fields: fields};
98
- case FRAME_BODY:
99
- return {channel: frame.channel, content: frame.payload};
100
- case FRAME_HEARTBEAT:
101
- return HEARTBEAT;
102
- default:
103
- throw new Error('Unknown frame type ' + frame.type);
104
- }
105
- }
106
-
107
- // encoded heartbeat
108
- module.exports.HEARTBEAT_BUF = Buffer.from([constants.FRAME_HEARTBEAT,
109
- 0, 0, 0, 0, // size = 0
110
- 0, 0, // channel = 0
111
- constants.FRAME_END]);
112
-
113
- module.exports.HEARTBEAT = HEARTBEAT;
@@ -1,89 +0,0 @@
1
- //
2
- //
3
- //
4
-
5
- // Heartbeats. In AMQP both clients and servers may expect a heartbeat
6
- // frame if there is no activity on the connection for a negotiated
7
- // period of time. If there's no activity for two such intervals, the
8
- // server or client is allowed to close the connection on the
9
- // presumption that the other party is dead.
10
- //
11
- // The client has two jobs here: the first is to send a heartbeat
12
- // frame if it's not sent any frames for a while, so that the server
13
- // doesn't think it's dead; the second is to check periodically that
14
- // it's seen activity from the server, and to advise if there doesn't
15
- // appear to have been any for over two intervals.
16
- //
17
- // Node.JS timers are a bit unreliable, in that they endeavour only to
18
- // fire at some indeterminate point *after* the given time (rather
19
- // gives the lie to 'realtime', dunnit). Because the scheduler is just
20
- // an event loop, it's quite easy to delay timers indefinitely by
21
- // reacting to some I/O with a lot of computation.
22
- //
23
- // To mitigate this I need a bit of creative interpretation:
24
- //
25
- // - I'll schedule a server activity check for every `interval`, and
26
- // check just how much time has passed. It will overshoot by at
27
- // least a small margin; modulo missing timer deadlines, it'll
28
- // notice between two and three intervals after activity actually
29
- // stops (otherwise, at some point after two intervals).
30
- //
31
- // - Every `interval / 2` I'll check that we've sent something since
32
- // the last check, and if not, send a heartbeat frame. If we're
33
- // really too busy to even run the check for two whole heartbeat
34
- // intervals, there must be a lot of I (but not O, at least not on
35
- // the connection), or computation, in which case perhaps it's best
36
- // the server cuts us off anyway. Why `interval / 2`? Because the
37
- // edge case is that the client sent a frame just after a
38
- // heartbeat, which would mean I only send one after almost two
39
- // intervals. (NB a heartbeat counts as a send, so it'll be checked
40
- // at least twice before sending another)
41
- //
42
- // This design is based largely on RabbitMQ's heartbeating:
43
- // https://github.com/rabbitmq/rabbitmq-common/blob/master/src/rabbit_heartbeat.erl
44
-
45
- // %% Yes, I could apply the same 'actually passage of time' thing to
46
- // %% send as well as to recv.
47
-
48
- 'use strict';
49
-
50
- var inherits = require('util').inherits;
51
- var EventEmitter = require('events').EventEmitter;
52
-
53
- // Exported so that we can mess with it in tests
54
- module.exports.UNITS_TO_MS = 1000;
55
-
56
- function Heart(interval, checkSend, checkRecv) {
57
- EventEmitter.call(this);
58
- this.interval = interval;
59
-
60
- var intervalMs = interval * module.exports.UNITS_TO_MS;
61
- // Function#bind is my new best friend
62
- var beat = this.emit.bind(this, 'beat');
63
- var timeout = this.emit.bind(this, 'timeout');
64
-
65
- this.sendTimer = setInterval(
66
- this.runHeartbeat.bind(this, checkSend, beat), intervalMs / 2);
67
-
68
- // A timeout occurs if I see nothing for *two consecutive* intervals
69
- var recvMissed = 0;
70
- function missedTwo() {
71
- if (!checkRecv()) return (++recvMissed < 2);
72
- else { recvMissed = 0; return true; }
73
- }
74
- this.recvTimer = setInterval(
75
- this.runHeartbeat.bind(this, missedTwo, timeout), intervalMs);
76
- }
77
- inherits(Heart, EventEmitter);
78
-
79
- module.exports.Heart = Heart;
80
-
81
- Heart.prototype.clear = function() {
82
- clearInterval(this.sendTimer);
83
- clearInterval(this.recvTimer);
84
- };
85
-
86
- Heart.prototype.runHeartbeat = function(check, fail) {
87
- // Have we seen activity?
88
- if (!check()) fail();
89
- };
@@ -1,129 +0,0 @@
1
- //
2
- //
3
- //
4
-
5
- 'use strict';
6
-
7
- // A Mux is an object into which other readable streams may be piped;
8
- // it then writes 'packets' from the upstreams to the given
9
- // downstream.
10
-
11
- var assert = require('assert');
12
-
13
- var schedule = (typeof setImmediate === 'function') ?
14
- setImmediate : process.nextTick;
15
-
16
- function Mux(downstream) {
17
- this.newStreams = [];
18
- this.oldStreams = [];
19
- this.blocked = false;
20
- this.scheduledRead = false;
21
-
22
- this.out = downstream;
23
- var self = this;
24
- downstream.on('drain', function() {
25
- self.blocked = false;
26
- self._readIncoming();
27
- });
28
- }
29
-
30
- // There are 2 states we can be in:
31
-
32
- // - waiting for outbound capacity, which will be signalled by a
33
- // - 'drain' event on the downstream; or,
34
-
35
- // - no packets to send, waiting for an inbound buffer to have
36
- // packets, which will be signalled by a 'readable' event
37
-
38
- // If we write all packets available whenever there is outbound
39
- // capacity, we will either run out of outbound capacity (`#write`
40
- // returns false), or run out of packets (all calls to an
41
- // `inbound.read()` have returned null).
42
-
43
- Mux.prototype._readIncoming = function() {
44
-
45
- // We may be sent here speculatively, if an incoming stream has
46
- // become readable
47
- if (this.blocked) return;
48
-
49
- var accepting = true;
50
- var out = this.out;
51
-
52
- // Try to read a chunk from each stream in turn, until all streams
53
- // are empty, or we exhaust our ability to accept chunks.
54
- function roundrobin(streams) {
55
- var s;
56
- while (accepting && (s = streams.shift())) {
57
- var chunk = s.read();
58
- if (chunk !== null) {
59
- accepting = out.write(chunk);
60
- streams.push(s);
61
- }
62
- }
63
- }
64
-
65
- roundrobin(this.newStreams);
66
-
67
- // Either we exhausted the new queues, or we ran out of capacity. If
68
- // we ran out of capacity, all the remaining new streams (i.e.,
69
- // those with packets left) become old streams. This effectively
70
- // prioritises streams that keep their buffers close to empty over
71
- // those that are constantly near full.
72
-
73
- if (accepting) { // all new queues are exhausted, write as many as
74
- // we can from the old streams
75
- assert.equal(0, this.newStreams.length);
76
- roundrobin(this.oldStreams);
77
- }
78
- else { // ran out of room
79
- assert(this.newStreams.length > 0, "Expect some new streams to remain");
80
- Array.prototype.push.apply(this.oldStreams, this.newStreams);
81
- this.newStreams = [];
82
- }
83
- // We may have exhausted all the old queues, or run out of room;
84
- // either way, all we need to do is record whether we have capacity
85
- // or not, so any speculative reads will know
86
- this.blocked = !accepting;
87
- };
88
-
89
- Mux.prototype._scheduleRead = function() {
90
- var self = this;
91
-
92
- if (!self.scheduledRead) {
93
- schedule(function() {
94
- self.scheduledRead = false;
95
- self._readIncoming();
96
- });
97
- self.scheduledRead = true;
98
- }
99
- };
100
-
101
- Mux.prototype.pipeFrom = function(readable) {
102
- var self = this;
103
-
104
- function enqueue() {
105
- self.newStreams.push(readable);
106
- self._scheduleRead();
107
- }
108
-
109
- function cleanup() {
110
- readable.removeListener('readable', enqueue);
111
- readable.removeListener('error', cleanup);
112
- readable.removeListener('end', cleanup);
113
- readable.removeListener('unpipeFrom', cleanupIfMe);
114
- }
115
- function cleanupIfMe(dest) {
116
- if (dest === self) cleanup();
117
- }
118
-
119
- readable.on('unpipeFrom', cleanupIfMe);
120
- readable.on('end', cleanup);
121
- readable.on('error', cleanup);
122
- readable.on('readable', enqueue);
123
- };
124
-
125
- Mux.prototype.unpipeFrom = function(readable) {
126
- readable.emit('unpipeFrom', this);
127
- };
128
-
129
- module.exports.Mux = Mux;
@@ -1,37 +0,0 @@
1
- {
2
- "name": "amqplib",
3
- "homepage": "http://amqp-node.github.io/amqplib/",
4
- "main": "./channel_api.js",
5
- "version": "0.10.3",
6
- "description": "An AMQP 0-9-1 (e.g., RabbitMQ) library and client.",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/amqp-node/amqplib.git"
10
- },
11
- "engines": {
12
- "node": ">=10"
13
- },
14
- "dependencies": {
15
- "@acuminous/bitsyntax": "^0.1.2",
16
- "buffer-more-ints": "~1.0.0",
17
- "readable-stream": "1.x >=1.1.9",
18
- "url-parse": "~1.5.10"
19
- },
20
- "devDependencies": {
21
- "claire": "0.4.1",
22
- "mocha": "^9.2.2",
23
- "nyc": "^15.1.0",
24
- "uglify-js": "2.8.x"
25
- },
26
- "scripts": {
27
- "test": "make test",
28
- "prepare": "make"
29
- },
30
- "keywords": [
31
- "AMQP",
32
- "AMQP 0-9-1",
33
- "RabbitMQ"
34
- ],
35
- "author": "Michael Bridgen <mikeb@squaremobius.net>",
36
- "license": "MIT"
37
- }
@@ -1,69 +0,0 @@
1
- 'use strict';
2
-
3
- const claire = require('claire');
4
- const {BitSet} = require('../lib/bitset');
5
-
6
- const {
7
- forAll,
8
- data: arb,
9
- label,
10
- choice,
11
- transform
12
- } = claire;
13
-
14
- const PosInt = transform(Math.floor, arb.Positive);
15
-
16
- const EmptyBitSet = label('bitset', transform(
17
- size => {
18
- return new BitSet(size);
19
- },
20
- choice(arb.Nothing, PosInt)));
21
-
22
- suite('BitSet', () => {
23
-
24
- test('get bit', forAll(EmptyBitSet, PosInt)
25
- .satisfy((b, bit) => {
26
- b.set(bit);
27
- return b.get(bit);
28
- }).asTest());
29
-
30
- test('clear bit', forAll(EmptyBitSet, PosInt)
31
- .satisfy((b, bit) => {
32
- b.set(bit);
33
- b.clear(bit);
34
- return !b.get(bit);
35
- }).asTest());
36
-
37
- test('next set of empty', forAll(EmptyBitSet)
38
- .satisfy(b => {
39
- return b.nextSetBit(0) === -1;
40
- }).asTest());
41
-
42
- test('next set of one bit', forAll(EmptyBitSet, PosInt)
43
- .satisfy((b, bit) => {
44
- b.set(bit);
45
- return b.nextSetBit(0) === bit;
46
- }).asTest());
47
-
48
- test('next set same bit', forAll(EmptyBitSet, PosInt)
49
- .satisfy((b, bit) => {
50
- b.set(bit);
51
- return b.nextSetBit(bit) === bit;
52
- }).asTest());
53
-
54
- test('next set following bit', forAll(EmptyBitSet, PosInt)
55
- .satisfy((b, bit) => {
56
- b.set(bit);
57
- return b.nextSetBit(bit+1) === -1;
58
- }).asTest());
59
-
60
- test('next clear of empty', forAll(EmptyBitSet, PosInt)
61
- .satisfy((b, bit) => { return b.nextClearBit(bit) === bit; })
62
- .asTest());
63
-
64
- test('next clear of one set', forAll(EmptyBitSet, PosInt)
65
- .satisfy((b, bit) => {
66
- b.set(bit);
67
- return b.nextClearBit(bit) === bit + 1;
68
- }).asTest());
69
- });