Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apache-arrow

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apache-arrow - npm Package Compare versions

Comparing version 0.4.1 to 0.13.0

91

bin/arrow2csv.js

@@ -10,3 +10,2 @@ #! /usr/bin/env node

const bignumJSONParse = require('json-bignum').parse;
const pipeline = require('util').promisify(stream.pipeline);
const argv = require(`command-line-args`)(cliOpts(), { partial: true });

@@ -28,7 +27,4 @@ const files = argv.help ? [] : [...(argv.file || []), ...(argv._unknown || [])].filter(Boolean);

hasReaders = true;
const source = reader.toNodeStream();
const xform = batchesToString(state, reader.schema);
const sink = new stream.PassThrough();
sink.pipe(process.stdout, { end: false });
await pipeline(source, xform, sink).catch(() => state.closed = true);
const transformToString = batchesToString(state, reader.schema);
await pipeTo(reader.pipe(transformToString), process.stdout, { end: false }).catch(() => state.closed = true); // Handle EPIPE errors
}

@@ -47,2 +43,14 @@ if (state.closed) {

}).then((code) => process.exit(code));
function pipeTo(source, sink, opts) {
return new Promise((resolve, reject) => {
source.on('end', onEnd).pipe(sink, opts).on('error', onErr);
function onEnd() { done(undefined, resolve); }
function onErr(err) { done(err, reject); }
function done(e, cb) {
source.removeListener('end', onEnd);
sink.removeListener('error', onErr);
cb(e);
}
});
}
async function* recordBatchReaders(createSourceStream) {

@@ -92,3 +100,2 @@ let json = new Arrow_node_1.AsyncByteQueue();

return new stream.Transform({
transform,
encoding: 'utf8',

@@ -108,43 +115,43 @@ writableObjectMode: true,

cb();
}
});
function transform(batch, _enc, cb) {
batch = !(state.schema && state.schema.length) ? batch : batch.select(...state.schema);
if (state.closed) {
return cb(undefined, null);
}
// Pass one to convert to strings and count max column widths
state.maxColWidths = measureColumnWidths(rowId, batch, header.map((x, i) => Math.max(maxColWidths[i] || 0, x.length)));
// If this is the first batch in a stream, print a top horizontal rule, schema metadata, and
if (++batchId === 0) {
this.push(`${horizontalRule(state.maxColWidths, hr, sep)}\n`);
if (state.metadata && batch.schema.metadata.size > 0) {
this.push(`metadata:\n${formatMetadata(batch.schema.metadata)}\n`);
},
transform(batch, _enc, cb) {
batch = !(state.schema && state.schema.length) ? batch : batch.select(...state.schema);
if (state.closed) {
return cb(undefined, null);
}
// Pass one to convert to strings and count max column widths
state.maxColWidths = measureColumnWidths(rowId, batch, header.map((x, i) => Math.max(maxColWidths[i] || 0, x.length)));
// If this is the first batch in a stream, print a top horizontal rule, schema metadata, and
if (++batchId === 0) {
this.push(`${horizontalRule(state.maxColWidths, hr, sep)}\n`);
if (state.metadata && batch.schema.metadata.size > 0) {
this.push(`metadata:\n${formatMetadata(batch.schema.metadata)}\n`);
this.push(`${horizontalRule(state.maxColWidths, hr, sep)}\n`);
}
if (batch.length <= 0 || batch.numCols <= 0) {
this.push(`${formatRow(header, maxColWidths = state.maxColWidths, sep)}\n`);
}
}
if (batch.length <= 0 || batch.numCols <= 0) {
this.push(`${formatRow(header, maxColWidths = state.maxColWidths, sep)}\n`);
}
}
if (batch.length > 0 && batch.numCols > 0) {
// If any of the column widths changed, print the header again
if (rowId % 350 !== 0 && JSON.stringify(state.maxColWidths) !== JSON.stringify(maxColWidths)) {
this.push(`${formatRow(header, state.maxColWidths, sep)}\n`);
}
maxColWidths = state.maxColWidths;
for (const row of batch) {
if (state.closed) {
break;
if (batch.length > 0 && batch.numCols > 0) {
// If any of the column widths changed, print the header again
if (rowId % 350 !== 0 && JSON.stringify(state.maxColWidths) !== JSON.stringify(maxColWidths)) {
this.push(`${formatRow(header, state.maxColWidths, sep)}\n`);
}
else if (!row) {
continue;
maxColWidths = state.maxColWidths;
for (const row of batch) {
if (state.closed) {
break;
}
else if (!row) {
continue;
}
if (rowId++ % 350 === 0) {
this.push(`${formatRow(header, maxColWidths, sep)}\n`);
}
this.push(`${formatRow([rowId, ...row].map(pretty_1.valueToString), maxColWidths, sep)}\n`);
}
if (rowId++ % 350 === 0) {
this.push(`${formatRow(header, maxColWidths, sep)}\n`);
}
this.push(`${formatRow([rowId, ...row].map(pretty_1.valueToString), maxColWidths, sep)}\n`);
}
cb();
}
cb();
}
});
}

@@ -151,0 +158,0 @@ function horizontalRule(maxColWidths, hr = '-', sep = ' |') {

@@ -62,5 +62,5 @@ /// <reference types="node" />

}, options?: PipeOptions): ReadableStream<any>;
private _DOMStream?;
protected _DOMStream?: ReadableStream<T>;
private _getDOMStream;
private _nodeStream?;
protected _nodeStream?: import('stream').Readable;
private _getNodeStream;

@@ -67,0 +67,0 @@ }

@@ -60,2 +60,4 @@ "use strict";

this._impl.reset(schema);
this._DOMStream = undefined;
this._nodeStream = undefined;
return this;

@@ -62,0 +64,0 @@ }

{
"version": "0.4.1",
"version": "0.13.0",
"name": "apache-arrow",

@@ -4,0 +4,0 @@ "unpkg": "Arrow.es5.min.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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