@databricks/sql 1.1.0 → 1.2.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.
Files changed (108) hide show
  1. package/dist/DBSQLClient.d.ts +3 -1
  2. package/dist/DBSQLClient.js +11 -8
  3. package/dist/DBSQLClient.js.map +1 -1
  4. package/dist/DBSQLOperation/SchemaHelper.d.ts +1 -1
  5. package/dist/DBSQLOperation/SchemaHelper.js +4 -2
  6. package/dist/DBSQLOperation/SchemaHelper.js.map +1 -1
  7. package/dist/DBSQLSession.js +20 -1
  8. package/dist/DBSQLSession.js.map +1 -1
  9. package/dist/connection/auth/PlainHttpAuthentication.d.ts +1 -1
  10. package/dist/connection/contracts/IConnectionOptions.d.ts +1 -1
  11. package/dist/connection/contracts/ITransport.d.ts +1 -1
  12. package/dist/connection/types/AuthOptions.d.ts +1 -1
  13. package/dist/contracts/IDBSQLSession.d.ts +10 -10
  14. package/dist/contracts/IOperation.d.ts +1 -1
  15. package/dist/dto/InfoValue.d.ts +1 -1
  16. package/dist/dto/Status.d.ts +1 -1
  17. package/dist/globalConfig.d.ts +5 -0
  18. package/dist/globalConfig.js +7 -0
  19. package/dist/globalConfig.js.map +1 -0
  20. package/dist/hive/Types/index.d.ts +1 -1
  21. package/dist/result/ArrowResult.d.ts +14 -0
  22. package/dist/result/ArrowResult.js +105 -0
  23. package/dist/result/ArrowResult.js.map +1 -0
  24. package/dist/result/JsonResult.d.ts +1 -5
  25. package/dist/result/JsonResult.js +5 -59
  26. package/dist/result/JsonResult.js.map +1 -1
  27. package/dist/result/utils.d.ts +3 -0
  28. package/dist/result/utils.js +77 -0
  29. package/dist/result/utils.js.map +1 -0
  30. package/dist/version.d.ts +1 -1
  31. package/dist/version.js +1 -1
  32. package/node_modules/async-limiter/.eslintignore +2 -0
  33. package/node_modules/async-limiter/.nycrc +10 -0
  34. package/node_modules/async-limiter/.travis.yml +9 -0
  35. package/node_modules/async-limiter/LICENSE +8 -0
  36. package/node_modules/async-limiter/index.js +67 -0
  37. package/node_modules/async-limiter/package.json +35 -0
  38. package/node_modules/async-limiter/readme.md +132 -0
  39. package/node_modules/browser-or-node/LICENSE +21 -0
  40. package/node_modules/browser-or-node/README.md +63 -0
  41. package/node_modules/browser-or-node/lib/index.js +31 -0
  42. package/node_modules/browser-or-node/package.json +60 -0
  43. package/node_modules/browser-or-node/src/index.js +26 -0
  44. package/node_modules/isomorphic-ws/LICENSE +21 -0
  45. package/node_modules/isomorphic-ws/README.md +58 -0
  46. package/node_modules/isomorphic-ws/browser.js +17 -0
  47. package/node_modules/isomorphic-ws/index.d.ts +8 -0
  48. package/node_modules/isomorphic-ws/node.js +3 -0
  49. package/node_modules/isomorphic-ws/package.json +34 -0
  50. package/node_modules/node-int64/.npmignore +3 -0
  51. package/node_modules/node-int64/Int64.js +268 -0
  52. package/node_modules/node-int64/LICENSE +19 -0
  53. package/node_modules/node-int64/README.md +78 -0
  54. package/node_modules/node-int64/package.json +27 -0
  55. package/node_modules/node-int64/test.js +120 -0
  56. package/node_modules/q/CHANGES.md +800 -0
  57. package/node_modules/q/LICENSE +18 -0
  58. package/node_modules/q/README.md +874 -0
  59. package/node_modules/q/package.json +76 -0
  60. package/node_modules/q/q.js +2076 -0
  61. package/node_modules/q/queue.js +35 -0
  62. package/node_modules/thrift/LICENSE +306 -0
  63. package/node_modules/thrift/README.md +210 -0
  64. package/node_modules/thrift/lib/nodejs/README.md +142 -0
  65. package/node_modules/thrift/lib/nodejs/lib/thrift/binary.js +168 -0
  66. package/node_modules/thrift/lib/nodejs/lib/thrift/binary_protocol.js +367 -0
  67. package/node_modules/thrift/lib/nodejs/lib/thrift/browser.js +49 -0
  68. package/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js +186 -0
  69. package/node_modules/thrift/lib/nodejs/lib/thrift/compact_protocol.js +915 -0
  70. package/node_modules/thrift/lib/nodejs/lib/thrift/connection.js +396 -0
  71. package/node_modules/thrift/lib/nodejs/lib/thrift/create_client.js +54 -0
  72. package/node_modules/thrift/lib/nodejs/lib/thrift/framed_transport.js +185 -0
  73. package/node_modules/thrift/lib/nodejs/lib/thrift/header_protocol.js +258 -0
  74. package/node_modules/thrift/lib/nodejs/lib/thrift/header_transport.js +341 -0
  75. package/node_modules/thrift/lib/nodejs/lib/thrift/http_connection.js +282 -0
  76. package/node_modules/thrift/lib/nodejs/lib/thrift/index.js +76 -0
  77. package/node_modules/thrift/lib/nodejs/lib/thrift/input_buffer_underrun_error.js +32 -0
  78. package/node_modules/thrift/lib/nodejs/lib/thrift/int64_util.js +91 -0
  79. package/node_modules/thrift/lib/nodejs/lib/thrift/json_parse.js +299 -0
  80. package/node_modules/thrift/lib/nodejs/lib/thrift/json_protocol.js +799 -0
  81. package/node_modules/thrift/lib/nodejs/lib/thrift/log.js +87 -0
  82. package/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_processor.js +63 -0
  83. package/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_protocol.js +73 -0
  84. package/node_modules/thrift/lib/nodejs/lib/thrift/protocol.js +22 -0
  85. package/node_modules/thrift/lib/nodejs/lib/thrift/server.js +123 -0
  86. package/node_modules/thrift/lib/nodejs/lib/thrift/thrift.js +241 -0
  87. package/node_modules/thrift/lib/nodejs/lib/thrift/transport.js +22 -0
  88. package/node_modules/thrift/lib/nodejs/lib/thrift/web_server.js +567 -0
  89. package/node_modules/thrift/lib/nodejs/lib/thrift/ws_connection.js +286 -0
  90. package/node_modules/thrift/lib/nodejs/lib/thrift/ws_transport.js +206 -0
  91. package/node_modules/thrift/lib/nodejs/lib/thrift/xhr_connection.js +280 -0
  92. package/node_modules/thrift/package.json +72 -0
  93. package/node_modules/ws/LICENSE +21 -0
  94. package/node_modules/ws/README.md +417 -0
  95. package/node_modules/ws/index.js +9 -0
  96. package/node_modules/ws/lib/buffer-util.js +72 -0
  97. package/node_modules/ws/lib/constants.js +10 -0
  98. package/node_modules/ws/lib/event-target.js +170 -0
  99. package/node_modules/ws/lib/extension.js +211 -0
  100. package/node_modules/ws/lib/permessage-deflate.js +516 -0
  101. package/node_modules/ws/lib/receiver.js +513 -0
  102. package/node_modules/ws/lib/sender.js +401 -0
  103. package/node_modules/ws/lib/validation.js +29 -0
  104. package/node_modules/ws/lib/websocket-server.js +369 -0
  105. package/node_modules/ws/lib/websocket.js +828 -0
  106. package/node_modules/ws/package.json +44 -0
  107. package/package.json +12 -8
  108. package/CHANGELOG.md +0 -56
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.convertThriftValue = exports.getSchemaColumns = void 0;
7
+ const node_int64_1 = __importDefault(require("node-int64"));
8
+ const TCLIService_types_1 = require("../../thrift/TCLIService_types");
9
+ function getSchemaColumns(schema) {
10
+ if (!schema) {
11
+ return [];
12
+ }
13
+ return [...schema.columns].sort((c1, c2) => c1.position - c2.position);
14
+ }
15
+ exports.getSchemaColumns = getSchemaColumns;
16
+ function isString(value) {
17
+ return typeof value === 'string' || value instanceof String;
18
+ }
19
+ function convertJSON(value, defaultValue) {
20
+ if (!isString(value)) {
21
+ return value;
22
+ }
23
+ try {
24
+ return JSON.parse(value);
25
+ }
26
+ catch (e) {
27
+ return defaultValue;
28
+ }
29
+ }
30
+ function convertBigInt(value) {
31
+ if (typeof value === 'bigint') {
32
+ return Number(value);
33
+ }
34
+ if (value instanceof node_int64_1.default) {
35
+ return value.toNumber();
36
+ }
37
+ return value;
38
+ }
39
+ function convertThriftValue(typeDescriptor, value) {
40
+ if (!typeDescriptor) {
41
+ return value;
42
+ }
43
+ switch (typeDescriptor.type) {
44
+ case TCLIService_types_1.TTypeId.DATE_TYPE:
45
+ case TCLIService_types_1.TTypeId.TIMESTAMP_TYPE:
46
+ return value;
47
+ case TCLIService_types_1.TTypeId.UNION_TYPE:
48
+ case TCLIService_types_1.TTypeId.USER_DEFINED_TYPE:
49
+ return String(value);
50
+ case TCLIService_types_1.TTypeId.DECIMAL_TYPE:
51
+ return Number(value);
52
+ case TCLIService_types_1.TTypeId.STRUCT_TYPE:
53
+ case TCLIService_types_1.TTypeId.MAP_TYPE:
54
+ return convertJSON(value, {});
55
+ case TCLIService_types_1.TTypeId.ARRAY_TYPE:
56
+ return convertJSON(value, []);
57
+ case TCLIService_types_1.TTypeId.BIGINT_TYPE:
58
+ return convertBigInt(value);
59
+ case TCLIService_types_1.TTypeId.NULL_TYPE:
60
+ case TCLIService_types_1.TTypeId.BINARY_TYPE:
61
+ case TCLIService_types_1.TTypeId.INTERVAL_YEAR_MONTH_TYPE:
62
+ case TCLIService_types_1.TTypeId.INTERVAL_DAY_TIME_TYPE:
63
+ case TCLIService_types_1.TTypeId.FLOAT_TYPE:
64
+ case TCLIService_types_1.TTypeId.DOUBLE_TYPE:
65
+ case TCLIService_types_1.TTypeId.INT_TYPE:
66
+ case TCLIService_types_1.TTypeId.SMALLINT_TYPE:
67
+ case TCLIService_types_1.TTypeId.TINYINT_TYPE:
68
+ case TCLIService_types_1.TTypeId.BOOLEAN_TYPE:
69
+ case TCLIService_types_1.TTypeId.STRING_TYPE:
70
+ case TCLIService_types_1.TTypeId.CHAR_TYPE:
71
+ case TCLIService_types_1.TTypeId.VARCHAR_TYPE:
72
+ default:
73
+ return value;
74
+ }
75
+ }
76
+ exports.convertThriftValue = convertThriftValue;
77
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/result/utils.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,sEAAyG;AAEzG,SAAgB,gBAAgB,CAAC,MAAqB;IACpD,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,EAAE,CAAC;KACX;IAED,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;AACzE,CAAC;AAND,4CAMC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,CAAC;AAC9D,CAAC;AAED,SAAS,WAAW,CAAC,KAAU,EAAE,YAAiB;IAChD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACpB,OAAO,KAAK,CAAC;KACd;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KAC1B;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,YAAY,CAAC;KACrB;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAU;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;KACtB;IACD,IAAI,KAAK,YAAY,oBAAK,EAAE;QAC1B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;KACzB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,kBAAkB,CAAC,cAA+C,EAAE,KAAU;IAC5F,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IAED,QAAQ,cAAc,CAAC,IAAI,EAAE;QAC3B,KAAK,2BAAO,CAAC,SAAS,CAAC;QACvB,KAAK,2BAAO,CAAC,cAAc;YACzB,OAAO,KAAK,CAAC;QACf,KAAK,2BAAO,CAAC,UAAU,CAAC;QACxB,KAAK,2BAAO,CAAC,iBAAiB;YAC5B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,KAAK,2BAAO,CAAC,YAAY;YACvB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,KAAK,2BAAO,CAAC,WAAW,CAAC;QACzB,KAAK,2BAAO,CAAC,QAAQ;YACnB,OAAO,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAChC,KAAK,2BAAO,CAAC,UAAU;YACrB,OAAO,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAChC,KAAK,2BAAO,CAAC,WAAW;YACtB,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK,2BAAO,CAAC,SAAS,CAAC;QACvB,KAAK,2BAAO,CAAC,WAAW,CAAC;QACzB,KAAK,2BAAO,CAAC,wBAAwB,CAAC;QACtC,KAAK,2BAAO,CAAC,sBAAsB,CAAC;QACpC,KAAK,2BAAO,CAAC,UAAU,CAAC;QACxB,KAAK,2BAAO,CAAC,WAAW,CAAC;QACzB,KAAK,2BAAO,CAAC,QAAQ,CAAC;QACtB,KAAK,2BAAO,CAAC,aAAa,CAAC;QAC3B,KAAK,2BAAO,CAAC,YAAY,CAAC;QAC1B,KAAK,2BAAO,CAAC,YAAY,CAAC;QAC1B,KAAK,2BAAO,CAAC,WAAW,CAAC;QACzB,KAAK,2BAAO,CAAC,SAAS,CAAC;QACvB,KAAK,2BAAO,CAAC,YAAY,CAAC;QAC1B;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC;AArCD,gDAqCC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.1.0";
1
+ declare const _default: "1.2.0";
2
2
  export default _default;
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.1.0';
3
+ exports.default = '1.2.0';
4
4
  //# sourceMappingURL=version.js.map
@@ -0,0 +1,2 @@
1
+ coverage
2
+ .nyc_output
@@ -0,0 +1,10 @@
1
+ {
2
+ "check-coverage": false,
3
+ "lines": 99,
4
+ "statements": 99,
5
+ "functions": 99,
6
+ "branches": 99,
7
+ "include": [
8
+ "index.js"
9
+ ]
10
+ }
@@ -0,0 +1,9 @@
1
+ language: node_js
2
+ node_js:
3
+ - "6"
4
+ - "8"
5
+ - "10"
6
+ - "node"
7
+ script: npm run travis
8
+ cache:
9
+ yarn: true
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2017 Samuel Reed <samuel.trace.reed@gmail.com>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ function Queue(options) {
4
+ if (!(this instanceof Queue)) {
5
+ return new Queue(options);
6
+ }
7
+
8
+ options = options || {};
9
+ this.concurrency = options.concurrency || Infinity;
10
+ this.pending = 0;
11
+ this.jobs = [];
12
+ this.cbs = [];
13
+ this._done = done.bind(this);
14
+ }
15
+
16
+ var arrayAddMethods = [
17
+ 'push',
18
+ 'unshift',
19
+ 'splice'
20
+ ];
21
+
22
+ arrayAddMethods.forEach(function(method) {
23
+ Queue.prototype[method] = function() {
24
+ var methodResult = Array.prototype[method].apply(this.jobs, arguments);
25
+ this._run();
26
+ return methodResult;
27
+ };
28
+ });
29
+
30
+ Object.defineProperty(Queue.prototype, 'length', {
31
+ get: function() {
32
+ return this.pending + this.jobs.length;
33
+ }
34
+ });
35
+
36
+ Queue.prototype._run = function() {
37
+ if (this.pending === this.concurrency) {
38
+ return;
39
+ }
40
+ if (this.jobs.length) {
41
+ var job = this.jobs.shift();
42
+ this.pending++;
43
+ job(this._done);
44
+ this._run();
45
+ }
46
+
47
+ if (this.pending === 0) {
48
+ while (this.cbs.length !== 0) {
49
+ var cb = this.cbs.pop();
50
+ process.nextTick(cb);
51
+ }
52
+ }
53
+ };
54
+
55
+ Queue.prototype.onDone = function(cb) {
56
+ if (typeof cb === 'function') {
57
+ this.cbs.push(cb);
58
+ this._run();
59
+ }
60
+ };
61
+
62
+ function done() {
63
+ this.pending--;
64
+ this._run();
65
+ }
66
+
67
+ module.exports = Queue;
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "async-limiter",
3
+ "version": "1.0.1",
4
+ "description": "asynchronous function queue with adjustable concurrency",
5
+ "keywords": [
6
+ "throttle",
7
+ "async",
8
+ "limiter",
9
+ "asynchronous",
10
+ "job",
11
+ "task",
12
+ "concurrency",
13
+ "concurrent"
14
+ ],
15
+ "dependencies": {},
16
+ "devDependencies": {
17
+ "coveralls": "^3.0.3",
18
+ "eslint": "^5.16.0",
19
+ "eslint-plugin-mocha": "^5.3.0",
20
+ "intelli-espower-loader": "^1.0.1",
21
+ "mocha": "^6.1.4",
22
+ "nyc": "^14.1.1",
23
+ "power-assert": "^1.6.1"
24
+ },
25
+ "scripts": {
26
+ "test": "mocha --require intelli-espower-loader test/",
27
+ "travis": "npm run lint && npm run test",
28
+ "coverage": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
29
+ "example": "node example",
30
+ "lint": "eslint ."
31
+ },
32
+ "repository": "https://github.com/strml/async-limiter.git",
33
+ "author": "Samuel Reed <samuel.trace.reed@gmail.com",
34
+ "license": "MIT"
35
+ }
@@ -0,0 +1,132 @@
1
+ # Async-Limiter
2
+
3
+ A module for limiting concurrent asynchronous actions in flight. Forked from [queue](https://github.com/jessetane/queue).
4
+
5
+ [![npm](http://img.shields.io/npm/v/async-limiter.svg?style=flat-square)](http://www.npmjs.org/async-limiter)
6
+ [![tests](https://img.shields.io/travis/STRML/async-limiter.svg?style=flat-square&branch=master)](https://travis-ci.org/STRML/async-limiter)
7
+ [![coverage](https://img.shields.io/coveralls/STRML/async-limiter.svg?style=flat-square&branch=master)](https://coveralls.io/r/STRML/async-limiter)
8
+
9
+ This module exports a class `Limiter` that implements some of the `Array` API.
10
+ Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods.
11
+
12
+ ## Motivation
13
+
14
+ Certain functions, like `zlib`, have [undesirable behavior](https://github.com/nodejs/node/issues/8871#issuecomment-250915913) when
15
+ run at infinite concurrency.
16
+
17
+ In this case, it is actually faster, and takes far less memory, to limit concurrency.
18
+
19
+ This module should do the absolute minimum work necessary to queue up functions. PRs are welcome that would
20
+ make this module faster or lighter, but new functionality is not desired.
21
+
22
+ Style should confirm to nodejs/node style.
23
+
24
+ ## Example
25
+
26
+ ``` javascript
27
+ var Limiter = require('async-limiter')
28
+
29
+ var t = new Limiter({concurrency: 2});
30
+ var results = []
31
+
32
+ // add jobs using the familiar Array API
33
+ t.push(function (cb) {
34
+ results.push('two')
35
+ cb()
36
+ })
37
+
38
+ t.push(
39
+ function (cb) {
40
+ results.push('four')
41
+ cb()
42
+ },
43
+ function (cb) {
44
+ results.push('five')
45
+ cb()
46
+ }
47
+ )
48
+
49
+ t.unshift(function (cb) {
50
+ results.push('one')
51
+ cb()
52
+ })
53
+
54
+ t.splice(2, 0, function (cb) {
55
+ results.push('three')
56
+ cb()
57
+ })
58
+
59
+ // Jobs run automatically. If you want a callback when all are done,
60
+ // call 'onDone()'.
61
+ t.onDone(function () {
62
+ console.log('all done:', results)
63
+ })
64
+ ```
65
+
66
+ ## Zlib Example
67
+
68
+ ```js
69
+ const zlib = require('zlib');
70
+ const Limiter = require('async-limiter');
71
+
72
+ const message = {some: "data"};
73
+ const payload = new Buffer(JSON.stringify(message));
74
+
75
+ // Try with different concurrency values to see how this actually
76
+ // slows significantly with higher concurrency!
77
+ //
78
+ // 5: 1398.607ms
79
+ // 10: 1375.668ms
80
+ // Infinity: 4423.300ms
81
+ //
82
+ const t = new Limiter({concurrency: 5});
83
+ function deflate(payload, cb) {
84
+ t.push(function(done) {
85
+ zlib.deflate(payload, function(err, buffer) {
86
+ done();
87
+ cb(err, buffer);
88
+ });
89
+ });
90
+ }
91
+
92
+ console.time('deflate');
93
+ for(let i = 0; i < 30000; ++i) {
94
+ deflate(payload, function (err, buffer) {});
95
+ }
96
+ t.onDone(function() {
97
+ console.timeEnd('deflate');
98
+ });
99
+ ```
100
+
101
+ ## Install
102
+
103
+ `npm install async-limiter`
104
+
105
+ ## Test
106
+
107
+ `npm test`
108
+
109
+ ## API
110
+
111
+ ### `var t = new Limiter([opts])`
112
+ Constructor. `opts` may contain inital values for:
113
+ * `t.concurrency`
114
+
115
+ ## Instance methods
116
+
117
+ ### `t.onDone(fn)`
118
+ `fn` will be called once and only once, when the queue is empty.
119
+
120
+ ## Instance methods mixed in from `Array`
121
+ Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
122
+ ### `t.push(element1, ..., elementN)`
123
+ ### `t.unshift(element1, ..., elementN)`
124
+ ### `t.splice(index , howMany[, element1[, ...[, elementN]]])`
125
+
126
+ ## Properties
127
+ ### `t.concurrency`
128
+ Max number of jobs the queue should process concurrently, defaults to `Infinity`.
129
+
130
+ ### `t.length`
131
+ Jobs pending + jobs to process (readonly).
132
+
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Dineshkumar Pandiyan <flexdinesh@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,63 @@
1
+ # Browser or Node.js
2
+
3
+ [![Build Status](https://travis-ci.org/flexdinesh/browser-or-node.svg?branch=master)](https://travis-ci.org/flexdinesh/browser-or-node)
4
+ [![npm version](https://badge.fury.io/js/browser-or-node.svg)](https://www.npmjs.com/package/browser-or-node)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ Check whether the code is running in the browser or node.js runtime.
8
+
9
+ ## Install
10
+
11
+ ```
12
+ $ npm install --save browser-or-node
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ES6 style import
18
+
19
+ ```js
20
+ import { isBrowser, isNode, isWebWorker, isJsDom } from "browser-or-node";
21
+
22
+ if (isBrowser) {
23
+ // do browser only stuff
24
+ }
25
+
26
+ if (isNode) {
27
+ // do node.js only stuff
28
+ }
29
+
30
+ if (isWebWorker) {
31
+ // do web worker only stuff
32
+ }
33
+
34
+ if (isJsDom) {
35
+ // do jsdom only stuff
36
+ }
37
+ ```
38
+
39
+ ES5 style import
40
+
41
+ ```js
42
+ var jsEnv = require("browser-or-node");
43
+
44
+ if (jsEnv.isBrowser) {
45
+ // do browser only stuff
46
+ }
47
+
48
+ if (jsEnv.isNode) {
49
+ // do node.js only stuff
50
+ }
51
+
52
+ if (jsEnv.isWebWorker) {
53
+ // do web worker only stuff
54
+ }
55
+
56
+ if (jsEnv.isJsDom) {
57
+ // do jsdom only stuff
58
+ }
59
+ ```
60
+
61
+ ## License
62
+
63
+ MIT © Dineshkumar Pandiyan
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
8
+
9
+ /* global window self */
10
+
11
+ var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
12
+
13
+ /* eslint-disable no-restricted-globals */
14
+ var isWebWorker = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) === 'object' && self.constructor && self.constructor.name === 'DedicatedWorkerGlobalScope';
15
+ /* eslint-enable no-restricted-globals */
16
+
17
+ var isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
18
+
19
+ /**
20
+ * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0
21
+ * @see https://github.com/jsdom/jsdom/issues/1537
22
+ */
23
+ /* eslint-disable no-undef */
24
+ var isJsDom = function isJsDom() {
25
+ return typeof window !== 'undefined' && window.name === 'nodejs' || navigator.userAgent.includes('Node.js') || navigator.userAgent.includes('jsdom');
26
+ };
27
+
28
+ exports.isBrowser = isBrowser;
29
+ exports.isWebWorker = isWebWorker;
30
+ exports.isNode = isNode;
31
+ exports.isJsDom = isJsDom;
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "browser-or-node",
3
+ "version": "1.3.0",
4
+ "description": "Check where the code is running in the browser or node.js",
5
+ "main": "./lib/index.js",
6
+ "scripts": {
7
+ "clean": "rimraf lib",
8
+ "test": "npm run cover",
9
+ "test:only": "cross-env BABEL_ENV=commonjs mocha --require babel-core/register --recursive",
10
+ "test:watch": "npm test -- --watch",
11
+ "test:examples": "node examples/",
12
+ "cover": "cross-env BABEL_ENV=commonjs istanbul cover node_modules/mocha/bin/_mocha -- --require babel-core/register --recursive",
13
+ "lint": "eslint src",
14
+ "build": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
15
+ "prepublish": "npm run clean && npm run lint && npm run test && npm run build"
16
+ },
17
+ "files": [
18
+ "lib",
19
+ "src"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/flexdinesh/browser-or-node.git"
24
+ },
25
+ "keywords": [
26
+ "npm",
27
+ "browser",
28
+ "node",
29
+ "is browser",
30
+ "is node",
31
+ "is browser node"
32
+ ],
33
+ "author": "Dineshkumar Pandiyan <flexdinesh@gmail.com>",
34
+ "contributors": [
35
+ "Daniel Wang <daniel.liberated@gmail.com> (https://github.com/dan1wang/)"
36
+ ],
37
+ "license": "MIT",
38
+ "bugs": {
39
+ "url": "https://github.com/flexdinesh/browser-or-node/issues"
40
+ },
41
+ "homepage": "https://github.com/flexdinesh/browser-or-node#readme",
42
+ "devDependencies": {
43
+ "babel": "^6.23.0",
44
+ "babel-cli": "^6.26.0",
45
+ "babel-eslint": "^10.1.0",
46
+ "babel-plugin-add-module-exports": "^1.0.2",
47
+ "babel-preset-es2015": "^6.24.1",
48
+ "babel-preset-stage-2": "^6.24.1",
49
+ "chai": "^4.2.0",
50
+ "cross-env": "^7.0.2",
51
+ "eslint": "^7.3.1",
52
+ "eslint-config-airbnb": "^18.2.0",
53
+ "eslint-plugin-import": "^2.21.2",
54
+ "eslint-plugin-jsx-a11y": "^6.3.1",
55
+ "eslint-plugin-react": "^7.20.0",
56
+ "istanbul": "^1.0.0-alpha",
57
+ "mocha": "^8.0.1",
58
+ "rimraf": "^3.0.2"
59
+ }
60
+ }
@@ -0,0 +1,26 @@
1
+ /* global window self */
2
+
3
+ const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
4
+
5
+ /* eslint-disable no-restricted-globals */
6
+ const isWebWorker = typeof self === 'object'
7
+ && self.constructor
8
+ && self.constructor.name === 'DedicatedWorkerGlobalScope';
9
+ /* eslint-enable no-restricted-globals */
10
+
11
+ const isNode = typeof process !== 'undefined'
12
+ && process.versions != null
13
+ && process.versions.node != null;
14
+
15
+ /**
16
+ * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0
17
+ * @see https://github.com/jsdom/jsdom/issues/1537
18
+ */
19
+ /* eslint-disable no-undef */
20
+ const isJsDom = () => (typeof window !== 'undefined' && window.name === 'nodejs')
21
+ || navigator.userAgent.includes('Node.js')
22
+ || navigator.userAgent.includes('jsdom');
23
+
24
+ export {
25
+ isBrowser, isWebWorker, isNode, isJsDom
26
+ };
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Zejin Zhuang <heineiuo@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,58 @@
1
+ # isomorphic-ws
2
+
3
+ Isomorphic implementation of WebSocket.
4
+
5
+ It uses:
6
+ - [ws](https://github.com/websockets/ws) on Node
7
+ - [global.WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) in browsers
8
+
9
+ ## Limitations
10
+
11
+ Before using this module you should know that
12
+ [`ws`](https://github.com/websockets/ws/blob/master/doc/ws.md#class-websocket)
13
+ is not perfectly API compatible with
14
+ [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket),
15
+ you should always test your code against both Node and browsers.
16
+
17
+ Some major differences:
18
+
19
+ - no `Server` implementation in browsers
20
+
21
+ ## Usage
22
+
23
+ You need to install both this package and [ws](https://github.com/websockets/ws):
24
+
25
+ ```
26
+ > npm i isomorphic-ws ws
27
+ ```
28
+
29
+ Then just require this package:
30
+
31
+ ```js
32
+ const WebSocket = require('isomorphic-ws')
33
+
34
+ const ws = new WebSocket('wss://echo.websocket.org/', {
35
+ origin: 'https://websocket.org'
36
+ });
37
+
38
+ ws.onopen = function open() {
39
+ console.log('connected');
40
+ ws.send(Date.now());
41
+ });
42
+
43
+ ws.onclose = function close() {
44
+ console.log('disconnected');
45
+ });
46
+
47
+ ws.onmessage = function incoming(data) {
48
+ console.log(`Roundtrip time: ${Date.now() - data} ms`);
49
+
50
+ setTimeout(function timeout() {
51
+ ws.send(Date.now());
52
+ }, 500);
53
+ });
54
+ ```
55
+
56
+ ## License
57
+
58
+ [MIT](LICENSE)
@@ -0,0 +1,17 @@
1
+ // https://github.com/maxogden/websocket-stream/blob/48dc3ddf943e5ada668c31ccd94e9186f02fafbd/ws-fallback.js
2
+
3
+ var ws = null
4
+
5
+ if (typeof WebSocket !== 'undefined') {
6
+ ws = WebSocket
7
+ } else if (typeof MozWebSocket !== 'undefined') {
8
+ ws = MozWebSocket
9
+ } else if (typeof global !== 'undefined') {
10
+ ws = global.WebSocket || global.MozWebSocket
11
+ } else if (typeof window !== 'undefined') {
12
+ ws = window.WebSocket || window.MozWebSocket
13
+ } else if (typeof self !== 'undefined') {
14
+ ws = self.WebSocket || self.MozWebSocket
15
+ }
16
+
17
+ module.exports = ws
@@ -0,0 +1,8 @@
1
+ // Type definitions for isomorphic-ws
2
+ // Run `npm install @types/ws` before using this.
3
+ // Fix for https://github.com/heineiuo/isomorphic-ws/issues/8
4
+ // If there is still something wrong, welcome issue.
5
+
6
+ import WebSocket = require('ws')
7
+
8
+ export = WebSocket