@apache-arrow/ts
Advanced tools
Comparing version 12.0.1 to 13.0.0
@@ -45,6 +45,7 @@ // Licensed to the Apache Software Foundation (ASF) under one | ||
} else { | ||
const n = value.length; | ||
const v = value as T['TValue']; | ||
const n = v.length; | ||
const start = offsets.set(index, n).buffer[index]; | ||
for (let i = -1; ++i < n;) { | ||
child.set(start + i, value[i]); | ||
child.set(start + i, v[i]); | ||
} | ||
@@ -51,0 +52,0 @@ } |
{ | ||
"version": "12.0.1", | ||
"version": "13.0.0", | ||
"name": "@apache-arrow/ts", | ||
@@ -30,3 +30,3 @@ "browser": "Arrow.dom.ts", | ||
"dependencies": { | ||
"@types/node": "18.14.5", | ||
"@types/node": "20.3.0", | ||
"@types/command-line-args": "5.2.0", | ||
@@ -36,8 +36,8 @@ "@types/command-line-usage": "5.0.2", | ||
"command-line-args": "5.2.1", | ||
"command-line-usage": "6.1.3", | ||
"flatbuffers": "23.3.3", | ||
"command-line-usage": "7.0.1", | ||
"flatbuffers": "23.5.26", | ||
"json-bignum": "^0.0.3", | ||
"pad-left": "^2.1.0", | ||
"tslib": "^2.5.0" | ||
"tslib": "^2.5.3" | ||
} | ||
} |
@@ -94,3 +94,3 @@ // Licensed to the Apache Software Foundation (ASF) under one | ||
if (args[args.length - 1] instanceof Uint32Array) { | ||
if (args.at(-1) instanceof Uint32Array) { | ||
offsets = args.pop(); | ||
@@ -97,0 +97,0 @@ } |
@@ -23,3 +23,2 @@ // Licensed to the Apache Software Foundation (ASF) under one | ||
import { TypedArrayConstructor } from './interfaces.js'; | ||
import { BigInt64Array, BigUint64Array } from './util/compat.js'; | ||
import { bigIntToNumber } from './util/bigint.js'; | ||
@@ -26,0 +25,0 @@ |
@@ -21,3 +21,2 @@ // Licensed to the Apache Software Foundation (ASF) under one | ||
import { BigIntArray, BigIntArrayConstructor } from '../interfaces.js'; | ||
import { BigInt64Array, BigUint64Array } from './compat.js'; | ||
@@ -40,13 +39,13 @@ /** @ignore */ | ||
BigNum.prototype[isArrowBigNumSymbol] = true; | ||
BigNum.prototype.toJSON = function <T extends BN<BigNumArray>>(this: T) { return `"${bignumToString(this)}"`; }; | ||
BigNum.prototype.valueOf = function <T extends BN<BigNumArray>>(this: T) { return bignumToNumber(this); }; | ||
BigNum.prototype.toString = function <T extends BN<BigNumArray>>(this: T) { return bignumToString(this); }; | ||
BigNum.prototype.toJSON = function <T extends BN<BigNumArray>>(this: T) { return `"${bigNumToString(this)}"`; }; | ||
BigNum.prototype.valueOf = function <T extends BN<BigNumArray>>(this: T) { return bigNumToNumber(this); }; | ||
BigNum.prototype.toString = function <T extends BN<BigNumArray>>(this: T) { return bigNumToString(this); }; | ||
BigNum.prototype[Symbol.toPrimitive] = function <T extends BN<BigNumArray>>(this: T, hint: 'string' | 'number' | 'default' = 'default') { | ||
switch (hint) { | ||
case 'number': return bignumToNumber(this); | ||
case 'string': return bignumToString(this); | ||
case 'default': return bignumToBigInt(this); | ||
case 'number': return bigNumToNumber(this); | ||
case 'string': return bigNumToString(this); | ||
case 'default': return bigNumToBigInt(this); | ||
} | ||
// @ts-ignore | ||
return bignumToString(this); | ||
return bigNumToString(this); | ||
}; | ||
@@ -75,6 +74,6 @@ | ||
/** @ignore */ | ||
function bignumToNumber<T extends BN<BigNumArray>>(bn: T) { | ||
function bigNumToNumber<T extends BN<BigNumArray>>(bn: T) { | ||
const { buffer, byteOffset, length, 'signed': signed } = bn; | ||
const words = new BigUint64Array(buffer, byteOffset, length); | ||
const negative = signed && words[words.length - 1] & (BigInt(1) << BigInt(63)); | ||
const negative = signed && words.at(-1)! & (BigInt(1) << BigInt(63)); | ||
let number = negative ? BigInt(1) : BigInt(0); | ||
@@ -96,8 +95,48 @@ let i = BigInt(0); | ||
/** @ignore */ | ||
export const bignumToString: { <T extends BN<BigNumArray>>(a: T): string } = (<T extends BN<BigNumArray>>(a: T) => a.byteLength === 8 ? `${new a['BigIntArray'](a.buffer, a.byteOffset, 1)[0]}` : decimalToString(a)); | ||
export const bigNumToString: { <T extends BN<BigNumArray>>(a: T): string } = (<T extends BN<BigNumArray>>(a: T) => { | ||
// use BigInt native implementation | ||
if (a.byteLength === 8) { | ||
const bigIntArray = new a['BigIntArray'](a.buffer, a.byteOffset, 1); | ||
return `${bigIntArray[0]}`; | ||
} | ||
// unsigned numbers | ||
if (!a['signed']) { | ||
return unsignedBigNumToString(a); | ||
} | ||
let array = new Uint16Array(a.buffer, a.byteOffset, a.byteLength / 2); | ||
// detect positive numbers | ||
const highOrderWord = new Int16Array([array.at(-1)!])[0]; | ||
if (highOrderWord >= 0) { | ||
return unsignedBigNumToString(a); | ||
} | ||
// flip the negative value | ||
array = array.slice(); | ||
let carry = 1; | ||
for (let i = 0; i < array.length; i++) { | ||
const elem = array[i]; | ||
const updated = ~elem + carry; | ||
array[i] = updated; | ||
carry &= elem === 0 ? 1 : 0; | ||
} | ||
const negated = unsignedBigNumToString(<any>array); | ||
return `-${negated}`; | ||
}); | ||
/** @ignore */ | ||
export const bignumToBigInt: { <T extends BN<BigNumArray>>(a: T): bigint } = (<T extends BN<BigNumArray>>(a: T) => a.byteLength === 8 ? new a['BigIntArray'](a.buffer, a.byteOffset, 1)[0] : <any>decimalToString(a)); | ||
export const bigNumToBigInt: { <T extends BN<BigNumArray>>(a: T): bigint } = (<T extends BN<BigNumArray>>(a: T) => { | ||
if (a.byteLength === 8) { | ||
const bigIntArray = new a['BigIntArray'](a.buffer, a.byteOffset, 1); | ||
return bigIntArray[0]; | ||
} else { | ||
return <any>bigNumToString(a); | ||
} | ||
}); | ||
/** @ignore */ | ||
function decimalToString<T extends BN<BigNumArray>>(a: T) { | ||
function unsignedBigNumToString<T extends BN<BigNumArray>>(a: T) { | ||
let digits = ''; | ||
@@ -104,0 +143,0 @@ const base64 = new Uint32Array(2); |
@@ -20,3 +20,3 @@ // Licensed to the Apache Software Foundation (ASF) under one | ||
import { TypedArray, TypedArrayConstructor, BigIntArrayConstructor } from '../interfaces.js'; | ||
import { isPromise, isIterable, isAsyncIterable, isIteratorResult, isFlatbuffersByteBuffer, BigInt64Array, BigUint64Array } from './compat.js'; | ||
import { isPromise, isIterable, isAsyncIterable, isIteratorResult, isFlatbuffersByteBuffer } from './compat.js'; | ||
import { ByteBuffer } from 'flatbuffers'; | ||
@@ -67,3 +67,3 @@ | ||
const byteLength = result.reduce((x, b) => x + b.byteLength, 0); | ||
let source: Uint8Array, sliced: Uint8Array, buffer: Uint8Array | void; | ||
let source: Uint8Array, sliced: Uint8Array, buffer: Uint8Array | undefined; | ||
let offset = 0, index = -1; | ||
@@ -70,0 +70,0 @@ const length = Math.min(size || Number.POSITIVE_INFINITY, byteLength); |
@@ -45,29 +45,2 @@ // Licensed to the Apache Software Foundation (ASF) under one | ||
/** @ignore */ | ||
const [BigInt64ArrayCtor, BigInt64ArrayAvailable] = (() => { | ||
const BigInt64ArrayUnavailableError = () => { throw new Error('BigInt64Array is not available in this environment'); }; | ||
class BigInt64ArrayUnavailable { | ||
static get BYTES_PER_ELEMENT() { return 8; } | ||
static of() { throw BigInt64ArrayUnavailableError(); } | ||
static from() { throw BigInt64ArrayUnavailableError(); } | ||
constructor() { throw BigInt64ArrayUnavailableError(); } | ||
} | ||
return typeof BigInt64Array !== 'undefined' ? [BigInt64Array, true] : [<any>BigInt64ArrayUnavailable, false]; | ||
})() as [BigInt64ArrayConstructor, boolean]; | ||
/** @ignore */ | ||
const [BigUint64ArrayCtor, BigUint64ArrayAvailable] = (() => { | ||
const BigUint64ArrayUnavailableError = () => { throw new Error('BigUint64Array is not available in this environment'); }; | ||
class BigUint64ArrayUnavailable { | ||
static get BYTES_PER_ELEMENT() { return 8; } | ||
static of() { throw BigUint64ArrayUnavailableError(); } | ||
static from() { throw BigUint64ArrayUnavailableError(); } | ||
constructor() { throw BigUint64ArrayUnavailableError(); } | ||
} | ||
return typeof BigUint64Array !== 'undefined' ? [BigUint64Array, true] : [<any>BigUint64ArrayUnavailable, false]; | ||
})() as [BigUint64ArrayConstructor, boolean]; | ||
export { BigInt64ArrayCtor as BigInt64Array, BigInt64ArrayAvailable }; | ||
export { BigUint64ArrayCtor as BigUint64Array, BigUint64ArrayAvailable }; | ||
/** @ignore */ const isNumber = (x: any) => typeof x === 'number'; | ||
@@ -74,0 +47,0 @@ /** @ignore */ const isBoolean = (x: any) => typeof x === 'boolean'; |
@@ -18,4 +18,2 @@ // Licensed to the Apache Software Foundation (ASF) under one | ||
import { BigInt64Array, BigUint64Array } from './compat.js'; | ||
/** @ignore */ const undf = void (0); | ||
@@ -22,0 +20,0 @@ |
@@ -33,3 +33,2 @@ // Licensed to the Apache Software Foundation (ASF) under one | ||
} from './util/chunk.js'; | ||
import { BigInt64Array, BigUint64Array } from './util/compat.js'; | ||
@@ -100,3 +99,3 @@ import { instance as getVisitor } from './visitor/get.js'; | ||
this.numChildren = type.children?.length ?? 0; | ||
this.length = this._offsets[this._offsets.length - 1]; | ||
this.length = this._offsets.at(-1)!; | ||
} | ||
@@ -154,3 +153,3 @@ | ||
/** | ||
* The Array or TypedAray constructor used for the JS representation | ||
* The Array or TypedArray constructor used for the JS representation | ||
* of the element's values in {@link Vector.prototype.toArray `toArray()`}. | ||
@@ -157,0 +156,0 @@ */ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16278
885207
+ Added@75lb/deep-merge@1.1.2(transitive)
+ Added@types/node@20.3.0(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedarray-back@6.2.2(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchalk-template@0.4.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommand-line-usage@7.0.1(transitive)
+ Addedflatbuffers@23.5.26(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedstream-read-all@3.0.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtable-layout@3.0.2(transitive)
+ Addedtypical@7.3.0(transitive)
+ Addedwordwrapjs@5.1.0(transitive)
- Removed@types/node@18.14.5(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedarray-back@4.0.2(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcommand-line-usage@6.1.3(transitive)
- Removeddeep-extend@0.6.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedflatbuffers@23.3.3(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedreduce-flatten@2.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtable-layout@1.0.2(transitive)
- Removedtypical@5.2.0(transitive)
- Removedwordwrapjs@4.0.1(transitive)
Updated@types/node@20.3.0
Updatedcommand-line-usage@7.0.1
Updatedflatbuffers@23.5.26
Updatedtslib@^2.5.3