mirror of
https://github.com/asadbek064/hyparquet.git
synced 2025-12-05 22:41:55 +00:00
Use bigint literals
This commit is contained in:
parent
3c5dbab649
commit
5675560266
12
package.json
12
package.json
@ -32,13 +32,13 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "22.10.7",
|
||||
"@vitest/coverage-v8": "3.0.1",
|
||||
"eslint": "9.18.0",
|
||||
"eslint-plugin-jsdoc": "50.6.1",
|
||||
"@types/node": "22.13.1",
|
||||
"@vitest/coverage-v8": "3.0.5",
|
||||
"eslint": "9.20.0",
|
||||
"eslint-plugin-jsdoc": "50.6.3",
|
||||
"hyparquet-compressors": "1.0.0",
|
||||
"typescript": "5.7.3",
|
||||
"typescript-eslint": "8.20.0",
|
||||
"vitest": "3.0.1"
|
||||
"typescript-eslint": "8.23.0",
|
||||
"vitest": "3.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,14 +51,14 @@ describe('convert function', () => {
|
||||
})
|
||||
|
||||
it('converts bigint to DECIMAL', () => {
|
||||
const data = [BigInt(1000), BigInt(2000)]
|
||||
const data = [1000n, 2000n]
|
||||
/** @type {SchemaElement} */
|
||||
const schemaElement = { name, converted_type: 'DECIMAL' }
|
||||
expect(convert(data, schemaElement)).toEqual([1000, 2000])
|
||||
})
|
||||
|
||||
it('converts bigint to DECIMAL with scale', () => {
|
||||
const data = [BigInt(10), BigInt(20)]
|
||||
const data = [10n, 20n]
|
||||
/** @type {SchemaElement} */
|
||||
const schemaElement = { name, converted_type: 'DECIMAL', scale: 2 }
|
||||
expect(convert(data, schemaElement)).toEqual([0.1, 0.2])
|
||||
@ -114,7 +114,7 @@ describe('convert function', () => {
|
||||
})
|
||||
|
||||
it('converts uint64', () => {
|
||||
const data = [BigInt(100), BigInt(-100)]
|
||||
const data = [100n, -100n]
|
||||
/** @type {SchemaElement} */
|
||||
const schemaElement = { name, converted_type: 'UINT_64' }
|
||||
expect(convert(data, schemaElement)).toEqual(new BigUint64Array([100n, 18446744073709551516n]))
|
||||
|
||||
@ -39,7 +39,7 @@ describe('readPlain', () => {
|
||||
|
||||
it('reads INT64 values', () => {
|
||||
const view = new DataView(new ArrayBuffer(8))
|
||||
view.setBigInt64(0, BigInt('1234567890123456789'), true)
|
||||
view.setBigInt64(0, 1234567890123456789n, true)
|
||||
const reader = { view, offset: 0 }
|
||||
const result = readPlain(reader, 'INT64', 1, undefined)
|
||||
expect(result).toEqual(new BigInt64Array([1234567890123456789n]))
|
||||
@ -48,7 +48,7 @@ describe('readPlain', () => {
|
||||
|
||||
it('reads unaligned INT64 values', () => {
|
||||
const view = new DataView(new ArrayBuffer(9))
|
||||
view.setBigInt64(1, BigInt('1234567890123456789'), true)
|
||||
view.setBigInt64(1, 1234567890123456789n, true)
|
||||
const reader = { view, offset: 1 }
|
||||
const result = readPlain(reader, 'INT64', 1, undefined)
|
||||
expect(result).toEqual(new BigInt64Array([1234567890123456789n]))
|
||||
|
||||
@ -8,9 +8,9 @@ describe('toJson', () => {
|
||||
})
|
||||
|
||||
it('convert bigint to number', () => {
|
||||
expect(toJson(BigInt(123))).toBe(123)
|
||||
expect(toJson([BigInt(123), BigInt(456)])).toEqual([123, 456])
|
||||
expect(toJson({ a: BigInt(123), b: { c: BigInt(456) } })).toEqual({ a: 123, b: { c: 456 } })
|
||||
expect(toJson(123n)).toBe(123)
|
||||
expect(toJson([123n, 456n])).toEqual([123, 456])
|
||||
expect(toJson({ a: 123n, b: { c: 456n } })).toEqual({ a: 123, b: { c: 456 } })
|
||||
})
|
||||
|
||||
it('convert Uint8Array to array of numbers', () => {
|
||||
@ -23,7 +23,7 @@ describe('toJson', () => {
|
||||
})
|
||||
|
||||
it('ignore undefined properties in objects', () => {
|
||||
expect(toJson({ a: undefined, b: BigInt(123) })).toEqual({ b: 123 })
|
||||
expect(toJson({ a: undefined, b: 123n })).toEqual({ b: 123 })
|
||||
})
|
||||
|
||||
it('return null in objects unchanged', () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user