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,69 +0,0 @@
1
- # buffer-more-ints: Add support for more integer widths to Buffer
2
-
3
- [![Build Status](https://travis-ci.org/dpw/node-buffer-more-ints.png)](https://travis-ci.org/dpw/node-buffer-more-ints)
4
-
5
- Node's Buffer only supports reading and writing integers of a limited
6
- range of widths. This module provides support for more widths, so
7
- that integers from 1 to 8 bytes (64 bits) can be accessed. The
8
- support takes two forms. Firstly, as stand-alone functions similar to
9
- the integer reading/writing methods of Buffer:
10
-
11
- $ node
12
- > var moreints = require('buffer-more-ints')
13
- undefined
14
- > moreints.readInt64BE(new Buffer("0000deadbeef0000", "hex"), 0).toString(16)
15
- 'deadbeef0000'
16
-
17
- Read and write functions for the regular widths (8, 16, 32) are also
18
- present in this module, for consistency.
19
-
20
- The second form is methods patched into `Buffer.prototype`, installed
21
- by requiring `'buffer-more-ints/polyfill'`:
22
-
23
- $ node
24
- > require('buffer-more-ints/polyfill')
25
- {}
26
- > new Buffer("0000deadbeef0000", "hex").readInt64BE(0).toString(16)
27
- 'deadbeef0000'
28
-
29
- buffer-more-ints/polyfill also adds methods `readIntBE`, `writeIntBE`,
30
- and their LE and UInt counterparts, which take an initial argument
31
- giving the width of the integer in bytes:
32
-
33
- > var b = new Buffer(3);
34
- > b.writeIntLE(3, -123456, 0);
35
- > b.toString('hex')
36
- 'c01dfe'
37
- > b.readIntLE(3, 0);
38
- -123456
39
-
40
- The functions added by buffer-more-ints are all implemented in terms
41
- of the core Buffer functions. Part way through writing the code, I
42
- discovered that node.js currently implements those in JavaScript, so
43
- this doesn't lead to performance benefits. But should node ever
44
- switch to implementing its Buffer operations natively, this
45
- module should get a speed boost.
46
-
47
- ## Limitations
48
-
49
- As JavaScript uses IEEE754 doubles for numbers, the contiguous range
50
- of integers it can represent is [-2^53 - 1, 2^53 - 1]. So only
51
- integer widths up to 6 bytes or 48 bits can be read exactly. Reads of
52
- 7 or 8 bytes (56 or 64 bits) will return the closest value that can be
53
- represented as a JavaScript number.
54
-
55
- In certain situations it might be important to check that a JavaScript
56
- number was read exactly. The `isContiguousInt` or
57
- `Buffer.isContiguousInt` (polyfill) function will determine this:
58
-
59
- > Buffer.isContiguousInt(0x1fffffffffffff);
60
- true
61
- > Buffer.isContiguousInt(0x20000000000000);
62
- false
63
-
64
- And `assertContiguousInt` asserts that a number is so:
65
-
66
- > Buffer.assertContiguousInt(0x1fffffffffffff);
67
- undefined
68
- > Buffer.assertContiguousInt(0x20000000000000);
69
- AssertionError: number cannot be represented as a contiguous integer
@@ -1,183 +0,0 @@
1
- 'use strict';
2
-
3
- require('./polyfill');
4
-
5
- // A simple abbreviation to obtain a buffer from a hex string
6
- function h2b(str) {
7
- return new Buffer(str, "hex");
8
- }
9
-
10
- // Reverse a buffer
11
- function reverse(buf) {
12
- var res = new Buffer(buf.length);
13
- for (var i = 0, j = buf.length - 1; j >= 0; i++, j--) {
14
- res[i] = buf[j];
15
- }
16
- return res;
17
- }
18
-
19
- // Fill a buffer with distinctive data
20
- function scrub(buf) {
21
- var pos = 0;
22
- var written;
23
- while ((written = buf.write("deadbeef", pos, 4, "hex")) == 4) {
24
- pos += written;
25
- }
26
- return buf;
27
- }
28
-
29
- function xint_case(xint) {
30
- return function (assert, hex, val, inexact) {
31
- var readBE = "read" + xint + "BE";
32
- var writeBE = "write" + xint + "BE";
33
- var readLE = "read" + xint + "LE";
34
- var writeLE = "write" + xint + "LE";
35
-
36
- var len = hex.length / 2;
37
-
38
- // Straightforward read cases
39
- assert.equal(h2b(hex)[readBE](len, 0), val);
40
- assert.equal(reverse(h2b(hex))[readLE](len, 0), val);
41
-
42
- // Test straightforward writes and noAssert writes off the ends of
43
- // the buffer
44
- var buf = scrub(new Buffer(len));
45
- buf[writeBE](len, val, 0);
46
- if (!inexact) {
47
- assert.equal(buf.toString("hex"), hex);
48
- } else {
49
- assert.equal(buf[readBE](len, 0), val);
50
- }
51
-
52
- scrub(buf);
53
- buf[writeLE](len, val, 0);
54
- if (!inexact) {
55
- assert.equal(reverse(buf).toString("hex"), hex);
56
- } else {
57
- assert.equal(buf[readLE](len, 0), val);
58
- }
59
-
60
- // Accesses off the ends of the buffer should throw.
61
- assert.throws(function () { h2b(hex)[readBE](len, -1); });
62
- assert.throws(function () { h2b(hex)[readBE](len, 1); });
63
- assert.throws(function () { reverse(h2b(hex))[readLE](len, 1); });
64
- assert.throws(function () { reverse(h2b(hex))[readLE](len, -1); });
65
- assert.throws(function () { buf[writeBE](len, val, 1); });
66
- assert.throws(function () { buf[writeBE](len, val, -1); });
67
- assert.throws(function () { buf[writeLE](len, val, 1); });
68
- assert.throws(function () { buf[writeLE](len, val, -1); });
69
- };
70
- }
71
-
72
- var uint_case = xint_case("UInt");
73
- var int_case = xint_case("Int");
74
-
75
- module.exports.uint = function (assert) {
76
- uint_case(assert, "00", 0x00);
77
- uint_case(assert, "01", 0x01);
78
- uint_case(assert, "ff", 0xff);
79
-
80
- uint_case(assert, "0000", 0x0000);
81
- uint_case(assert, "0102", 0x0102);
82
- uint_case(assert, "ffff", 0xffff);
83
-
84
- uint_case(assert, "000000", 0x000000);
85
- uint_case(assert, "010203", 0x010203);
86
- uint_case(assert, "ffffff", 0xffffff);
87
-
88
- uint_case(assert, "00000000", 0x00000000);
89
- uint_case(assert, "01020304", 0x01020304);
90
- uint_case(assert, "ffffffff", 0xffffffff);
91
-
92
- uint_case(assert, "0000000000", 0x0000000000);
93
- uint_case(assert, "0102030405", 0x0102030405);
94
- uint_case(assert, "ffffffffff", 0xffffffffff);
95
-
96
- uint_case(assert, "000000000000", 0x000000000000);
97
- uint_case(assert, "010203040506", 0x010203040506);
98
- uint_case(assert, "ffffffffffff", 0xffffffffffff);
99
-
100
- uint_case(assert, "00000000000000", 0x00000000000000);
101
- uint_case(assert, "01020304050607", 0x01020304050607);
102
- uint_case(assert, "ffffffffffffff", 0xffffffffffffff);
103
-
104
- uint_case(assert, "0000000000000000", 0x0000000000000000);
105
- uint_case(assert, "0102030405060708", 0x0102030405060708, true);
106
- uint_case(assert, "ffffffffffffffff", 0xffffffffffffffff);
107
-
108
- assert.done();
109
- };
110
-
111
- module.exports.int = function (assert) {
112
- int_case(assert, "00", 0x00);
113
- int_case(assert, "01", 0x01);
114
- int_case(assert, "7f", 0x7f);
115
- int_case(assert, "80", -0x80);
116
- int_case(assert, "ff", -0x01);
117
-
118
- int_case(assert, "0000", 0x0000);
119
- int_case(assert, "0102", 0x0102);
120
- int_case(assert, "7fff", 0x7fff);
121
- int_case(assert, "8000", -0x8000);
122
- int_case(assert, "ffff", -0x0001);
123
-
124
- int_case(assert, "000000", 0x000000);
125
- int_case(assert, "010203", 0x010203);
126
- int_case(assert, "7fffff", 0x7fffff);
127
- int_case(assert, "800000", -0x800000);
128
- int_case(assert, "ffffff", -0x000001);
129
-
130
- int_case(assert, "00000000", 0x00000000);
131
- int_case(assert, "01020304", 0x01020304);
132
- int_case(assert, "7fffffff", 0x7fffffff);
133
- int_case(assert, "80000000", -0x80000000);
134
- int_case(assert, "ffffffff", -0x00000001);
135
-
136
- int_case(assert, "0000000000", 0x0000000000);
137
- int_case(assert, "0102030405", 0x0102030405);
138
- int_case(assert, "7fffffffff", 0x7fffffffff);
139
- int_case(assert, "8000000000", -0x8000000000);
140
- int_case(assert, "ffffffffff", -0x0000000001);
141
-
142
- int_case(assert, "000000000000", 0x000000000000);
143
- int_case(assert, "010203040506", 0x010203040506);
144
- int_case(assert, "7fffffffffff", 0x7fffffffffff);
145
- int_case(assert, "800000000000", -0x800000000000);
146
- int_case(assert, "ffffffffffff", -0x000000000001);
147
-
148
- int_case(assert, "00000000000000", 0x00000000000000);
149
- int_case(assert, "01020304050607", 0x01020304050607);
150
- int_case(assert, "7fffffffffffff", 0x7fffffffffffff);
151
- int_case(assert, "80000000000000", -0x80000000000000);
152
- int_case(assert, "ffffffffffffff", -0x00000000000001);
153
-
154
- int_case(assert, "0000000000000000", 0x0000000000000000);
155
- int_case(assert, "0102030405060708", 0x0102030405060708, true);
156
- int_case(assert, "7fffffffffffffff", 0x7fffffffffffffff);
157
- int_case(assert, "8000000000000000", -0x8000000000000000);
158
- int_case(assert, "ffffffffffffffff", -0x0000000000000001);
159
-
160
- assert.done();
161
- };
162
-
163
- module.exports.isContiguousInt = function (assert) {
164
- assert.equal(Buffer.isContiguousInt(0x1fffffffffffff), true);
165
- assert.equal(Buffer.isContiguousInt(0x20000000000000), false);
166
- assert.equal(Buffer.isContiguousInt(-0x1fffffffffffff), true);
167
- assert.equal(Buffer.isContiguousInt(-0x20000000000000), false);
168
-
169
- assert.doesNotThrow(function () {
170
- Buffer.assertContiguousInt(0x1fffffffffffff);
171
- });
172
- assert.throws(function () {
173
- Buffer.assertContiguousInt(0x20000000000000);
174
- });
175
- assert.doesNotThrow(function () {
176
- Buffer.assertContiguousInt(-0x1fffffffffffff);
177
- });
178
- assert.throws(function () {
179
- Buffer.assertContiguousInt(-0x20000000000000);
180
- });
181
-
182
- assert.done();
183
- };
@@ -1,432 +0,0 @@
1
- 'use strict';
2
-
3
- // JavaScript is numerically challenged
4
- var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
5
- var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
6
-
7
- // The maximum contiguous integer that can be held in a IEEE754 double
8
- var MAX_INT = 0x1fffffffffffff;
9
-
10
- function isContiguousInt(val) {
11
- return val <= MAX_INT && val >= -MAX_INT;
12
- }
13
-
14
- function assertContiguousInt(val) {
15
- if (!isContiguousInt(val)) {
16
- throw new TypeError("number cannot be represented as a contiguous integer");
17
- }
18
- }
19
-
20
- module.exports.isContiguousInt = isContiguousInt;
21
- module.exports.assertContiguousInt = assertContiguousInt;
22
-
23
- // Fill in the regular procedures
24
- ['UInt', 'Int'].forEach(function (sign) {
25
- var suffix = sign + '8';
26
- module.exports['read' + suffix] =
27
- Buffer.prototype['read' + suffix].call;
28
- module.exports['write' + suffix] =
29
- Buffer.prototype['write' + suffix].call;
30
-
31
- ['16', '32'].forEach(function (size) {
32
- ['LE', 'BE'].forEach(function (endian) {
33
- var suffix = sign + size + endian;
34
- var read = Buffer.prototype['read' + suffix];
35
- module.exports['read' + suffix] =
36
- function (buf, offset) {
37
- return read.call(buf, offset);
38
- };
39
- var write = Buffer.prototype['write' + suffix];
40
- module.exports['write' + suffix] =
41
- function (buf, val, offset) {
42
- return write.call(buf, val, offset);
43
- };
44
- });
45
- });
46
- });
47
-
48
- // Check that a value is an integer within the given range
49
- function check_value(val, min, max) {
50
- val = +val;
51
- if (typeof(val) != 'number' || val < min || val > max || Math.floor(val) !== val) {
52
- throw new TypeError("\"value\" argument is out of bounds");
53
- }
54
- return val;
55
- }
56
-
57
- // Check that something is within the Buffer bounds
58
- function check_bounds(buf, offset, len) {
59
- if (offset < 0 || offset + len > buf.length) {
60
- throw new RangeError("Index out of range");
61
- }
62
- }
63
-
64
- function readUInt24BE(buf, offset) {
65
- return buf.readUInt8(offset) << 16 | buf.readUInt16BE(offset + 1);
66
- }
67
- module.exports.readUInt24BE = readUInt24BE;
68
-
69
- function writeUInt24BE(buf, val, offset) {
70
- val = check_value(val, 0, 0xffffff);
71
- check_bounds(buf, offset, 3);
72
- buf.writeUInt8(val >>> 16, offset);
73
- buf.writeUInt16BE(val & 0xffff, offset + 1);
74
- }
75
- module.exports.writeUInt24BE = writeUInt24BE;
76
-
77
- function readUInt40BE(buf, offset) {
78
- return (buf.readUInt8(offset) || 0) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 1);
79
- }
80
- module.exports.readUInt40BE = readUInt40BE;
81
-
82
- function writeUInt40BE(buf, val, offset) {
83
- val = check_value(val, 0, 0xffffffffff);
84
- check_bounds(buf, offset, 5);
85
- buf.writeUInt8(Math.floor(val * SHIFT_RIGHT_32), offset);
86
- buf.writeInt32BE(val & -1, offset + 1);
87
- }
88
- module.exports.writeUInt40BE = writeUInt40BE;
89
-
90
- function readUInt48BE(buf, offset) {
91
- return buf.readUInt16BE(offset) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 2);
92
- }
93
- module.exports.readUInt48BE = readUInt48BE;
94
-
95
- function writeUInt48BE(buf, val, offset) {
96
- val = check_value(val, 0, 0xffffffffffff);
97
- check_bounds(buf, offset, 6);
98
- buf.writeUInt16BE(Math.floor(val * SHIFT_RIGHT_32), offset);
99
- buf.writeInt32BE(val & -1, offset + 2);
100
- }
101
- module.exports.writeUInt48BE = writeUInt48BE;
102
-
103
- function readUInt56BE(buf, offset) {
104
- return ((buf.readUInt8(offset) || 0) << 16 | buf.readUInt16BE(offset + 1)) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 3);
105
- }
106
- module.exports.readUInt56BE = readUInt56BE;
107
-
108
- function writeUInt56BE(buf, val, offset) {
109
- val = check_value(val, 0, 0xffffffffffffff);
110
- check_bounds(buf, offset, 7);
111
-
112
- if (val < 0x100000000000000) {
113
- var hi = Math.floor(val * SHIFT_RIGHT_32);
114
- buf.writeUInt8(hi >>> 16, offset);
115
- buf.writeUInt16BE(hi & 0xffff, offset + 1);
116
- buf.writeInt32BE(val & -1, offset + 3);
117
- } else {
118
- // Special case because 2^56-1 gets rounded up to 2^56
119
- buf[offset] = 0xff;
120
- buf[offset+1] = 0xff;
121
- buf[offset+2] = 0xff;
122
- buf[offset+3] = 0xff;
123
- buf[offset+4] = 0xff;
124
- buf[offset+5] = 0xff;
125
- buf[offset+6] = 0xff;
126
- }
127
- }
128
- module.exports.writeUInt56BE = writeUInt56BE;
129
-
130
- function readUInt64BE(buf, offset) {
131
- return buf.readUInt32BE(offset) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 4);
132
- }
133
- module.exports.readUInt64BE = readUInt64BE;
134
-
135
- function writeUInt64BE(buf, val, offset) {
136
- val = check_value(val, 0, 0xffffffffffffffff);
137
- check_bounds(buf, offset, 8);
138
-
139
- if (val < 0x10000000000000000) {
140
- buf.writeUInt32BE(Math.floor(val * SHIFT_RIGHT_32), offset);
141
- buf.writeInt32BE(val & -1, offset + 4);
142
- } else {
143
- // Special case because 2^64-1 gets rounded up to 2^64
144
- buf[offset] = 0xff;
145
- buf[offset+1] = 0xff;
146
- buf[offset+2] = 0xff;
147
- buf[offset+3] = 0xff;
148
- buf[offset+4] = 0xff;
149
- buf[offset+5] = 0xff;
150
- buf[offset+6] = 0xff;
151
- buf[offset+7] = 0xff;
152
- }
153
- }
154
- module.exports.writeUInt64BE = writeUInt64BE;
155
-
156
- function readUInt24LE(buf, offset) {
157
- return buf.readUInt8(offset + 2) << 16 | buf.readUInt16LE(offset);
158
- }
159
- module.exports.readUInt24LE = readUInt24LE;
160
-
161
- function writeUInt24LE(buf, val, offset) {
162
- val = check_value(val, 0, 0xffffff);
163
- check_bounds(buf, offset, 3);
164
-
165
- buf.writeUInt16LE(val & 0xffff, offset);
166
- buf.writeUInt8(val >>> 16, offset + 2);
167
- }
168
- module.exports.writeUInt24LE = writeUInt24LE;
169
-
170
- function readUInt40LE(buf, offset) {
171
- return (buf.readUInt8(offset + 4) || 0) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
172
- }
173
- module.exports.readUInt40LE = readUInt40LE;
174
-
175
- function writeUInt40LE(buf, val, offset) {
176
- val = check_value(val, 0, 0xffffffffff);
177
- check_bounds(buf, offset, 5);
178
- buf.writeInt32LE(val & -1, offset);
179
- buf.writeUInt8(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
180
- }
181
- module.exports.writeUInt40LE = writeUInt40LE;
182
-
183
- function readUInt48LE(buf, offset) {
184
- return buf.readUInt16LE(offset + 4) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
185
- }
186
- module.exports.readUInt48LE = readUInt48LE;
187
-
188
- function writeUInt48LE(buf, val, offset) {
189
- val = check_value(val, 0, 0xffffffffffff);
190
- check_bounds(buf, offset, 6);
191
- buf.writeInt32LE(val & -1, offset);
192
- buf.writeUInt16LE(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
193
- }
194
- module.exports.writeUInt48LE = writeUInt48LE;
195
-
196
- function readUInt56LE(buf, offset) {
197
- return ((buf.readUInt8(offset + 6) || 0) << 16 | buf.readUInt16LE(offset + 4)) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
198
- }
199
- module.exports.readUInt56LE = readUInt56LE;
200
-
201
- function writeUInt56LE(buf, val, offset) {
202
- val = check_value(val, 0, 0xffffffffffffff);
203
- check_bounds(buf, offset, 7);
204
-
205
- if (val < 0x100000000000000) {
206
- buf.writeInt32LE(val & -1, offset);
207
- var hi = Math.floor(val * SHIFT_RIGHT_32);
208
- buf.writeUInt16LE(hi & 0xffff, offset + 4);
209
- buf.writeUInt8(hi >>> 16, offset + 6);
210
- } else {
211
- // Special case because 2^56-1 gets rounded up to 2^56
212
- buf[offset] = 0xff;
213
- buf[offset+1] = 0xff;
214
- buf[offset+2] = 0xff;
215
- buf[offset+3] = 0xff;
216
- buf[offset+4] = 0xff;
217
- buf[offset+5] = 0xff;
218
- buf[offset+6] = 0xff;
219
- }
220
- }
221
- module.exports.writeUInt56LE = writeUInt56LE;
222
-
223
- function readUInt64LE(buf, offset) {
224
- return buf.readUInt32LE(offset + 4) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
225
- }
226
- module.exports.readUInt64LE = readUInt64LE;
227
-
228
- function writeUInt64LE(buf, val, offset) {
229
- val = check_value(val, 0, 0xffffffffffffffff);
230
- check_bounds(buf, offset, 8);
231
-
232
- if (val < 0x10000000000000000) {
233
- buf.writeInt32LE(val & -1, offset);
234
- buf.writeUInt32LE(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
235
- } else {
236
- // Special case because 2^64-1 gets rounded up to 2^64
237
- buf[offset] = 0xff;
238
- buf[offset+1] = 0xff;
239
- buf[offset+2] = 0xff;
240
- buf[offset+3] = 0xff;
241
- buf[offset+4] = 0xff;
242
- buf[offset+5] = 0xff;
243
- buf[offset+6] = 0xff;
244
- buf[offset+7] = 0xff;
245
- }
246
- }
247
- module.exports.writeUInt64LE = writeUInt64LE;
248
-
249
-
250
- function readInt24BE(buf, offset) {
251
- return (buf.readInt8(offset) << 16) + buf.readUInt16BE(offset + 1);
252
- }
253
- module.exports.readInt24BE = readInt24BE;
254
-
255
- function writeInt24BE(buf, val, offset) {
256
- val = check_value(val, -0x800000, 0x7fffff);
257
- check_bounds(buf, offset, 3);
258
- buf.writeInt8(val >> 16, offset);
259
- buf.writeUInt16BE(val & 0xffff, offset + 1);
260
- }
261
- module.exports.writeInt24BE = writeInt24BE;
262
-
263
- function readInt40BE(buf, offset) {
264
- return (buf.readInt8(offset) || 0) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 1);
265
- }
266
- module.exports.readInt40BE = readInt40BE;
267
-
268
- function writeInt40BE(buf, val, offset) {
269
- val = check_value(val, -0x8000000000, 0x7fffffffff);
270
- check_bounds(buf, offset, 5);
271
- buf.writeInt8(Math.floor(val * SHIFT_RIGHT_32), offset);
272
- buf.writeInt32BE(val & -1, offset + 1);
273
- }
274
- module.exports.writeInt40BE = writeInt40BE;
275
-
276
- function readInt48BE(buf, offset) {
277
- return buf.readInt16BE(offset) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 2);
278
- }
279
- module.exports.readInt48BE = readInt48BE;
280
-
281
- function writeInt48BE(buf, val, offset) {
282
- val = check_value(val, -0x800000000000, 0x7fffffffffff);
283
- check_bounds(buf, offset, 6);
284
- buf.writeInt16BE(Math.floor(val * SHIFT_RIGHT_32), offset);
285
- buf.writeInt32BE(val & -1, offset + 2);
286
- }
287
- module.exports.writeInt48BE = writeInt48BE;
288
-
289
- function readInt56BE(buf, offset) {
290
- return (((buf.readInt8(offset) || 0) << 16) + buf.readUInt16BE(offset + 1)) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 3);
291
- }
292
- module.exports.readInt56BE = readInt56BE;
293
-
294
- function writeInt56BE(buf, val, offset) {
295
- val = check_value(val, -0x800000000000000, 0x7fffffffffffff);
296
- check_bounds(buf, offset, 7);
297
-
298
- if (val < 0x80000000000000) {
299
- var hi = Math.floor(val * SHIFT_RIGHT_32);
300
- buf.writeInt8(hi >> 16, offset);
301
- buf.writeUInt16BE(hi & 0xffff, offset + 1);
302
- buf.writeInt32BE(val & -1, offset + 3);
303
- } else {
304
- // Special case because 2^55-1 gets rounded up to 2^55
305
- buf[offset] = 0x7f;
306
- buf[offset+1] = 0xff;
307
- buf[offset+2] = 0xff;
308
- buf[offset+3] = 0xff;
309
- buf[offset+4] = 0xff;
310
- buf[offset+5] = 0xff;
311
- buf[offset+6] = 0xff;
312
- }
313
- }
314
- module.exports.writeInt56BE = writeInt56BE;
315
-
316
- function readInt64BE(buf, offset) {
317
- return buf.readInt32BE(offset) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 4);
318
- }
319
- module.exports.readInt64BE = readInt64BE;
320
-
321
- function writeInt64BE(buf, val, offset) {
322
- val = check_value(val, -0x800000000000000000, 0x7fffffffffffffff);
323
- check_bounds(buf, offset, 8);
324
-
325
- if (val < 0x8000000000000000) {
326
- buf.writeInt32BE(Math.floor(val * SHIFT_RIGHT_32), offset);
327
- buf.writeInt32BE(val & -1, offset + 4);
328
- } else {
329
- // Special case because 2^63-1 gets rounded up to 2^63
330
- buf[offset] = 0x7f;
331
- buf[offset+1] = 0xff;
332
- buf[offset+2] = 0xff;
333
- buf[offset+3] = 0xff;
334
- buf[offset+4] = 0xff;
335
- buf[offset+5] = 0xff;
336
- buf[offset+6] = 0xff;
337
- buf[offset+7] = 0xff;
338
- }
339
- }
340
- module.exports.writeInt64BE = writeInt64BE;
341
-
342
- function readInt24LE(buf, offset) {
343
- return (buf.readInt8(offset + 2) << 16) + buf.readUInt16LE(offset);
344
- }
345
- module.exports.readInt24LE = readInt24LE;
346
-
347
- function writeInt24LE(buf, val, offset) {
348
- val = check_value(val, -0x800000, 0x7fffff);
349
- check_bounds(buf, offset, 3);
350
- buf.writeUInt16LE(val & 0xffff, offset);
351
- buf.writeInt8(val >> 16, offset + 2);
352
- }
353
- module.exports.writeInt24LE = writeInt24LE;
354
-
355
- function readInt40LE(buf, offset) {
356
- return (buf.readInt8(offset + 4) || 0) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
357
- }
358
- module.exports.readInt40LE = readInt40LE;
359
-
360
- function writeInt40LE(buf, val, offset) {
361
- val = check_value(val, -0x8000000000, 0x7fffffffff);
362
- check_bounds(buf, offset, 5);
363
- buf.writeInt32LE(val & -1, offset);
364
- buf.writeInt8(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
365
- }
366
- module.exports.writeInt40LE = writeInt40LE;
367
-
368
- function readInt48LE(buf, offset) {
369
- return buf.readInt16LE(offset + 4) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
370
- }
371
- module.exports.readInt48LE = readInt48LE;
372
-
373
- function writeInt48LE(buf, val, offset) {
374
- val = check_value(val, -0x800000000000, 0x7fffffffffff);
375
- check_bounds(buf, offset, 6);
376
- buf.writeInt32LE(val & -1, offset);
377
- buf.writeInt16LE(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
378
- }
379
- module.exports.writeInt48LE = writeInt48LE;
380
-
381
- function readInt56LE(buf, offset) {
382
- return (((buf.readInt8(offset + 6) || 0) << 16) + buf.readUInt16LE(offset + 4)) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
383
- }
384
- module.exports.readInt56LE = readInt56LE;
385
-
386
- function writeInt56LE(buf, val, offset) {
387
- val = check_value(val, -0x80000000000000, 0x7fffffffffffff);
388
- check_bounds(buf, offset, 7);
389
-
390
- if (val < 0x80000000000000) {
391
- buf.writeInt32LE(val & -1, offset);
392
- var hi = Math.floor(val * SHIFT_RIGHT_32);
393
- buf.writeUInt16LE(hi & 0xffff, offset + 4);
394
- buf.writeInt8(hi >> 16, offset + 6);
395
- } else {
396
- // Special case because 2^55-1 gets rounded up to 2^55
397
- buf[offset] = 0xff;
398
- buf[offset+1] = 0xff;
399
- buf[offset+2] = 0xff;
400
- buf[offset+3] = 0xff;
401
- buf[offset+4] = 0xff;
402
- buf[offset+5] = 0xff;
403
- buf[offset+6] = 0x7f;
404
- }
405
- }
406
- module.exports.writeInt56LE = writeInt56LE;
407
-
408
- function readInt64LE(buf, offset) {
409
- return buf.readInt32LE(offset + 4) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
410
- }
411
- module.exports.readInt64LE = readInt64LE;
412
-
413
- function writeInt64LE(buf, val, offset) {
414
- val = check_value(val, -0x8000000000000000, 0x7fffffffffffffff);
415
- check_bounds(buf, offset, 8);
416
-
417
- if (val < 0x8000000000000000) {
418
- buf.writeInt32LE(val & -1, offset);
419
- buf.writeInt32LE(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
420
- } else {
421
- // Special case because 2^55-1 gets rounded up to 2^55
422
- buf[offset] = 0xff;
423
- buf[offset+1] = 0xff;
424
- buf[offset+2] = 0xff;
425
- buf[offset+3] = 0xff;
426
- buf[offset+4] = 0xff;
427
- buf[offset+5] = 0xff;
428
- buf[offset+6] = 0xff;
429
- buf[offset+7] = 0x7f;
430
- }
431
- }
432
- module.exports.writeInt64LE = writeInt64LE;
@@ -1,19 +0,0 @@
1
- {
2
- "name": "buffer-more-ints",
3
- "version": "1.0.0",
4
- "author": "David Wragg <david@wragg.org>",
5
- "description": "Add support for more integer widths to Buffer",
6
- "homepage": "https://github.com/dpw/node-buffer-more-ints",
7
- "license": "MIT",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/dpw/node-buffer-more-ints.git"
11
- },
12
- "main": "buffer-more-ints.js",
13
- "devDependencies": {
14
- "nodeunit": ""
15
- },
16
- "scripts": {
17
- "test": "node ./node_modules/nodeunit/bin/nodeunit buffer-more-ints-tests.js"
18
- }
19
- }