fast-osmpbf-js 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,104 +1,104 @@
1
- import { createRequire } from "module"
2
- import { platform, arch } from "process"
3
- import { join, dirname } from "path"
4
- import { fileURLToPath } from "url"
1
+ import { createRequire } from "module";
2
+ import { platform, arch } from "process";
3
+ import { join, dirname } from "path";
4
+ import { fileURLToPath } from "url";
5
5
 
6
- const require = createRequire(import.meta.url)
7
- const __dirname = dirname(fileURLToPath(import.meta.url))
6
+ const require = createRequire(import.meta.url);
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
8
 
9
9
  // Map Node.js platform/arch to your binding folder names
10
10
  function getBindingPath() {
11
- const platformMap = {
12
- darwin: "apple-darwin",
13
- win32: "pc-windows-msvc",
14
- linux: "unknown-linux-gnu",
15
- }
11
+ const platformMap = {
12
+ darwin: "apple-darwin",
13
+ win32: "pc-windows-msvc",
14
+ linux: "unknown-linux-gnu",
15
+ };
16
16
 
17
- const archMap = {
18
- x64: "x86_64",
19
- arm64: "aarch64",
20
- }
17
+ const archMap = {
18
+ x64: "x86_64",
19
+ arm64: "aarch64",
20
+ };
21
21
 
22
- const nodeFileMap = {
23
- "linux-x64": "index.linux-x64-gnu.node",
24
- "linux-arm64": "index.linux-arm64-gnu.node",
25
- "darwin-x64": "index.darwin-x64.node",
26
- "darwin-arm64": "index.darwin-arm64.node",
27
- "win32-x64": "index.win32-x64-msvc.node",
28
- }
22
+ const nodeFileMap = {
23
+ "linux-x64": "index.linux-x64-gnu.node",
24
+ "linux-arm64": "index.linux-arm64-gnu.node",
25
+ "darwin-x64": "index.darwin-x64.node",
26
+ "darwin-arm64": "index.darwin-arm64.node",
27
+ "win32-x64": "index.win32-x64-msvc.node",
28
+ };
29
29
 
30
- const mappedPlatform = platformMap[platform]
31
- const mappedArch = archMap[arch]
30
+ const mappedPlatform = platformMap[platform];
31
+ const mappedArch = archMap[arch];
32
32
 
33
- if (!mappedPlatform || !mappedArch) {
34
- throw new Error(`Unsupported platform: ${platform}-${arch}`)
35
- }
33
+ if (!mappedPlatform || !mappedArch) {
34
+ throw new Error(`Unsupported platform: ${platform}-${arch}`);
35
+ }
36
36
 
37
- const bindingFolder = `bindings-${mappedArch}-${mappedPlatform}`
38
- const nodeFile = nodeFileMap[`${platform}-${arch}`]
37
+ const bindingFolder = `bindings-${mappedArch}-${mappedPlatform}`;
38
+ const nodeFile = nodeFileMap[`${platform}-${arch}`];
39
39
 
40
- if (!nodeFile) {
41
- throw new Error(`No binding available for ${platform}-${arch}`)
42
- }
40
+ if (!nodeFile) {
41
+ throw new Error(`No binding available for ${platform}-${arch}`);
42
+ }
43
43
 
44
- return join(__dirname, bindingFolder, nodeFile)
44
+ return join(__dirname, bindingFolder, nodeFile);
45
45
  }
46
46
 
47
- const native = require(getBindingPath())
47
+ const native = require(getBindingPath());
48
48
 
49
49
  export function getTags(block, index) {
50
- let tags = block.denseTags || block.tags
51
- const start = tags[2][index]
52
- const end = tags[2][index + 1]
53
- const result = []
54
- for (let i = start; i < end; i++) {
55
- result.push([block.stringTable[tags[0][i]], block.stringTable[tags[1][i]]])
56
- }
57
- return result
50
+ let tags = block.denseTags || block.tags;
51
+ const start = tags[2][index];
52
+ const end = tags[2][index + 1];
53
+ const result = [];
54
+ for (let i = start; i < end; i++) {
55
+ result.push([block.stringTable[tags[0][i]], block.stringTable[tags[1][i]]]);
56
+ }
57
+ return result;
58
58
  }
59
59
 
60
60
  export function getNodeIds(block, index) {
61
- if (!block.nodeIds) {
62
- return []
63
- }
64
- const result = []
65
- const start = block.nodeIds[1][index]
66
- const end = block.nodeIds[1][index + 1]
67
- for (let i = start; i < end; i++) {
68
- result.push(block.nodeIds[0][i])
69
- }
70
- return result
61
+ if (!block.nodeIds) {
62
+ return [];
63
+ }
64
+ const result = [];
65
+ const start = block.nodeIds[1][index];
66
+ const end = block.nodeIds[1][index + 1];
67
+ for (let i = start; i < end; i++) {
68
+ result.push(block.nodeIds[0][i]);
69
+ }
70
+ return result;
71
71
  }
72
72
 
73
73
  export function getRelationMembers(block, index) {
74
- if (!block.relationMembers) {
75
- return []
76
- }
77
- const result = []
78
- const start = block.relationMembers[3][index]
79
- const end = block.relationMembers[3][index + 1]
80
- for (let i = start; i < end; i++) {
81
- result.push({
82
- id: block.relationMembers[0][i],
83
- type: mapMemberType(block.relationMembers[1][i]),
84
- role: block.stringTable[block.relationMembers[2][i]],
85
- })
86
- }
87
- return result
74
+ if (!block.relationMembers) {
75
+ return [];
76
+ }
77
+ const result = [];
78
+ const start = block.relationMembers[3][index];
79
+ const end = block.relationMembers[3][index + 1];
80
+ for (let i = start; i < end; i++) {
81
+ result.push({
82
+ id: block.relationMembers[0][i],
83
+ type: mapMemberType(block.relationMembers[1][i]),
84
+ role: block.stringTable[block.relationMembers[2][i]],
85
+ });
86
+ }
87
+ return result;
88
88
  }
89
89
 
90
90
  function mapMemberType(memberType) {
91
- switch (memberType) {
92
- case 0:
93
- return "Node"
94
- case 1:
95
- return "Way"
96
- case 2:
97
- return "Relation"
98
- }
91
+ switch (memberType) {
92
+ case 0:
93
+ return "Node";
94
+ case 1:
95
+ return "Way";
96
+ case 2:
97
+ return "Relation";
98
+ }
99
99
  }
100
100
 
101
101
  // Re-export the NAPI exports
102
- export const OsmReader = native.OsmReader
103
- export const AsyncBlockIterator = native.AsyncBlockIterator
104
- export const JsElementBlock = native.JsElementBlock
102
+ export const OsmReader = native.OsmReader;
103
+ export const AsyncBlockIterator = native.AsyncBlockIterator;
104
+ export const JsElementBlock = native.JsElementBlock;
package/package.json CHANGED
@@ -1,34 +1,44 @@
1
1
  {
2
- "name": "fast-osmpbf-js",
3
- "type": "module",
4
- "version": "0.2.0",
5
- "description": "Node.js bindings for the fast-osmpbf Rust library",
6
- "author": {
7
- "name": "Daniel Steblin",
8
- "email": "d.steblin.dev@gmail.com"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/QuodEstDubitandum/fast-osmpbf"
13
- },
14
- "main": "index.js",
15
- "types": "wrapper.d.ts",
16
- "files": [
17
- "index.js",
18
- "wrapper.d.ts",
19
- "index.d.ts",
20
- "bindings-*/*.node"
21
- ],
22
- "scripts": {
23
- "artifacts": "napi artifacts",
24
- "build": "napi build --platform --release"
25
- },
26
- "license": "MIT OR Apache-2.0",
27
- "devDependencies": {
28
- "@napi-rs/cli": "^3.4.1",
29
- "@types/node": "^24.3.0"
30
- },
31
- "engines": {
32
- "node": ">=16"
33
- }
2
+ "name": "fast-osmpbf-js",
3
+ "type": "module",
4
+ "version": "0.2.2",
5
+ "description": "Node.js bindings for the fast-osmpbf Rust library",
6
+ "author": {
7
+ "name": "Daniel Steblin",
8
+ "email": "d.steblin.dev@gmail.com"
9
+ },
10
+ "keywords": [
11
+ "openstreetmap",
12
+ "osmpbf",
13
+ "osm",
14
+ "pbf",
15
+ "parser",
16
+ "geospatial",
17
+ "map",
18
+ "geodata"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/QuodEstDubitandum/fast-osmpbf"
23
+ },
24
+ "main": "index.js",
25
+ "types": "wrapper.d.ts",
26
+ "files": [
27
+ "index.js",
28
+ "wrapper.d.ts",
29
+ "index.d.ts",
30
+ "bindings-*/*.node"
31
+ ],
32
+ "scripts": {
33
+ "artifacts": "napi artifacts",
34
+ "build": "napi build --platform --release"
35
+ },
36
+ "license": "MIT OR Apache-2.0",
37
+ "devDependencies": {
38
+ "@napi-rs/cli": "^3.4.1",
39
+ "@types/node": "^24.3.0"
40
+ },
41
+ "engines": {
42
+ "node": ">=16"
43
+ }
34
44
  }