Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@kikko-land/better-absurd-sql
Advanced tools
You can check out the [example project](https://github.com/jlongster/absurd-example-project) to get started. Or follow the steps below:
Readme
This project is a fork of absurd-sql. Big thanks to James! But for now absurd-sql looks more abandoned than live. I also asked James for the access, but he didn't answer unfortunately, :(. And it's ok, he has not so much free time, I totally understand. So I managed to fork it and to continue work on it. If James start merging PRs(I hope so!), I will close this repo.
This is an absurd project.
It implements a backend for sql.js (sqlite3 compiled for the web) that treats IndexedDB like a disk and stores data in blocks there. That means your sqlite3 database is persisted. And not in the terrible way of reading and writing the whole image at once -- it reads and writes your db in small chunks.
It basically stores a whole database into another database. Which is absurd.
See the demo. You can also view an entire app using this here.
You should also read this blog post which explains the project in great detail.
If you like my work, feel free to buy me a coffee!
You can check out the example project to get started. Or follow the steps below:
First you install the packages:
yarn add @kikko-land/sql.js @kikko-land/better-absurd-sql
Right now you need to use my fork of sql.js
, but I'm going to open a PR and hopefully get it merged. The changes are minimal.
absurd-sql must run in a worker. This is fine because you really shouldn't be blocking the main thread anyway. So on the main thread, do this:
import { initBackend } from '@kikko-land/better-absurd-sql/dist/indexeddb-main-thread';
function init() {
let worker = new Worker(new URL('./index.worker.js', import.meta.url));
// This is only required because Safari doesn't support nested
// workers. This installs a handler that will proxy creating web
// workers through the main thread
initBackend(worker);
}
init();
Then in index.worker.js
do this:
import initSqlJs from '@kikko-land/sql.js';
import { SQLiteFS } from '@kikko-land/better-absurd-sql';
import IndexedDBBackend from '@kikko-land/better-absurd-sql/dist/indexeddb-backend';
async function run() {
let SQL = await initSqlJs({ locateFile: (file) => file });
let sqlFS = new SQLiteFS(SQL.FS, new IndexedDBBackend());
SQL.register_for_idb(sqlFS);
SQL.FS.mkdir('/sql');
SQL.FS.mount(sqlFS, {}, '/sql');
const path = '/sql/db.sqlite';
if (typeof SharedArrayBuffer === 'undefined') {
let stream = SQL.FS.open(path, 'a+');
await stream.node.contents.readIfFallback();
SQL.FS.close(stream);
}
let db = new SQL.Database(path, { filename: true });
// You might want to try `PRAGMA page_size=8192;` too!
db.exec(`
PRAGMA journal_mode=MEMORY;
`);
// Your code
}
Because this uses SharedArrayBuffer
and the Atomics
API, there are some requirement for code to run.
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Those headers are required because browsers only enable SharedArrayBuffer
if you tell it to isolate the process. There are potential security problems if SharedArrayBuffer
was available everywhere.
We do support browsers without SharedArrayBuffer
(only Safari). Read more about it here: https://jlongster.com/future-sql-web#fallback-mode-without-sharedarraybuffer
There are some limitations in this mode: only one tab can be writing the database at a time. The database will never be corrupted; if multiple tabs try to write it will just throw an error (in the future it should call a handler that you provide so you can notify the user).
It consistently beats IndexedDB performance up to 10x:
Read performance: doing something like SELECT SUM(value) FROM kv
:
Write performance: doing a bulk insert:
These are all on a 2015 macbook pro. Benchmark code is in src/examples/bench
.
Read this blog post for more details.
There are several things that could be done:
webkitFileSystem
backend
FAQs
You can check out the [example project](https://github.com/jlongster/absurd-example-project) to get started. Or follow the steps below:
The npm package @kikko-land/better-absurd-sql receives a total of 769 weekly downloads. As such, @kikko-land/better-absurd-sql popularity was classified as not popular.
We found that @kikko-land/better-absurd-sql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.