Skip to content

Commit 8765bef

Browse files
authored
Merge pull request #140 from matthewdowns/release/v1.1.1
1.1.1
2 parents bc589c4 + 835bda7 commit 8765bef

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "shapefile.js",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Easily read and parse Shapefiles from the browser.",
55
"keywords": [
66
"shapefiles",

src/lib/Shapefile/Shapefile.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ describe('Shapefile', () => {
7979
})
8080

8181
test('dbf', () => {
82-
const dbf = USA_adm1.parse('dbf', { timezone: 'Europe/Oslo', properties: true })
82+
const dbf = USA_adm1.parse('dbf', { properties: true })
8383
expect(dbf.header.version).toBe(DbaseVersion.Level5) // 3
84-
console.log(dbf.header.lastUpdated)
8584
expect(dbf.header.lastUpdated.toISOString()).toBe('2015-08-11T00:00:00.000Z')
8685
expect(dbf.header.numberOfRecords).toBe(52)
8786
expect(dbf.header.numberOfBytesInHeader).toBe(321)

src/lib/Shapefile/Shapefile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class Shapefile {
1919
this.contents = contents
2020
}
2121

22-
public parse(key: 'shp'): Shape;
23-
public parse(key: 'shx'): ShapeIndex;
24-
public parse(key: 'dbf', options: DbfOptions): Dbase<DbaseVersion, typeof options.properties>;
22+
public parse(key: 'shp'): Shape
23+
public parse(key: 'shx'): ShapeIndex
24+
public parse(key: 'dbf', options: DbfOptions): Dbase<DbaseVersion, typeof options.properties>
2525
public parse(key: keyof ShapefileContents, ...args: any) {
2626
switch (key) {
2727
case 'shp':

src/lib/Shapefile/parsers/dbf.ts

Lines changed: 6 additions & 6 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, properties = true): Dbase<DbaseVersion, typeof properties> {
12+
function dbf(arrayBuffer: ArrayBuffer, options: DbfOptions): Dbase<DbaseVersion, typeof options.properties> {
1313
const array = new Uint8Array(arrayBuffer)
1414
const dv = new DataView(arrayBuffer)
1515

@@ -43,15 +43,15 @@ function dbf(arrayBuffer: ArrayBuffer, properties = true): Dbase<DbaseVersion, t
4343
: 68,
4444
arrayBuffer.byteLength)),
4545
header,
46-
properties)
46+
options)
4747

4848
return {
4949
header,
5050
fields
5151
}
5252
}
5353

54-
function getFields(array: Uint8Array, header: DbaseHeader<DbaseVersion>, properties: boolean): Array<DbaseField<typeof header.version, typeof properties>> {
54+
function getFields(array: Uint8Array, header: DbaseHeader<DbaseVersion>, options: DbfOptions): Array<DbaseField<typeof header.version, typeof options.properties>> {
5555
let size: number
5656
switch (header.version) {
5757
case DbaseVersion.Level5:
@@ -62,20 +62,20 @@ function getFields(array: Uint8Array, header: DbaseHeader<DbaseVersion>, propert
6262
break
6363
}
6464

65-
const fields: Array<DbaseField<typeof header.version, typeof properties>> = []
65+
const fields: Array<DbaseField<typeof header.version, typeof options.properties>> = []
6666
let bp = 0
6767
let terminated = false
6868
do {
6969
const terminator = array[bp]
7070
if (terminator === 0x0D) terminated = true
7171
else {
72-
fields.push(getField(array.slice(bp, bp + size), header.version, properties))
72+
fields.push(getField(array.slice(bp, bp + size), header.version, options.properties))
7373
bp += size
7474
}
7575
} while (!terminated)
7676
bp += 1
7777

78-
if (properties === true) {
78+
if (options.properties === true) {
7979
do {
8080
for (let i = 0; i < fields.length; i++) {
8181
const valueRaw = Buffer.from(array.slice(bp, bp + fields[i].length)).toString('utf-8').trim()

0 commit comments

Comments
 (0)