JS (emscripten) port of SpatiaLite
npm install spatiasqlJavaScript (emscripten) port of SpatiaLite 5.0.0-beta (including SQLite 3.24.0, proj 5.1.0, geos 3.6.2)

(be patient, loading the js and database file takes some time).
- loading shapefiles in node:
``js
const fs = require('fs');
const spatiasql = require('spatiasql-node');
spatiasql.then(Database => {
const db = new Database();
db.loadshp('my_table', 'CP1251', 4326, {
shp: fs.readFileSync('my_file.shp'),
shx: fs.readFileSync('my_file.shx'),
dbf: fs.readFileSync('my_file.dbf')
});
let res = db.exec('SELECT * FROM my_table');
console.log(res);
});
`
- loading shapefiles in the browser:
`js
import { Database } from 'spatiasql';
const db = new Database();
const files = await Promise.all([
fetch('my_file.shp').then(res => res.arrayBuffer()),
fetch('my_file.shx').then(res => res.arrayBuffer()),
fetch('my_file.dbf').then(res => res.arrayBuffer())
]);
const loaded = await db.loadshp('my_table', 'CP1251', 4326, {
shp: files[0],
shx: files[1],
dbf: files[2]
});
if (loaded) {
db.exec('SELECT * FROM my_table')
.then(res => console.log(res));
}
``