amqplib 0.7.0 → 0.9.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.
@@ -0,0 +1,38 @@
1
+ # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
+
4
+ name: Node.js CI
5
+
6
+ on:
7
+ push:
8
+ branches: [main]
9
+ pull_request:
10
+ branches: [main]
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-latest
15
+ services:
16
+ rabbitmq:
17
+ image: rabbitmq
18
+ ports:
19
+ - 5672:5672
20
+
21
+ strategy:
22
+ matrix:
23
+ node-version: [10.x, 12.x, 14.x, 16.x]
24
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
25
+
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+ - name: Use Node.js ${{ matrix.node-version }}
29
+ uses: actions/setup-node@v2
30
+ with:
31
+ node-version: ${{ matrix.node-version }}
32
+ cache: "npm"
33
+
34
+ # Install all prerequisites
35
+ - run: npm ci
36
+
37
+ # Run the tests
38
+ - run: make test
package/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
1
  # Change log for amqplib
2
2
 
3
+ ## Changes in v0.9.0
4
+
5
+ git log v0.8.0..v0.9.0
6
+
7
+ * Update mocha and replace the deprecated istanbul with nyc ([PR
8
+ 681](https://github.com/squaremo/amqp.node/pull/681)
9
+ * Update url-parse ([PR
10
+ 675](https://github.com/squaremo/amqp.node/pull/675), thank you
11
+ @suhail-n and @kibertoad)
12
+ * fix: done called twice on invalid options ([PR
13
+ 667](https://github.com/squaremo/amqp.node/pull/667), thank you
14
+ @luddd3 and @kibertoad)
15
+ * Close connection to server on connect errors ([PR
16
+ 647](https://github.com/squaremo/amqp.node/pull/647), thank you
17
+ @luddd3 and @kibertoad)
18
+ * Modernise channel_model.js ([PR
19
+ 635](https://github.com/squaremo/amqp.node/pull/635), thank you
20
+ @kibertoad and @jimmywarting)
21
+ * Bring package-lock.json up to date ([PR
22
+ 653](https://github.com/squaremo/amqp.node/pull/653)
23
+ * Update url-parse ([PR
24
+ 652](https://github.com/squaremo/amqp.node/pull/652), thank you
25
+ @giorgioatanasov and @buffolander)
26
+ * Modernise channel_model.js ([PR
27
+ 651](https://github.com/squaremo/amqp.node/pull/651), thank you
28
+ for the review @kibertoad)
29
+ * Modernise bitset.js ([PR
30
+ 634](https://github.com/squaremo/amqp.node/pull/634), thank you
31
+ @kibertoad and @jimmywarting)
32
+ * :warning: Drop CI for node versions below 10 ([PR
33
+ 631](https://github.com/squaremo/amqp.node/pull/631), thank you
34
+ for the review @kibertoad)
35
+ * Replace safe-buffer dependency with native buffers ([PR
36
+ 628](https://github.com/squaremo/amqp.node/pull/628), thank you
37
+ @kibertoad and @jimmywarting)
38
+
39
+ ## Changes in v0.8.0
40
+
41
+ git log v0.7.1..v0.8.0
42
+
43
+ * :warning: Support for NodeJS prior to v10 is dropped :warning: ([PR
44
+ 615](https://github.com/squaremo/amqp.node/pull/615), thank you
45
+ @xamgore and everyone who helped there)
46
+ * Use hostname as TLS servername, to help with using servers behind
47
+ load balancers ([PR
48
+ 567](https://github.com/squaremo/amqp.node/pull/567), thanks to
49
+ @carlhoerberg and commenters)
50
+
51
+ ## Changes in v0.7.1
52
+
53
+ git log v0.7.0..v0.7.1
54
+
55
+ * Update url-parse (and others) ([PR
56
+ 607](https://github.com/squaremo/amqp.node/pull/545), thanks
57
+ @ThomasGawlitza)
58
+
59
+ ## Changes in v0.7.0
60
+
61
+ git log v0.6.0..v0.7.0
62
+
63
+ * Extend support to Node.js v15
64
+ * Fix use of stream.write in tests
65
+
66
+ ## Changes in v0.6.0
67
+
68
+ git log v0.5.6..v0.6.0
69
+
70
+ * Extend support to Node.js v14
71
+
3
72
  ## Changes in v0.5.6
4
73
 
5
74
  git log v0.5.5..v0.5.6
package/Makefile CHANGED
@@ -3,12 +3,12 @@ JSON=amqp-rabbitmq-0.9.1.json
3
3
  RABBITMQ_CODEGEN=https://raw.githubusercontent.com/rabbitmq/rabbitmq-codegen
4
4
  AMQP_JSON=$(RABBITMQ_CODEGEN)/$(RABBITMQ_SRC_VERSION)/$(JSON)
5
5
 
6
- NODEJS_VERSIONS='0.8' '0.9' '0.10' '0.11' '0.12' '1.8.4' '2.5' '3.3' '4.9' '5.12' '6.17' '8.17' '9.11' '10.21' '11.15' '12.18' '13.14' '14.5' '15.8'
6
+ NODEJS_VERSIONS='10.21' '11.15' '12.18' '13.14' '14.5' '15.8'
7
7
 
8
8
  MOCHA=./node_modules/.bin/mocha
9
9
  _MOCHA=./node_modules/.bin/_mocha
10
10
  UGLIFY=./node_modules/.bin/uglifyjs
11
- ISTANBUL=./node_modules/.bin/istanbul
11
+ NYC=./node_modules/.bin/nyc
12
12
 
13
13
  .PHONY: test test-all-nodejs all clean coverage
14
14
 
@@ -25,17 +25,16 @@ lib/defs.js: $(UGLIFY) bin/generate-defs.js bin/amqp-rabbitmq-0.9.1.json
25
25
  -b 'indent-level=2' 2>&1 | (grep -v 'WARN' || true)
26
26
 
27
27
  test: lib/defs.js
28
- $(MOCHA) --check-leaks -u tdd test/
28
+ $(MOCHA) --check-leaks -u tdd --exit test/
29
29
 
30
30
  test-all-nodejs: lib/defs.js
31
31
  for v in $(NODEJS_VERSIONS); \
32
32
  do echo "-- Node version $$v --"; \
33
- nave use $$v $(MOCHA) -u tdd -R progress test; \
33
+ nave use $$v $(MOCHA) -u tdd --exit -R progress test; \
34
34
  done
35
35
 
36
- coverage: $(ISTANBUL) lib/defs.js
37
- $(ISTANBUL) cover $(_MOCHA) -- -u tdd -R progress test/
38
- $(ISTANBUL) report
36
+ coverage: $(NYC) lib/defs.js
37
+ $(NYC) --reporter=lcov --reporter=text $(_MOCHA) -u tdd -R progress test/
39
38
  @echo "HTML report at file://$$(pwd)/coverage/lcov-report/index.html"
40
39
 
41
40
  bin/amqp-rabbitmq-0.9.1.json:
package/README.md CHANGED
@@ -9,9 +9,7 @@
9
9
  * [API reference][gh-pages-apiref]
10
10
  * [Examples from RabbitMQ tutorials][tutes]
11
11
 
12
- A library for making AMQP 0-9-1 clients for Node.JS, and an AMQP 0-9-1
13
- client for Node.JS v0.8-0.12, v4-v15, and the intervening io.js
14
- releases.
12
+ A library for making AMQP 0-9-1 clients for Node.JS, and an AMQP 0-9-1 client for Node.JS v10+.
15
13
 
16
14
  This library does not implement [AMQP
17
15
  1.0](https://github.com/squaremo/amqp.node/issues/63) or [AMQP
@@ -148,10 +146,10 @@ really only useful for checking the kind and formatting of the errors.
148
146
  make coverage
149
147
  open file://`pwd`/coverage/lcov-report/index.html
150
148
 
151
- [gh-pages]: http://squaremo.github.com/amqp.node/
152
- [gh-pages-apiref]: http://squaremo.github.com/amqp.node/channel_api.html
149
+ [gh-pages]: http://www.squaremobius.net/amqp.node/
150
+ [gh-pages-apiref]: http://www.squaremobius.net/amqp.node/channel_api.html
153
151
  [nave]: https://github.com/isaacs/nave
154
- [tutes]: https://github.com/squaremo/amqp.node/tree/master/examples/tutorials
152
+ [tutes]: https://github.com/squaremo/amqp.node/tree/main/examples/tutorials
155
153
  [rabbitmq-tutes]: http://www.rabbitmq.com/getstarted.html
156
- [changelog]: https://github.com/squaremo/amqp.node/blob/master/CHANGELOG.md
154
+ [changelog]: https://github.com/squaremo/amqp.node/blob/main/CHANGELOG.md
157
155
  [docker]: https://www.docker.com/
@@ -116,7 +116,6 @@ println(
116
116
  '*/');
117
117
 
118
118
  println("'use strict';"); nl();
119
- println('var Buffer = require("safe-buffer").Buffer;');
120
119
  nl()
121
120
  println('var codec = require("./codec");');
122
121
  println('var ints = require("buffer-more-ints");');
@@ -85,9 +85,9 @@ some needless object-orientation (in the Python code; you don't get a
85
85
  choice about needless object-orientation in Java).
86
86
 
87
87
  [rabbitmq-tutes]: http://github.com/rabbitmq/rabbitmq-tutorials
88
- [tute-one]: http://www.rabbitmq.com/tutorials/tutorial-one-python.html
89
- [tute-two]: http://www.rabbitmq.com/tutorials/tutorial-two-python.html
90
- [tute-three]: http://www.rabbitmq.com/tutorials/tutorial-three-python.html
91
- [tute-four]: http://www.rabbitmq.com/tutorials/tutorial-four-python.html
92
- [tute-five]: http://www.rabbitmq.com/tutorials/tutorial-five-python.html
93
- [tute-six]: http://www.rabbitmq.com/tutorials/tutorial-six-python.html
88
+ [tute-one]: http://www.rabbitmq.com/tutorials/tutorial-one-javascript.html
89
+ [tute-two]: http://www.rabbitmq.com/tutorials/tutorial-two-javascript.html
90
+ [tute-three]: http://www.rabbitmq.com/tutorials/tutorial-three-javascript.html
91
+ [tute-four]: http://www.rabbitmq.com/tutorials/tutorial-four-javascript.html
92
+ [tute-five]: http://www.rabbitmq.com/tutorials/tutorial-five-javascript.html
93
+ [tute-six]: http://www.rabbitmq.com/tutorials/tutorial-six-javascript.html
package/lib/bitset.js CHANGED
@@ -2,67 +2,124 @@
2
2
  //
3
3
  //
4
4
 
5
- // A bitset implementation, after that in java.util. Yes there
6
- // already exist such things, but none implement next{Clear|Set}Bit or
7
- // equivalent, and none involved me tooling about for an evening.
8
-
9
5
  'use strict';
10
6
 
11
- function BitSet(size) {
12
- if (size) {
13
- var numWords = Math.ceil(size / 32);
14
- this.words = new Array(numWords);
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
15
25
  }
16
- else {
17
- this.words = [];
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
+ }
18
35
  }
19
- this.wordsInUse = 0; // = number, not index
20
- }
21
36
 
22
- var P = BitSet.prototype;
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
+ }
23
49
 
24
- function wordIndex(bitIndex) {
25
- return Math.floor(bitIndex / 32);
26
- }
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
+ }
27
59
 
28
- // Make sure we have at least numWords
29
- P.ensureSize = function(numWords) {
30
- var wordsPresent = this.words.length;
31
- if (wordsPresent < numWords) {
32
- this.words = this.words.concat(new Array(numWords - wordsPresent));
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);
33
68
  }
34
- }
35
69
 
36
- P.set = function(bitIndex) {
37
- var w = wordIndex(bitIndex);
38
- if (w >= this.wordsInUse) {
39
- this.ensureSize(w + 1);
40
- this.wordsInUse = w + 1;
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
+ }
41
88
  }
42
- var bit = 1 << bitIndex;
43
- this.words[w] |= bit;
44
- };
45
89
 
46
- P.clear = function(bitIndex) {
47
- var w = wordIndex(bitIndex);
48
- if (w >= this.wordsInUse) return;
49
- var mask = ~(1 << bitIndex);
50
- this.words[w] &= mask;
51
- };
90
+ /**
91
+ * @param {number} fromIndex
92
+ */
93
+ nextClearBit(fromIndex) {
94
+ let w = wordIndex(fromIndex);
95
+ if (w >= this.wordsInUse) return fromIndex;
52
96
 
53
- P.get = function(bitIndex) {
54
- var w = wordIndex(bitIndex);
55
- if (w >= this.wordsInUse) return false; // >= since index vs size
56
- var bit = 1 << bitIndex;
57
- return !!(this.words[w] & bit);
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
+ }
58
105
  }
59
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
+ */
60
117
  function trailingZeros(i) {
61
118
  // From Hacker's Delight, via JDK. Probably far less effective here,
62
119
  // since bit ops are not necessarily the quick way to do things in
63
120
  // JS.
64
121
  if (i === 0) return 32;
65
- var y, n = 31;
122
+ let y, n = 31;
66
123
  y = i << 16; if (y != 0) { n = n -16; i = y; }
67
124
  y = i << 8; if (y != 0) { n = n - 8; i = y; }
68
125
  y = i << 4; if (y != 0) { n = n - 4; i = y; }
@@ -70,34 +127,4 @@ function trailingZeros(i) {
70
127
  return n - ((i << 1) >>> 31);
71
128
  }
72
129
 
73
- // Give the next bit that's set on or after fromIndex, or -1 if no such
74
- // bit
75
- P.nextSetBit = function(fromIndex) {
76
- var 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
- var 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
- P.nextClearBit = function(fromIndex) {
91
- var w = wordIndex(fromIndex);
92
- if (w >= this.wordsInUse) return fromIndex;
93
-
94
- var word = ~(this.words[w]) & (0xffffffff << fromIndex);
95
- while (true) {
96
- if (word) return (w * 32) + trailingZeros(word);
97
- w++;
98
- if (w == this.wordsInUse) return w * 32;
99
- word = ~(this.words[w]);
100
- }
101
- };
102
-
103
130
  module.exports.BitSet = BitSet;
package/lib/channel.js CHANGED
@@ -16,7 +16,6 @@ var EventEmitter = require('events').EventEmitter;
16
16
  var fmt = require('util').format;
17
17
  var IllegalOperationError = require('./error').IllegalOperationError;
18
18
  var stackCapture = require('./error').stackCapture;
19
- var Buffer = require('safe-buffer').Buffer
20
19
  function Channel(connection) {
21
20
  EventEmitter.call( this );
22
21
  this.connection = connection;