diff --git a/js/package-lock.json b/js/package-lock.json index bf0c1e7fa4916..153fbfd7b2aaa 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -13425,7 +13425,7 @@ "progress": "^2.0.3", "shelljs": "^0.8.3", "typedoc-default-themes": "^0.6.0-0", - "typescript": "3.4.x" + "typescript": "3.5.x" }, "dependencies": { "handlebars": { @@ -13447,9 +13447,9 @@ "dev": true }, "typescript": { - "version": "3.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz", - "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", + "integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==", "dev": true } } diff --git a/js/src/builder/buffer.ts b/js/src/builder/buffer.ts index 41f5c7055ad78..7aa336a2a8036 100644 --- a/js/src/builder/buffer.ts +++ b/js/src/builder/buffer.ts @@ -16,13 +16,12 @@ // under the License. import { memcpy } from '../util/buffer'; -import { BigInt64Array, BigUint64Array } from '../util/compat'; +import { BigIntAvailable, BigInt64Array, BigUint64Array } from '../util/compat'; import { TypedArray, TypedArrayConstructor, BigIntArray, BigIntArrayConstructor } from '../interfaces'; -/** @ignore */ type WideArray = T extends BigIntArray ? Int32Array : Uint32Array; /** @ignore */ type DataValue = T extends TypedArray ? number : T extends BigIntArray ? WideValue : T; /** @ignore */ type WideValue = T extends BigIntArray ? bigint | Int32Array | Uint32Array : never; /** @ignore */ type ArrayCtor = @@ -157,16 +156,13 @@ export class OffsetsBufferBuilder extends DataBufferBuilder { } /** @ignore */ -export class WideBufferBuilder extends BufferBuilder, DataValue> { +export class WideBufferBuilder extends BufferBuilder> { // @ts-ignore - public buffer64: T; + public buffer64: R; // @ts-ignore - constructor(buffer: T, stride: number) { - const ArrayType = buffer instanceof BigInt64Array ? Int32Array : Uint32Array; - super(new ArrayType(buffer.buffer, buffer.byteOffset, buffer.byteLength / 4) as WideArray, stride); - } - public get ArrayType64(): BigIntArrayConstructor { - return this.buffer instanceof Int32Array ? BigInt64Array : BigUint64Array as any; + protected _ArrayType64: BigIntArrayConstructor; + public get ArrayType64() { + return this._ArrayType64 || (this._ArrayType64 = > (this.buffer instanceof Int32Array ? BigInt64Array : BigUint64Array)); } public set(index: number, value: DataValue) { this.reserve(index - this.length + 1); @@ -180,7 +176,9 @@ export class WideBufferBuilder extends BufferBuilder extends IntBuilder {} export class Int32Builder extends IntBuilder {} /** @ignore */ export class Int64Builder extends IntBuilder { + protected _values: WideBufferBuilder; constructor(options: BuilderOptions) { if (options['nullValues']) { options['nullValues'] = (options['nullValues'] as TNull[]).map(toBigInt); } super(options); - if (BigInt64ArrayAvailable) { - this._values = new WideBufferBuilder(new BigInt64Array(0), 2); - } + this._values = new WideBufferBuilder(new Int32Array(0), 2); } - public get values64() { return (this._values as any).buffer64 as BigInt64Array; } + public get values64() { return this._values.buffer64; } public isValid(value: Int32Array | bigint | TNull) { return super.isValid(toBigInt(value)); } } @@ -58,16 +56,15 @@ export class Uint16Builder extends IntBuilder {} export class Uint32Builder extends IntBuilder {} /** @ignore */ export class Uint64Builder extends IntBuilder { + protected _values: WideBufferBuilder; constructor(options: BuilderOptions) { if (options['nullValues']) { options['nullValues'] = (options['nullValues'] as TNull[]).map(toBigInt); } super(options); - if (BigUint64ArrayAvailable) { - this._values = new WideBufferBuilder(new BigUint64Array(0), 2); - } + this._values = new WideBufferBuilder(new Uint32Array(0), 2); } - public get values64() { return (this._values as any).buffer64 as BigUint64Array; } + public get values64() { return this._values.buffer64; } public isValid(value: Uint32Array | bigint | TNull) { return super.isValid(toBigInt(value)); } }