@based/db 0.0.25 → 0.0.26
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/dist/lib/darwin_aarch64/include/selva/db.h +37 -3
- package/dist/lib/darwin_aarch64/include/selva/fields.h +3 -3
- package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
- package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +37 -3
- package/dist/lib/linux_aarch64/include/selva/fields.h +3 -3
- package/dist/lib/linux_aarch64/libnode-v20.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v21.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +37 -3
- package/dist/lib/linux_x86_64/include/selva/fields.h +3 -3
- package/dist/lib/linux_x86_64/libnode-v20.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v21.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/flushModify.js +5 -1
- package/dist/src/client/index.d.ts +12 -6
- package/dist/src/client/index.js +33 -1
- package/dist/src/client/modify/create.js +17 -1
- package/dist/src/client/modify/fixed.js +52 -3
- package/dist/src/client/modify/modify.js +3 -1
- package/dist/src/client/modify/references/edge.js +3 -1
- package/dist/src/client/modify/upsert.js +1 -1
- package/dist/src/client/operations.d.ts +32 -0
- package/dist/src/client/operations.js +137 -0
- package/dist/src/client/query/BasedDbQuery.js +3 -0
- package/dist/src/client/query/BasedIterable.js +10 -3
- package/dist/src/client/query/aggregation.d.ts +3 -0
- package/dist/src/client/query/aggregation.js +9 -0
- package/dist/src/client/query/display.js +12 -2
- package/dist/src/client/query/filter/toBuffer.js +2 -2
- package/dist/src/client/query/query.d.ts +1 -1
- package/dist/src/client/query/query.js +1 -1
- package/dist/src/client/query/queryDef.js +0 -1
- package/dist/src/client/query/read/read.js +9 -4
- package/dist/src/client/query/toBuffer.js +2 -2
- package/dist/src/client/query/types.d.ts +4 -3
- package/dist/src/client/query/validation.js +5 -1
- package/dist/src/client/string.js +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.js +11 -2
- package/dist/src/native.d.ts +1 -1
- package/dist/src/native.js +2 -2
- package/dist/src/server/csmt/tree.js +2 -2
- package/dist/src/server/index.d.ts +1 -1
- package/dist/src/server/index.js +27 -2
- package/dist/src/server/save.js +19 -11
- package/dist/src/server/start.js +0 -2
- package/dist/src/utils.d.ts +6 -0
- package/dist/src/utils.js +81 -9
- package/package.json +4 -4
package/dist/src/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encodeBase64 } from '@saulx/utils';
|
|
2
|
-
const native =
|
|
2
|
+
const native = typeof window === 'undefined' ? (await import('./native.js')).default : null;
|
|
3
3
|
export const DECODER = new TextDecoder('utf-8');
|
|
4
4
|
export const ENCODER = new TextEncoder();
|
|
5
5
|
export const equals = (aB, bB) => {
|
|
@@ -28,7 +28,8 @@ export const equals = (aB, bB) => {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
export function concatUint8Arr(bufs, totalByteLength) {
|
|
31
|
-
totalByteLength =
|
|
31
|
+
totalByteLength =
|
|
32
|
+
totalByteLength ?? bufs.reduce((acc, cur) => acc + cur.byteLength, 0);
|
|
32
33
|
const res = new Uint8Array(totalByteLength);
|
|
33
34
|
let off = 0;
|
|
34
35
|
for (let i = 0; i < bufs.length; i++) {
|
|
@@ -62,12 +63,12 @@ const intMap = {
|
|
|
62
63
|
'7': 0x7,
|
|
63
64
|
'8': 0x8,
|
|
64
65
|
'9': 0x9,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
a: 0xa,
|
|
67
|
+
b: 0xb,
|
|
68
|
+
c: 0xc,
|
|
69
|
+
d: 0xd,
|
|
70
|
+
e: 0xe,
|
|
71
|
+
f: 0xf,
|
|
71
72
|
};
|
|
72
73
|
// Uint8Array.fromHex() and Uint8Array.toHex() are not available in V8
|
|
73
74
|
// https://issues.chromium.org/issues/42204568
|
|
@@ -85,7 +86,7 @@ function base64OutLen(n, lineMax) {
|
|
|
85
86
|
let olen;
|
|
86
87
|
/* This version would be with padding but we don't pad */
|
|
87
88
|
//olen = n * 4 / 3 + 4; /* 3-byte blocks to 4-byte */
|
|
88
|
-
olen = ((4 * n / 3
|
|
89
|
+
olen = ((4 * n) / 3 + 3) & ~3;
|
|
89
90
|
olen += lineMax > 0 ? olen / lineMax : 0; // line feeds
|
|
90
91
|
return olen;
|
|
91
92
|
}
|
|
@@ -99,4 +100,75 @@ export const base64encode = (a, lineMax = 72) => {
|
|
|
99
100
|
return DECODER.decode(native.base64encode(tmp, a, lineMax));
|
|
100
101
|
}
|
|
101
102
|
};
|
|
103
|
+
export const readDoubleLE = (val, offset) => {
|
|
104
|
+
const low = (val[offset] |
|
|
105
|
+
(val[offset + 1] << 8) |
|
|
106
|
+
(val[offset + 2] << 16) |
|
|
107
|
+
(val[offset + 3] << 24)) >>>
|
|
108
|
+
0;
|
|
109
|
+
const high = (val[offset + 4] |
|
|
110
|
+
(val[offset + 5] << 8) |
|
|
111
|
+
(val[offset + 6] << 16) |
|
|
112
|
+
(val[offset + 7] << 24)) >>>
|
|
113
|
+
0;
|
|
114
|
+
const sign = high >>> 31 ? -1 : 1;
|
|
115
|
+
let exponent = (high >>> 20) & 0x7ff;
|
|
116
|
+
let fraction = (high & 0xfffff) * 2 ** 32 + low;
|
|
117
|
+
if (exponent === 0x7ff) {
|
|
118
|
+
if (fraction === 0)
|
|
119
|
+
return sign * Infinity;
|
|
120
|
+
return NaN;
|
|
121
|
+
}
|
|
122
|
+
if (exponent === 0) {
|
|
123
|
+
if (fraction === 0)
|
|
124
|
+
return sign * 0;
|
|
125
|
+
exponent = 1;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
fraction += 2 ** 52;
|
|
129
|
+
}
|
|
130
|
+
return sign * fraction * 2 ** (exponent - 1075);
|
|
131
|
+
};
|
|
132
|
+
export const readFloatLE = (val, offset) => {
|
|
133
|
+
const bits = val[offset] |
|
|
134
|
+
(val[offset + 1] << 8) |
|
|
135
|
+
(val[offset + 2] << 16) |
|
|
136
|
+
(val[offset + 3] << 24);
|
|
137
|
+
const sign = bits >>> 31 ? -1 : 1;
|
|
138
|
+
let exponent = (bits >>> 23) & 0xff;
|
|
139
|
+
let fraction = bits & 0x7fffff;
|
|
140
|
+
if (exponent === 0xff) {
|
|
141
|
+
if (fraction === 0)
|
|
142
|
+
return sign * Infinity;
|
|
143
|
+
return NaN;
|
|
144
|
+
}
|
|
145
|
+
if (exponent === 0) {
|
|
146
|
+
if (fraction === 0)
|
|
147
|
+
return sign * 0;
|
|
148
|
+
exponent = 1;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
fraction |= 0x800000;
|
|
152
|
+
}
|
|
153
|
+
return sign * fraction * 2 ** (exponent - 150);
|
|
154
|
+
};
|
|
155
|
+
export const readUint32 = (val, offset) => {
|
|
156
|
+
return ((val[offset] |
|
|
157
|
+
(val[offset + 1] << 8) |
|
|
158
|
+
(val[offset + 2] << 16) |
|
|
159
|
+
(val[offset + 3] << 24)) >>>
|
|
160
|
+
0);
|
|
161
|
+
};
|
|
162
|
+
export const readInt32 = (val, offset) => {
|
|
163
|
+
return (val[offset] |
|
|
164
|
+
(val[offset + 1] << 8) |
|
|
165
|
+
(val[offset + 2] << 16) |
|
|
166
|
+
(val[offset + 3] << 24));
|
|
167
|
+
};
|
|
168
|
+
export const readInt16 = (val, offset) => {
|
|
169
|
+
return ((val[offset] | (val[offset + 1] << 8)) << 16) >> 16;
|
|
170
|
+
};
|
|
171
|
+
export const readUint16 = (val, offset) => {
|
|
172
|
+
return (val[offset] | (val[offset + 1] << 8)) >>> 0;
|
|
173
|
+
};
|
|
102
174
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@based/db",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"basedDbNative.cjs"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@based/schema": "5.0.0-alpha.
|
|
35
|
+
"@based/schema": "5.0.0-alpha.8",
|
|
36
36
|
"@saulx/hash": "^3.0.0",
|
|
37
|
-
"@saulx/utils": "^
|
|
37
|
+
"@saulx/utils": "^6.1.1",
|
|
38
38
|
"exit-hook": "^4.0.0",
|
|
39
39
|
"picocolors": "^1.1.0",
|
|
40
40
|
"@based/crc32c": "^1.0.0"
|
|
@@ -50,4 +50,4 @@
|
|
|
50
50
|
"tar": "^7.4.3",
|
|
51
51
|
"typescript": "^5.6.3"
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
}
|