Socket
Socket
Sign inDemoInstall

@clickhouse/client

Package Overview
Dependencies
Maintainers
4
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clickhouse/client - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

61

dist/result_set.js

@@ -28,4 +28,6 @@ "use strict";

const client_common_1 = require("@clickhouse/client-common");
const buffer_1 = require("buffer");
const stream_1 = __importStar(require("stream"));
const utils_1 = require("./utils");
const NEWLINE = 0x0a;
class ResultSet {

@@ -72,27 +74,50 @@ constructor(_stream, format, query_id) {

(0, client_common_1.validateStreamFormat)(this.format);
let decodedChunk = '';
let incompleteChunks = [];
const toRows = new stream_1.Transform({
transform(chunk, encoding, callback) {
decodedChunk += chunk.toString();
transform(chunk, _encoding, callback) {
const rows = [];
// eslint-disable-next-line no-constant-condition
while (true) {
const idx = decodedChunk.indexOf('\n');
if (idx !== -1) {
const text = decodedChunk.slice(0, idx);
decodedChunk = decodedChunk.slice(idx + 1);
rows.push({
text,
json() {
return (0, client_common_1.decode)(text, 'JSON');
},
});
let lastIdx = 0;
// first pass on the current chunk
// using the incomplete row from the previous chunks
let idx = chunk.indexOf(NEWLINE);
if (idx !== -1) {
let text;
if (incompleteChunks.length > 0) {
text = buffer_1.Buffer.concat([...incompleteChunks, chunk.subarray(0, idx)], incompleteChunks.reduce((sz, buf) => sz + buf.length, 0) + idx).toString();
incompleteChunks = [];
}
else {
if (rows.length) {
text = chunk.subarray(0, idx).toString();
}
rows.push({
text,
json() {
return JSON.parse(text);
},
});
lastIdx = idx + 1; // skipping newline character
// consequent passes on the current chunk with at least one row parsed
// all previous chunks with incomplete rows were already processed
do {
idx = chunk.indexOf(NEWLINE, lastIdx);
if (idx !== -1) {
const text = chunk.subarray(lastIdx, idx).toString();
rows.push({
text,
json() {
return JSON.parse(text);
},
});
}
else {
// to be processed during the first pass for the next chunk
incompleteChunks.push(chunk.subarray(lastIdx));
this.push(rows);
}
break;
}
lastIdx = idx + 1; // skipping newline character
} while (idx !== -1);
}
else {
incompleteChunks.push(chunk); // this chunk does not contain a full row
}
callback();

@@ -99,0 +124,0 @@ },

@@ -1,2 +0,2 @@

declare const _default: "0.2.3";
declare const _default: "0.2.4";
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = '0.2.3';
exports.default = '0.2.4';
//# sourceMappingURL=version.js.map

@@ -5,3 +5,3 @@ {

"homepage": "https://clickhouse.com",
"version": "0.2.3",
"version": "0.2.4",
"license": "Apache-2.0",

@@ -27,4 +27,4 @@ "keywords": [

"dependencies": {
"@clickhouse/client-common": "0.2.3"
"@clickhouse/client-common": "0.2.4"
}
}
<p align="center">
<img src=".static/logo.png" width="200px" align="center">
<img src=".static/logo.svg" width="200px" align="center">
<h1 align="center">ClickHouse JS client</h1>

@@ -4,0 +4,0 @@ </p>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc