@instantdb/core
Advanced tools
Comparing version 0.10.20 to 0.10.21
@@ -244,6 +244,5 @@ "use strict"; | ||
function isBefore(startCursor, direction, [e, a, _v, t]) { | ||
return (startCursor[1] === a && | ||
(cursorCompare(direction, "number")(t, startCursor[3]) || | ||
(t === startCursor[3] && | ||
cursorCompare(direction, "uuid")(e, startCursor[0])))); | ||
return (cursorCompare(direction, "number")(t, startCursor[3]) || | ||
(t === startCursor[3] && | ||
cursorCompare(direction, "uuid")(e, startCursor[0]))); | ||
} | ||
@@ -269,3 +268,5 @@ function runDataloadAndReturnObjects(store, etype, direction, pageInfo, dq) { | ||
} | ||
if (startCursor && isBefore(startCursor, direction, triple)) { | ||
if (startCursor && | ||
a === startCursor[1] && | ||
isBefore(startCursor, direction, triple)) { | ||
toRemove.push(e); | ||
@@ -272,0 +273,0 @@ } |
@@ -242,6 +242,5 @@ import { query as datalogQuery } from "./datalog"; | ||
function isBefore(startCursor, direction, [e, a, _v, t]) { | ||
return (startCursor[1] === a && | ||
(cursorCompare(direction, "number")(t, startCursor[3]) || | ||
(t === startCursor[3] && | ||
cursorCompare(direction, "uuid")(e, startCursor[0])))); | ||
return (cursorCompare(direction, "number")(t, startCursor[3]) || | ||
(t === startCursor[3] && | ||
cursorCompare(direction, "uuid")(e, startCursor[0]))); | ||
} | ||
@@ -267,3 +266,5 @@ function runDataloadAndReturnObjects(store, etype, direction, pageInfo, dq) { | ||
} | ||
if (startCursor && isBefore(startCursor, direction, triple)) { | ||
if (startCursor && | ||
a === startCursor[1] && | ||
isBefore(startCursor, direction, triple)) { | ||
toRemove.push(e); | ||
@@ -270,0 +271,0 @@ } |
@@ -1,18 +0,23 @@ | ||
import { parse, v4 } from "uuid"; | ||
export function uuidCompare(uuid_a, uuid_b) { | ||
const bytes_a = parse(uuid_a); | ||
const bytes_b = parse(uuid_b); | ||
for (let i = 0; i < 16; i++) { | ||
const a = bytes_a[i]; | ||
const b = bytes_b[i]; | ||
if (a < b) { | ||
import { v4 } from "uuid"; | ||
function uuidToByteArray(uuid) { | ||
const hex = uuid.replace(/-/g, ""); | ||
const bytes = []; | ||
for (let i = 0; i < hex.length; i += 2) { | ||
bytes.push(parseInt(hex.substring(i, i + 2), 16)); | ||
} | ||
return bytes; | ||
} | ||
function compareByteArrays(a, b) { | ||
for (let i = 0; i < a.length; i++) { | ||
if (a[i] < b[i]) | ||
return -1; | ||
} | ||
if (b > a) { | ||
if (a[i] > b[i]) | ||
return 1; | ||
} | ||
} | ||
return 0; | ||
} | ||
export function uuidCompare(uuid_a, uuid_b) { | ||
return compareByteArrays(uuidToByteArray(uuid_a), uuidToByteArray(uuid_b)); | ||
} | ||
export default v4; | ||
//# sourceMappingURL=uuid.js.map |
@@ -5,19 +5,24 @@ "use strict"; | ||
const uuid_1 = require("uuid"); | ||
function uuidCompare(uuid_a, uuid_b) { | ||
const bytes_a = (0, uuid_1.parse)(uuid_a); | ||
const bytes_b = (0, uuid_1.parse)(uuid_b); | ||
for (let i = 0; i < 16; i++) { | ||
const a = bytes_a[i]; | ||
const b = bytes_b[i]; | ||
if (a < b) { | ||
function uuidToByteArray(uuid) { | ||
const hex = uuid.replace(/-/g, ""); | ||
const bytes = []; | ||
for (let i = 0; i < hex.length; i += 2) { | ||
bytes.push(parseInt(hex.substring(i, i + 2), 16)); | ||
} | ||
return bytes; | ||
} | ||
function compareByteArrays(a, b) { | ||
for (let i = 0; i < a.length; i++) { | ||
if (a[i] < b[i]) | ||
return -1; | ||
} | ||
if (b > a) { | ||
if (a[i] > b[i]) | ||
return 1; | ||
} | ||
} | ||
return 0; | ||
} | ||
function uuidCompare(uuid_a, uuid_b) { | ||
return compareByteArrays(uuidToByteArray(uuid_a), uuidToByteArray(uuid_b)); | ||
} | ||
exports.uuidCompare = uuidCompare; | ||
exports.default = uuid_1.v4; | ||
//# sourceMappingURL=uuid.js.map |
{ | ||
"name": "@instantdb/core", | ||
"version": "0.10.20", | ||
"version": "0.10.21", | ||
"description": "Instant's core local abstraction", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -327,6 +327,5 @@ import { query as datalogQuery } from "./datalog"; | ||
return ( | ||
startCursor[1] === a && | ||
(cursorCompare(direction, "number")(t, startCursor[3]) || | ||
(t === startCursor[3] && | ||
cursorCompare(direction, "uuid")(e, startCursor[0]))) | ||
cursorCompare(direction, "number")(t, startCursor[3]) || | ||
(t === startCursor[3] && | ||
cursorCompare(direction, "uuid")(e, startCursor[0])) | ||
); | ||
@@ -355,3 +354,7 @@ } | ||
if (startCursor && isBefore(startCursor, direction, triple)) { | ||
if ( | ||
startCursor && | ||
a === startCursor[1] && | ||
isBefore(startCursor, direction, triple) | ||
) { | ||
toRemove.push(e); | ||
@@ -358,0 +361,0 @@ } |
@@ -1,16 +0,16 @@ | ||
import { parse, v4 } from "uuid"; | ||
import { v4 } from "uuid"; | ||
export function uuidCompare(uuid_a: string, uuid_b: string) { | ||
const bytes_a = parse(uuid_a); | ||
const bytes_b = parse(uuid_b); | ||
function uuidToByteArray(uuid: string) { | ||
const hex = uuid.replace(/-/g, ""); | ||
const bytes = []; | ||
for (let i = 0; i < hex.length; i += 2) { | ||
bytes.push(parseInt(hex.substring(i, i + 2), 16)); | ||
} | ||
return bytes; | ||
} | ||
for (let i = 0; i < 16; i++) { | ||
const a = bytes_a[i]; | ||
const b = bytes_b[i]; | ||
if (a < b) { | ||
return -1; | ||
} | ||
if (b > a) { | ||
return 1; | ||
} | ||
function compareByteArrays(a, b) { | ||
for (let i = 0; i < a.length; i++) { | ||
if (a[i] < b[i]) return -1; | ||
if (a[i] > b[i]) return 1; | ||
} | ||
@@ -20,2 +20,6 @@ return 0; | ||
export function uuidCompare(uuid_a: string, uuid_b: string) { | ||
return compareByteArrays(uuidToByteArray(uuid_a), uuidToByteArray(uuid_b)); | ||
} | ||
export default v4; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2829923
40176