Skip to content

Commit

Permalink
Fixes for Bun v0.5, #208
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Jan 20, 2023
1 parent bc92d61 commit e593d2c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
4 changes: 1 addition & 3 deletions native.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { dirname, join, default as pathModule } from 'path';
import { fileURLToPath } from 'url';
import loadNAPI from 'node-gyp-build-optional-packages';
export let Env, Txn, Dbi, Compression, Cursor, getAddress, getBufferAddress, createBufferForAddress, clearKeptObjects, globalBuffer, setGlobalBuffer, arch, fs, os, onExit, tmpdir, lmdbError, path, EventEmitter, orderedBinary, MsgpackrEncoder, WeakLRUCache, setEnvMap, getEnvMap, getByBinary, detachBuffer, startRead, setReadCallback, write, position, iterate, prefetch, resetTxn, getCurrentValue, getCurrentShared, getStringByBinary, getSharedByBinary, getSharedBuffer, compress;

path = pathModule;
let dirName = (typeof __dirname == 'string' ? __dirname : // for bun, which doesn't have fileURLToPath
dirname(fileURLToPath(import.meta.url))).replace(/dist$/, ''); // for node, which doesn't have __dirname in ESM
let dirName = dirname(fileURLToPath(import.meta.url)).replace(/dist$/, '');
export let nativeAddon = loadNAPI(dirName);

if (process.isBun && false) {
Expand Down
11 changes: 6 additions & 5 deletions node-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import { createRequire } from 'module';
import { setRequire } from './open.js';
import { nativeAddon, setNativeFunctions } from './native.js';
export { nativeAddon } from './native.js'
import { setFlagsFromString } from 'v8';
setRequire(createRequire(import.meta.url));
let require = createRequire(import.meta.url);
setRequire(require);
export let v8AccelerationEnabled = false

let versions = process.versions;
if (!versions.deno) {
if (!versions.deno && !process.isBun) {
let [ majorVersion, minorVersion ] = versions.node.split('.');
if (versions.v8 && +majorVersion == nativeAddon.version.nodeCompiledVersion) {
let v8Funcs = {};
let fastApiCalls = (majorVersion == 17 || majorVersion == 18 || majorVersion == 16 && minorVersion > 8) && !process.env.DISABLE_TURBO_CALLS;
if (fastApiCalls)
setFlagsFromString('--turbo-fast-api-calls')
if (fastApiCalls) {
require('v8').setFlagsFromString('--turbo-fast-api-calls');
}
nativeAddon.enableDirectV8(v8Funcs, fastApiCalls);
Object.assign(nativeAddon, v8Funcs);
v8AccelerationEnabled = true;
Expand Down
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lmdb",
"author": "Kris Zyp",
"version": "2.7.4",
"version": "2.7.5",
"description": "Simple, efficient, scalable, high-performance LMDB interface",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -80,7 +80,7 @@
"dependencies": {
"msgpackr": "1.8.1",
"node-addon-api": "^4.3.0",
"node-gyp-build-optional-packages": "5.0.5",
"node-gyp-build-optional-packages": "5.0.6",
"ordered-binary": "^1.4.0",
"weak-lru-cache": "^1.2.2"
},
Expand All @@ -105,11 +105,5 @@
"test": "tests"
},
"optionalDependencies": {
"@lmdb/lmdb-darwin-arm64": "2.7.2",
"@lmdb/lmdb-darwin-x64": "2.7.2",
"@lmdb/lmdb-linux-arm": "2.7.2",
"@lmdb/lmdb-linux-arm64": "2.7.2",
"@lmdb/lmdb-linux-x64": "2.7.2",
"@lmdb/lmdb-win32-x64": "2.7.2"
}
}
3 changes: 1 addition & 2 deletions read.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { RangeIterable } from './util/RangeIterable.js';
import { getAddress, Cursor, Txn, orderedBinary, lmdbError, getByBinary, detachBuffer, setGlobalBuffer, prefetch, iterate, position as doPosition, resetTxn, getCurrentValue, getCurrentShared, getStringByBinary, globalBuffer, getSharedBuffer, startRead, setReadCallback } from './native.js';
import { getAddress, Cursor, Txn, orderedBinary, lmdbError, getByBinary, setGlobalBuffer, prefetch, iterate, position as doPosition, resetTxn, getCurrentValue, getCurrentShared, getStringByBinary, globalBuffer, getSharedBuffer, startRead, setReadCallback } from './native.js';
import { saveKey } from './keys.js';
import lmdb from "./index.js";
const IF_EXISTS = 3.542694326329068e-103;
const ITERATOR_DONE = { done: true, value: undefined };
const Uint8ArraySlice = Uint8Array.prototype.slice;
Expand Down

0 comments on commit e593d2c

Please sign in to comment.