Skip to content

Commit 911581f

Browse files
committed
fix typings
1 parent 16b7937 commit 911581f

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

src/lib/Shapefile/Shapefile.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DbaseVersion, ShapePolygon } from '../../types'
44
import Shapefile from './Shapefile'
55

66
const testsDir = resolve(__dirname, '../../../tests')
7-
const USA_adm = readFileSync(join(testsDir, 'USA_adm.zip'))
7+
const USA_adm = new Uint8Array(readFileSync(join(testsDir, 'USA_adm.zip')))
88

99
describe('Shapefile', () => {
1010
describe('USA_adm', () => {

src/lib/Shapefile/Shapefile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import JSZip from 'jszip'
2-
import {
2+
import type {
33
Dbase,
44
DbaseVersion,
55
Shape,
66
ShapeIndex
77
} from '../../types'
88
import * as parsers from './parsers'
9-
import { DbfOptions } from './parsers/dbf'
10-
import { ShapefileContents } from './Shapefile.types'
9+
import type { DbfOptions } from './parsers/dbf'
10+
import type { ShapefileContents } from './Shapefile.types'
1111

1212
type JSZipLoadAsyncParamters = Parameters<typeof JSZip.loadAsync>
1313

src/lib/Shapefile/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { default } from './Shapefile'
2-
export * from './Shapefile.types'
2+
export type * from './Shapefile.types'

src/lib/Shapefile/parsers/dbf.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface DbfOptions {
99
properties: boolean
1010
}
1111

12-
function dbf(arrayBuffer: ArrayBuffer, options: DbfOptions): Dbase<DbaseVersion, typeof options.properties> {
12+
function dbf(arrayBuffer: ArrayBufferLike, options: DbfOptions): Dbase<DbaseVersion, typeof options.properties> {
1313
const array = new Uint8Array(arrayBuffer)
1414
const dv = new DataView(arrayBuffer)
1515

@@ -111,7 +111,7 @@ function getFields(array: Uint8Array, header: DbaseHeader<DbaseVersion>, options
111111
return fields
112112
}
113113

114-
function getField(arrayBuffer: ArrayBuffer, version: DbaseVersion, properties: boolean): DbaseField<typeof version, typeof properties> {
114+
function getField(arrayBuffer: Uint8Array, version: DbaseVersion, properties: boolean): DbaseField<typeof version, typeof properties> {
115115
const array = new Uint8Array(arrayBuffer)
116116

117117
switch (version) {

src/lib/Shapefile/parsers/shp.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import {
1313
ShapeType
1414
} from '../../../types'
1515

16-
function shp(arrayBuffer: ArrayBuffer): Shape {
16+
function shp(arrayBuffer: ArrayBufferLike): Shape {
1717
return {
1818
header: getHeader(arrayBuffer.slice(0, 100)),
1919
records: getRecords(arrayBuffer.slice(100, arrayBuffer.byteLength))
2020
}
2121
}
2222

23-
function getHeader(arrayBuffer: ArrayBuffer): ShapeHeader {
23+
function getHeader(arrayBuffer: ArrayBufferLike): ShapeHeader {
2424
const dv = new DataView(arrayBuffer)
2525
return {
2626
file: {
@@ -44,7 +44,7 @@ function getHeader(arrayBuffer: ArrayBuffer): ShapeHeader {
4444
}
4545
}
4646

47-
function getRecords(arrayBuffer: ArrayBuffer): Array<ShapeRecord<ShapeType>> {
47+
function getRecords(arrayBuffer: ArrayBufferLike): Array<ShapeRecord<ShapeType>> {
4848
const dv = new DataView(arrayBuffer)
4949

5050
let bp = 0
@@ -159,7 +159,7 @@ function getRecords(arrayBuffer: ArrayBuffer): Array<ShapeRecord<ShapeType>> {
159159
return records
160160
}
161161

162-
function getBoundingBox(arrayBuffer: ArrayBuffer): ShapeBoundingBox {
162+
function getBoundingBox(arrayBuffer: ArrayBufferLike): ShapeBoundingBox {
163163
const dv = new DataView(arrayBuffer)
164164
return {
165165
minX: dv.getFloat64(0, true),
@@ -169,11 +169,11 @@ function getBoundingBox(arrayBuffer: ArrayBuffer): ShapeBoundingBox {
169169
}
170170
}
171171

172-
function getPoint(arrayBuffer: ArrayBuffer): ShapePoint
173-
function getPoint(arrayBuffer: ArrayBuffer, type: undefined): ShapePoint
174-
function getPoint(arrayBuffer: ArrayBuffer, type: 'M'): ShapePointZ
175-
function getPoint(arrayBuffer: ArrayBuffer, type: 'Z'): ShapePointZ
176-
function getPoint(arrayBuffer: ArrayBuffer, type?: 'M' | 'Z'): ShapePoint | ShapePointZ {
172+
function getPoint(arrayBuffer: ArrayBufferLike): ShapePoint
173+
function getPoint(arrayBuffer: ArrayBufferLike, type: undefined): ShapePoint
174+
function getPoint(arrayBuffer: ArrayBufferLike, type: 'M'): ShapePointZ
175+
function getPoint(arrayBuffer: ArrayBufferLike, type: 'Z'): ShapePointZ
176+
function getPoint(arrayBuffer: ArrayBufferLike, type?: 'M' | 'Z'): ShapePoint | ShapePointZ {
177177
const dv = new DataView(arrayBuffer)
178178
return {
179179
x: dv.getFloat64(0, true),

src/lib/Shapefile/parsers/shx.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
ShapeIndexRecord
55
} from '../../../types'
66

7-
function shx(buffer: ArrayBuffer): ShapeIndex {
7+
function shx(buffer: ArrayBufferLike): ShapeIndex {
88
const header = getHeader(buffer.slice(0, 100))
99
const records = getRecords(buffer.slice(100, buffer.byteLength))
1010

@@ -14,7 +14,7 @@ function shx(buffer: ArrayBuffer): ShapeIndex {
1414
}
1515
}
1616

17-
function getHeader(arrayBuffer: ArrayBuffer): ShapeHeader {
17+
function getHeader(arrayBuffer: ArrayBufferLike): ShapeHeader {
1818
const dv = new DataView(arrayBuffer)
1919
return {
2020
file: {
@@ -38,7 +38,7 @@ function getHeader(arrayBuffer: ArrayBuffer): ShapeHeader {
3838
}
3939
}
4040

41-
function getRecords(arrayBuffer: ArrayBuffer): ShapeIndexRecord[] {
41+
function getRecords(arrayBuffer: ArrayBufferLike): ShapeIndexRecord[] {
4242
const dv = new DataView(arrayBuffer)
4343

4444
let bp = 0

0 commit comments

Comments
 (0)