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,314 +0,0 @@
1
- //
2
- //
3
- //
4
-
5
- 'use strict';
6
-
7
- /*
8
- The channel (promise) and callback APIs have similar signatures, and
9
- in particular, both need AMQP fields prepared from the same arguments
10
- and options. The arguments marshalling is done here. Each of the
11
- procedures below takes arguments and options (the latter in an object)
12
- particular to the operation it represents, and returns an object with
13
- fields for handing to the encoder.
14
- */
15
-
16
- // A number of AMQP methods have a table-typed field called
17
- // `arguments`, that is intended to carry extension-specific
18
- // values. RabbitMQ uses this in a number of places; e.g., to specify
19
- // an 'alternate exchange'.
20
- //
21
- // Many of the methods in this API have an `options` argument, from
22
- // which I take both values that have a default in AMQP (e.g.,
23
- // autoDelete in QueueDeclare) *and* values that are specific to
24
- // RabbitMQ (e.g., 'alternate-exchange'), which would normally be
25
- // supplied in `arguments`. So that extensions I don't support yet can
26
- // be used, I include `arguments` itself among the options.
27
- //
28
- // The upshot of this is that I often need to prepare an `arguments`
29
- // value that has any values passed in `options.arguments` as well as
30
- // any I've promoted to being options themselves. Since I don't want
31
- // to mutate anything passed in, the general pattern is to create a
32
- // fresh object with the `arguments` value given as its prototype; all
33
- // fields in the supplied value will be serialised, as well as any I
34
- // set on the fresh object. What I don't want to do, however, is set a
35
- // field to undefined by copying possibly missing field values,
36
- // because that will mask a value in the prototype.
37
- //
38
- // NB the `arguments` field already has a default value of `{}`, so
39
- // there's no need to explicitly default it unless I'm setting values.
40
- function setIfDefined(obj, prop, value) {
41
- if (value != undefined) obj[prop] = value;
42
- }
43
-
44
- var EMPTY_OPTIONS = Object.freeze({});
45
-
46
- var Args = {};
47
-
48
- Args.assertQueue = function(queue, options) {
49
- queue = queue || '';
50
- options = options || EMPTY_OPTIONS;
51
-
52
- var argt = Object.create(options.arguments || null);
53
- setIfDefined(argt, 'x-expires', options.expires);
54
- setIfDefined(argt, 'x-message-ttl', options.messageTtl);
55
- setIfDefined(argt, 'x-dead-letter-exchange',
56
- options.deadLetterExchange);
57
- setIfDefined(argt, 'x-dead-letter-routing-key',
58
- options.deadLetterRoutingKey);
59
- setIfDefined(argt, 'x-max-length', options.maxLength);
60
- setIfDefined(argt, 'x-max-priority', options.maxPriority);
61
- setIfDefined(argt, 'x-overflow', options.overflow);
62
- setIfDefined(argt, 'x-queue-mode', options.queueMode);
63
-
64
- return {
65
- queue: queue,
66
- exclusive: !!options.exclusive,
67
- durable: (options.durable === undefined) ? true : options.durable,
68
- autoDelete: !!options.autoDelete,
69
- arguments: argt,
70
- passive: false,
71
- // deprecated but we have to include it
72
- ticket: 0,
73
- nowait: false
74
- };
75
- };
76
-
77
- Args.checkQueue = function(queue) {
78
- return {
79
- queue: queue,
80
- passive: true, // switch to "completely different" mode
81
- nowait: false,
82
- durable: true, autoDelete: false, exclusive: false, // ignored
83
- ticket: 0,
84
- };
85
- };
86
-
87
- Args.deleteQueue = function(queue, options) {
88
- options = options || EMPTY_OPTIONS;
89
- return {
90
- queue: queue,
91
- ifUnused: !!options.ifUnused,
92
- ifEmpty: !!options.ifEmpty,
93
- ticket: 0, nowait: false
94
- };
95
- };
96
-
97
- Args.purgeQueue = function(queue) {
98
- return {
99
- queue: queue,
100
- ticket: 0, nowait: false
101
- };
102
- };
103
-
104
- Args.bindQueue = function(queue, source, pattern, argt) {
105
- return {
106
- queue: queue,
107
- exchange: source,
108
- routingKey: pattern,
109
- arguments: argt,
110
- ticket: 0, nowait: false
111
- };
112
- };
113
-
114
- Args.unbindQueue = function(queue, source, pattern, argt) {
115
- return {
116
- queue: queue,
117
- exchange: source,
118
- routingKey: pattern,
119
- arguments: argt,
120
- ticket: 0, nowait: false
121
- };
122
- };
123
-
124
- Args.assertExchange = function(exchange, type, options) {
125
- options = options || EMPTY_OPTIONS;
126
- var argt = Object.create(options.arguments || null);
127
- setIfDefined(argt, 'alternate-exchange', options.alternateExchange);
128
- return {
129
- exchange: exchange,
130
- ticket: 0,
131
- type: type,
132
- passive: false,
133
- durable: (options.durable === undefined) ? true : options.durable,
134
- autoDelete: !!options.autoDelete,
135
- internal: !!options.internal,
136
- nowait: false,
137
- arguments: argt
138
- };
139
- };
140
-
141
- Args.checkExchange = function(exchange) {
142
- return {
143
- exchange: exchange,
144
- passive: true, // switch to 'may as well be another method' mode
145
- nowait: false,
146
- // ff are ignored
147
- durable: true, internal: false, type: '', autoDelete: false,
148
- ticket: 0
149
- };
150
- };
151
-
152
- Args.deleteExchange = function(exchange, options) {
153
- options = options || EMPTY_OPTIONS;
154
- return {
155
- exchange: exchange,
156
- ifUnused: !!options.ifUnused,
157
- ticket: 0, nowait: false
158
- };
159
- };
160
-
161
- Args.bindExchange = function(dest, source, pattern, argt) {
162
- return {
163
- source: source,
164
- destination: dest,
165
- routingKey: pattern,
166
- arguments: argt,
167
- ticket: 0, nowait: false
168
- };
169
- };
170
-
171
- Args.unbindExchange = function(dest, source, pattern, argt) {
172
- return {
173
- source: source,
174
- destination: dest,
175
- routingKey: pattern,
176
- arguments: argt,
177
- ticket: 0, nowait: false
178
- };
179
- };
180
-
181
- // It's convenient to construct the properties and the method fields
182
- // at the same time, since in the APIs, values for both can appear in
183
- // `options`. Since the property or mthod field names don't overlap, I
184
- // just return one big object that can be used for both purposes, and
185
- // the encoder will pick out what it wants.
186
- Args.publish = function(exchange, routingKey, options) {
187
- options = options || EMPTY_OPTIONS;
188
-
189
- // The CC and BCC fields expect an array of "longstr", which would
190
- // normally be buffer values in JavaScript; however, since a field
191
- // array (or table) cannot have shortstr values, the codec will
192
- // encode all strings as longstrs anyway.
193
- function convertCC(cc) {
194
- if (cc === undefined) {
195
- return undefined;
196
- }
197
- else if (Array.isArray(cc)) {
198
- return cc.map(String);
199
- }
200
- else return [String(cc)];
201
- }
202
-
203
- var headers = Object.create(options.headers || null);
204
- setIfDefined(headers, 'CC', convertCC(options.CC));
205
- setIfDefined(headers, 'BCC', convertCC(options.BCC));
206
-
207
- var deliveryMode; // undefined will default to 1 (non-persistent)
208
-
209
- // Previously I overloaded deliveryMode be a boolean meaning
210
- // 'persistent or not'; better is to name this option for what it
211
- // is, but I need to have backwards compatibility for applications
212
- // that either supply a numeric or boolean value.
213
- if (options.persistent !== undefined)
214
- deliveryMode = (options.persistent) ? 2 : 1;
215
- else if (typeof options.deliveryMode === 'number')
216
- deliveryMode = options.deliveryMode;
217
- else if (options.deliveryMode) // is supplied and truthy
218
- deliveryMode = 2;
219
-
220
- var expiration = options.expiration;
221
- if (expiration !== undefined) expiration = expiration.toString();
222
-
223
- return {
224
- // method fields
225
- exchange: exchange,
226
- routingKey: routingKey,
227
- mandatory: !!options.mandatory,
228
- immediate: false, // RabbitMQ doesn't implement this any more
229
- ticket: undefined,
230
- // properties
231
- contentType: options.contentType,
232
- contentEncoding: options.contentEncoding,
233
- headers: headers,
234
- deliveryMode: deliveryMode,
235
- priority: options.priority,
236
- correlationId: options.correlationId,
237
- replyTo: options.replyTo,
238
- expiration: expiration,
239
- messageId: options.messageId,
240
- timestamp: options.timestamp,
241
- type: options.type,
242
- userId: options.userId,
243
- appId: options.appId,
244
- clusterId: undefined
245
- };
246
- };
247
-
248
- Args.consume = function(queue, options) {
249
- options = options || EMPTY_OPTIONS;
250
- var argt = Object.create(options.arguments || null);
251
- setIfDefined(argt, 'x-priority', options.priority);
252
- return {
253
- ticket: 0,
254
- queue: queue,
255
- consumerTag: options.consumerTag || '',
256
- noLocal: !!options.noLocal,
257
- noAck: !!options.noAck,
258
- exclusive: !!options.exclusive,
259
- nowait: false,
260
- arguments: argt
261
- };
262
- };
263
-
264
- Args.cancel = function(consumerTag) {
265
- return {
266
- consumerTag: consumerTag,
267
- nowait: false
268
- };
269
- };
270
-
271
- Args.get = function(queue, options) {
272
- options = options || EMPTY_OPTIONS;
273
- return {
274
- ticket: 0,
275
- queue: queue,
276
- noAck: !!options.noAck
277
- };
278
- };
279
-
280
- Args.ack = function(tag, allUpTo) {
281
- return {
282
- deliveryTag: tag,
283
- multiple: !!allUpTo
284
- };
285
- };
286
-
287
- Args.nack = function(tag, allUpTo, requeue) {
288
- return {
289
- deliveryTag: tag,
290
- multiple: !!allUpTo,
291
- requeue: (requeue === undefined) ? true : requeue
292
- };
293
- };
294
-
295
- Args.reject = function(tag, requeue) {
296
- return {
297
- deliveryTag: tag,
298
- requeue: (requeue === undefined) ? true : requeue
299
- };
300
- };
301
-
302
- Args.prefetch = function(count, global) {
303
- return {
304
- prefetchCount: count || 0,
305
- prefetchSize: 0,
306
- global: !!global
307
- };
308
- };
309
-
310
- Args.recover = function() {
311
- return {requeue: true};
312
- };
313
-
314
- module.exports = Object.freeze(Args);
@@ -1,130 +0,0 @@
1
- //
2
- //
3
- //
4
-
5
- 'use strict';
6
-
7
- /**
8
- * A bitset implementation, after that in java.util. Yes there
9
- * already exist such things, but none implement next{Clear|Set}Bit or
10
- * equivalent, and none involved me tooling about for an evening.
11
- */
12
- class BitSet {
13
- /**
14
- * @param {number} [size]
15
- */
16
- constructor(size) {
17
- if (size) {
18
- const numWords = Math.ceil(size / 32);
19
- this.words = new Array(numWords);
20
- }
21
- else {
22
- this.words = [];
23
- }
24
- this.wordsInUse = 0; // = number, not index
25
- }
26
-
27
- /**
28
- * @param {number} numWords
29
- */
30
- ensureSize(numWords) {
31
- const wordsPresent = this.words.length;
32
- if (wordsPresent < numWords) {
33
- this.words = this.words.concat(new Array(numWords - wordsPresent));
34
- }
35
- }
36
-
37
- /**
38
- * @param {number} bitIndex
39
- */
40
- set(bitIndex) {
41
- const w = wordIndex(bitIndex);
42
- if (w >= this.wordsInUse) {
43
- this.ensureSize(w + 1);
44
- this.wordsInUse = w + 1;
45
- }
46
- const bit = 1 << bitIndex;
47
- this.words[w] |= bit;
48
- }
49
-
50
- /**
51
- * @param {number} bitIndex
52
- */
53
- clear(bitIndex) {
54
- const w = wordIndex(bitIndex);
55
- if (w >= this.wordsInUse) return;
56
- const mask = ~(1 << bitIndex);
57
- this.words[w] &= mask;
58
- }
59
-
60
- /**
61
- * @param {number} bitIndex
62
- */
63
- get(bitIndex) {
64
- const w = wordIndex(bitIndex);
65
- if (w >= this.wordsInUse) return false; // >= since index vs size
66
- const bit = 1 << bitIndex;
67
- return !!(this.words[w] & bit);
68
- }
69
-
70
- /**
71
- * Give the next bit that is set on or after fromIndex, or -1 if no such bit
72
- *
73
- * @param {number} fromIndex
74
- */
75
- nextSetBit(fromIndex) {
76
- let w = wordIndex(fromIndex);
77
- if (w >= this.wordsInUse) return -1;
78
-
79
- // the right-hand side is shifted to only test the bits of the first
80
- // word that are > fromIndex
81
- let word = this.words[w] & (0xffffffff << fromIndex);
82
- while (true) {
83
- if (word) return (w * 32) + trailingZeros(word);
84
- w++;
85
- if (w === this.wordsInUse) return -1;
86
- word = this.words[w];
87
- }
88
- }
89
-
90
- /**
91
- * @param {number} fromIndex
92
- */
93
- nextClearBit(fromIndex) {
94
- let w = wordIndex(fromIndex);
95
- if (w >= this.wordsInUse) return fromIndex;
96
-
97
- let word = ~(this.words[w]) & (0xffffffff << fromIndex);
98
- while (true) {
99
- if (word) return (w * 32) + trailingZeros(word);
100
- w++;
101
- if (w == this.wordsInUse) return w * 32;
102
- word = ~(this.words[w]);
103
- }
104
- }
105
- }
106
-
107
- /**
108
- * @param {number} bitIndex
109
- */
110
- function wordIndex(bitIndex) {
111
- return Math.floor(bitIndex / 32);
112
- }
113
-
114
- /**
115
- * @param {number} i
116
- */
117
- function trailingZeros(i) {
118
- // From Hacker's Delight, via JDK. Probably far less effective here,
119
- // since bit ops are not necessarily the quick way to do things in
120
- // JS.
121
- if (i === 0) return 32;
122
- let y, n = 31;
123
- y = i << 16; if (y != 0) { n = n -16; i = y; }
124
- y = i << 8; if (y != 0) { n = n - 8; i = y; }
125
- y = i << 4; if (y != 0) { n = n - 4; i = y; }
126
- y = i << 2; if (y != 0) { n = n - 2; i = y; }
127
- return n - ((i << 1) >>> 31);
128
- }
129
-
130
- module.exports.BitSet = BitSet;