diff --git a/js/src/Arrow.externs.js b/js/src/Arrow.externs.js index a549cae5a7c8b..438ac8b736cac 100644 --- a/js/src/Arrow.externs.js +++ b/js/src/Arrow.externs.js @@ -38,8 +38,6 @@ Table.empty = function() {}; /** @type {?} */ Table.prototype.schema; /** @type {?} */ -Table.prototype.columns; -/** @type {?} */ Table.prototype.length; /** @type {?} */ Table.prototype.numCols; @@ -58,15 +56,13 @@ Table.prototype.select; /** @type {?} */ Table.prototype.rowsToString; /** @type {?} */ -Table.prototype.lengths; +Table.prototype.batchesUnion; /** @type {?} */ Table.prototype.batches; /** @type {?} */ Table.prototype.countBy; /** @type {?} */ Table.prototype.scan; -/** @type {?} */ -Table.prototype.get; var CountByResult = function() {}; /** @type {?} */ @@ -124,7 +120,7 @@ RecordBatch.from = function() {}; /** @type {?} */ RecordBatch.prototype.numCols; /** @type {?} */ -RecordBatch.prototype.numRows; +RecordBatch.prototype.length; /** @type {?} */ RecordBatch.prototype.schema; /** @type {?} */ @@ -311,6 +307,8 @@ Schema.prototype.version; Schema.prototype.metadata; /** @type {?} */ Schema.prototype.dictionaries; +/** @type {?} */ +Schema.prototype.select; var Field = function() {}; /** @type {?} */ Field.prototype.name; diff --git a/js/src/table.ts b/js/src/table.ts index b9fdeb99c64e4..82c7ef56da6e1 100644 --- a/js/src/table.ts +++ b/js/src/table.ts @@ -296,15 +296,15 @@ export class TableToStringIterator implements IterableIterator { pipe(stream: NodeJS.WritableStream) { let res: IteratorResult; let write = () => { - if (stream.writable) { + if (stream['writable']) { do { if ((res = this.next()).done) { break; } - } while (stream.write(res.value + '\n', 'utf8')); + } while (stream['write'](res.value + '\n', 'utf8')); } if (!res || !res.done) { - stream.once('drain', write); - } else if (!(stream as any).isTTY) { - stream.end('\n'); + stream['once']('drain', write); + } else if (!(stream as any)['isTTY']) { + stream['end']('\n'); } }; write(); @@ -324,7 +324,7 @@ function* tableRowsToString(table: Table, separator = ' | ') { } } yield header.map((x, j) => leftPad(x, ' ', maxColumnWidths[j])).join(separator); - for (let i = -1, n = table.length; ++i < n;) { + for (let i = -1; ++i < table.length;) { yield [i, ...table.get(i)] .map((x) => stringify(x)) .map((x, j) => leftPad(x, ' ', maxColumnWidths[j])) diff --git a/js/test/unit/table-tests.ts b/js/test/unit/table-tests.ts index d745908a48745..d8c0b7f494fa4 100644 --- a/js/test/unit/table-tests.ts +++ b/js/test/unit/table-tests.ts @@ -268,7 +268,7 @@ const test_data = [ [Math.fround( 0.2), 1, 'b'], [Math.fround( 0.1), -1, 'c'], ]} -] +]; describe(`Table`, () => { test(`can create an empty table`, () => { @@ -313,21 +313,21 @@ describe(`Table`, () => { { name: `filter on f32 >= 0`, filtered: table.filter(col('f32').gteq(0)), - expected: values.filter((row)=>row[F32] >= 0) + expected: values.filter((row) => row[F32] >= 0) }, { name: `filter on i32 <= 0 returns the correct length`, filtered: table.filter(col('i32').lteq(0)), - expected: values.filter((row)=>row[I32] <= 0) + expected: values.filter((row) => row[I32] <= 0) }, { name: `filter method combines predicates (f32 >= 0 && i32 <= 0)`, filtered: table.filter(col('i32').lteq(0)).filter(col('f32').gteq(0)), - expected: values.filter((row)=>row[I32] <= 0 && row[F32] >= 0) + expected: values.filter((row) => row[I32] <= 0 && row[F32] >= 0) }, { name: `filter on dictionary == 'a'`, filtered: table.filter(col('dictionary').eq('a')), - expected: values.filter((row)=>row[DICT] === 'a') + expected: values.filter((row) => row[DICT] === 'a') } - ] + ]; for (let this_test of filter_tests) { describe(`filter on f32 >= 0`, () => { const filtered = this_test.filtered; @@ -341,7 +341,7 @@ describe(`Table`, () => { const columns = batch.schema.fields.map((_, i) => batch.getChildAt(i)!); expect(columns.map((c) => c.get(idx))).toEqual(expected[expected_idx++]); }); - }) + }); }); } test(`countBy on dictionary returns the correct counts`, () => { @@ -358,7 +358,7 @@ describe(`Table`, () => { test(`countBy on dictionary with filter returns the correct counts`, () => { let expected: {[key: string]: number} = {'a': 0, 'b': 0, 'c': 0}; for (let row of values) { - if(row[I32] === 1) { expected[row[DICT]] += 1; } + if (row[I32] === 1) { expected[row[DICT]] += 1; } } expect(table.filter(col('i32').eq(1)).countBy('dictionary').toJSON()).toEqual(expected); @@ -383,7 +383,7 @@ describe(`Table`, () => { }); test(`table.toString()`, () => { let selected = table.select('i32', 'dictionary'); - let headers = [`"row_id"`, `"i32: Int32"`, `"dictionary: Dictionary"`] + let headers = [`"row_id"`, `"i32: Int32"`, `"dictionary: Dictionary"`]; let expected = [headers.join(' | '), ...values.map((row, idx) => { return [`${idx}`, `${row[I32]}`, `"${row[DICT]}"`].map((str, col) => { return leftPad(str, ' ', headers[col].length);