@graffy/common 0.19.1-alpha.1 → 0.19.1-alpha.2
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/coding/args.d.ts +4 -2
- package/coding/args.js +0 -1
- package/coding/decodeTree.js +7 -6
- package/coding/decorate.js +2 -2
- package/coding/encodeTree.js +4 -1
- package/coding/pack.d.ts +2 -2
- package/coding/path.d.ts +1 -1
- package/coding/struct.js +0 -1
- package/node/find.d.ts +2 -2
- package/node/find.js +2 -2
- package/ops/finalize.d.ts +1 -1
- package/ops/slice.d.ts +6 -2
- package/package.json +4 -4
- package/stream/makeWatcher.d.ts +1 -1
- package/util.d.ts +1 -1
package/coding/args.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export declare function splitArgs(arg: any):
|
|
1
|
+
export declare function splitArgs(arg: any): [Record<string, any> | undefined, Record<string, any> | undefined];
|
|
2
2
|
export declare function encode(arg: any): {
|
|
3
|
-
key
|
|
3
|
+
key?: Uint8Array<ArrayBuffer>;
|
|
4
|
+
end?: Uint8Array<ArrayBuffer>;
|
|
5
|
+
limit?: number;
|
|
4
6
|
};
|
|
5
7
|
export declare function decode(node: any): any;
|
package/coding/args.js
CHANGED
|
@@ -36,7 +36,6 @@ export function encode(arg) {
|
|
|
36
36
|
if (!page)
|
|
37
37
|
return { key: encodeValue(filter || {}) };
|
|
38
38
|
const { $cursor, ...range } = page;
|
|
39
|
-
// @ts-expect-error
|
|
40
39
|
const { $first, $all, $last, $after, $before, $since, $until } = range;
|
|
41
40
|
const hasRange = !isEmpty(range);
|
|
42
41
|
errIf('first_and_last', isDef($first) && isDef($last), arg);
|
package/coding/decodeTree.js
CHANGED
|
@@ -150,17 +150,18 @@ function decode(nodes = [], { isGraph } = {}) {
|
|
|
150
150
|
}
|
|
151
151
|
child.$key = { ...args, ...child.$key };
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
const ch = children;
|
|
154
|
+
if (ch.$put === true) {
|
|
155
|
+
ch[PRE_CHI_PUT] = [{ ...args, $all: true }];
|
|
155
156
|
}
|
|
156
|
-
else if (Array.isArray(
|
|
157
|
-
|
|
157
|
+
else if (Array.isArray(ch.$put)) {
|
|
158
|
+
ch[PRE_CHI_PUT] = ch.$put.map((rarg) => ({
|
|
158
159
|
...args,
|
|
159
160
|
...rarg,
|
|
160
161
|
}));
|
|
161
162
|
}
|
|
162
|
-
else if (isDef(
|
|
163
|
-
|
|
163
|
+
else if (isDef(ch.$put)) {
|
|
164
|
+
ch[PRE_CHI_PUT] = [{ ...args, ...ch.$put }];
|
|
164
165
|
}
|
|
165
166
|
return children;
|
|
166
167
|
}
|
package/coding/decorate.js
CHANGED
|
@@ -182,9 +182,9 @@ function addPageMeta(graph, args) {
|
|
|
182
182
|
Object.assign(graph, { $page: args, $prev: null, $next: null });
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
|
-
const [
|
|
185
|
+
const [page, filter] = splitArgs(args);
|
|
186
|
+
const { $first, $last, ...bounds } = page;
|
|
186
187
|
const count = $first || $last;
|
|
187
|
-
/** @type {any} */
|
|
188
188
|
const $page = { ...filter, ...bounds, $all: true };
|
|
189
189
|
if (graph.length === count) {
|
|
190
190
|
// This result was limited by the count; update the "outer" bound.
|
package/coding/encodeTree.js
CHANGED
|
@@ -93,7 +93,10 @@ function encode(value, { version, isGraph } = {}) {
|
|
|
93
93
|
if ((!isDef(key) || Number.isInteger(key)) &&
|
|
94
94
|
(filter || isDef(page.$cursor))) {
|
|
95
95
|
object.$key = isDef(page.$cursor) ? page.$cursor : page;
|
|
96
|
-
const wrapper = {
|
|
96
|
+
const wrapper = {
|
|
97
|
+
$key: filter || {},
|
|
98
|
+
$chi: [object],
|
|
99
|
+
};
|
|
97
100
|
if (isGraph)
|
|
98
101
|
wrapper.$put = foundPuts;
|
|
99
102
|
const node = makeNode(wrapper, key, ver);
|
package/coding/pack.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function pack(children: any, parentVersion
|
|
2
|
-
export declare function unpack(children: any, parentVersion
|
|
1
|
+
export declare function pack(children: any, parentVersion?: any): any;
|
|
2
|
+
export declare function unpack(children: any, parentVersion?: any): any;
|
package/coding/path.d.ts
CHANGED
package/coding/struct.js
CHANGED
package/node/find.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function findFirst(children: any, target: any, first
|
|
2
|
-
export declare function findLast(children: any, end: any, first
|
|
1
|
+
export declare function findFirst(children: any, target: any, first?: number, last?: any): number;
|
|
2
|
+
export declare function findLast(children: any, end: any, first?: number, last?: any): number;
|
package/node/find.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cmp, find } from "../util.js";
|
|
2
|
-
export function findFirst(children, target, first, last) {
|
|
2
|
+
export function findFirst(children, target, first = 0, last = children.length) {
|
|
3
3
|
return find(children, ({ key, end }) => {
|
|
4
4
|
const keyCmp = cmp(key, target);
|
|
5
5
|
const endCmp = end && cmp(end, target);
|
|
@@ -8,7 +8,7 @@ export function findFirst(children, target, first, last) {
|
|
|
8
8
|
return keyCmp;
|
|
9
9
|
}, first, last);
|
|
10
10
|
}
|
|
11
|
-
export function findLast(children, end, first, last) {
|
|
11
|
+
export function findLast(children, end, first = 0, last = children.length) {
|
|
12
12
|
const ix = findFirst(children, end, first, last);
|
|
13
13
|
return children[ix] && cmp(children[ix].key, end) <= 0 ? ix + 1 : ix;
|
|
14
14
|
}
|
package/ops/finalize.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {number | false} version
|
|
6
6
|
* @returns any
|
|
7
7
|
*/
|
|
8
|
-
export default function finalize(graph: any, query: any, version?: number): {
|
|
8
|
+
export default function finalize(graph: any, query: any, version?: number | false): {
|
|
9
9
|
key: Uint8Array<ArrayBuffer>;
|
|
10
10
|
end: Uint8Array<ArrayBuffer>;
|
|
11
11
|
version: number;
|
package/ops/slice.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
declare class Result {
|
|
2
|
-
|
|
2
|
+
root: Result;
|
|
3
|
+
known?: any[];
|
|
4
|
+
unknown?: any[];
|
|
5
|
+
linked?: any[];
|
|
6
|
+
constructor(root?: any);
|
|
3
7
|
addKnown(node: any): void;
|
|
4
8
|
addUnknown(node: any): void;
|
|
5
9
|
addLinked(children: any): any;
|
|
6
10
|
}
|
|
7
|
-
export default function slice(graph: any, query: any, root
|
|
11
|
+
export default function slice(graph: any, query: any, root?: any): Result;
|
|
8
12
|
export declare function sliceRange(graph: any, query: any, result: any): void;
|
|
9
13
|
export {};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/common",
|
|
3
3
|
"description": "Common libraries that used by various Graffy modules.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.19.1-alpha.
|
|
5
|
+
"version": "0.19.1-alpha.2",
|
|
6
6
|
"main": "./cjs/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"debug": "^4.4.3",
|
|
25
|
-
"lodash": "^4.
|
|
26
|
-
"nanoid": "^5.1.
|
|
27
|
-
"@graffy/stream": "0.19.1-alpha.
|
|
25
|
+
"lodash": "^4.18.1",
|
|
26
|
+
"nanoid": "^5.1.11",
|
|
27
|
+
"@graffy/stream": "0.19.1-alpha.2",
|
|
28
28
|
"merge-async-iterators": "^0.2.1"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/stream/makeWatcher.d.ts
CHANGED
package/util.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function isMaxKey(key: any): boolean;
|
|
|
5
5
|
export declare function err(message: any, { cause, ...args }?: {
|
|
6
6
|
cause?: any;
|
|
7
7
|
}): void;
|
|
8
|
-
export declare function errIf(message: any, condition: any, args
|
|
8
|
+
export declare function errIf(message: any, condition: any, args?: any): void;
|
|
9
9
|
export declare function isEmpty(object: any): boolean;
|
|
10
10
|
export declare function isDef(value: any): boolean;
|
|
11
11
|
export declare function isPlainObject(arg: any): boolean;
|