@graffy/common 0.15.21 → 0.15.23-alpha.1

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/index.cjs CHANGED
@@ -30,8 +30,7 @@ var __objRest = (source, exclude) => {
30
30
  }
31
31
  return target;
32
32
  };
33
- Object.defineProperty(exports, "__esModule", { value: true });
34
- exports[Symbol.toStringTag] = "Module";
33
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
35
34
  var nonSecure = require("nanoid/non-secure");
36
35
  var mergeIterators = require("merge-async-iterators");
37
36
  var stream = require("@graffy/stream");
@@ -177,7 +176,7 @@ function encode$3(value) {
177
176
  }
178
177
  return encode$4(buffer);
179
178
  }
180
- const nextKey = new WeakMap();
179
+ const nextKey = /* @__PURE__ */ new WeakMap();
181
180
  function decode$3(key) {
182
181
  let i = 0;
183
182
  const buffer = decode$4(key, 0);
@@ -773,8 +772,12 @@ function sliceNode(graph, query, result) {
773
772
  function sliceRange(graph, query, result) {
774
773
  let { key, end, limit = Infinity, version } = query;
775
774
  const step = key < end ? 1 : -1;
776
- if (graph[0].key === "" && graph[0].prefix) {
777
- sliceNode(graph[0], query, result);
775
+ if (graph[0].key === "" && graph[0].prefix && graph[0].children) {
776
+ const { known, unknown } = slice(graph[0].children, [query], result.root);
777
+ if (known)
778
+ result.addKnown(__spreadProps(__spreadValues({}, graph[0]), { children: known }));
779
+ if (unknown)
780
+ result.addUnknown(__spreadProps(__spreadValues({}, query[0]), { children: unknown }));
778
781
  return;
779
782
  }
780
783
  if (key < end) {
@@ -1333,9 +1336,9 @@ function encode(value, { version, isGraph } = {}) {
1333
1336
  node2.prefix = true;
1334
1337
  return node2;
1335
1338
  }
1336
- if ((!isDef(key) || Number.isInteger(key)) && page && filter) {
1339
+ if ((!isDef(key) || Number.isInteger(key)) && page && (filter || isDef(page.$cursor))) {
1337
1340
  const node2 = makeNode({
1338
- $key: filter,
1341
+ $key: filter || "",
1339
1342
  $chi: [
1340
1343
  __spreadProps(__spreadValues({}, object), { $key: isDef(page.$cursor) ? page.$cursor : page })
1341
1344
  ]
@@ -1441,7 +1444,7 @@ async function* mergeStreams(...streams) {
1441
1444
  yield* mergeIterators__default["default"](streams);
1442
1445
  }
1443
1446
  function makeWatcher() {
1444
- const listeners = new Set();
1447
+ const listeners = /* @__PURE__ */ new Set();
1445
1448
  function write(change) {
1446
1449
  for (const push of listeners)
1447
1450
  push(change);
package/index.mjs CHANGED
@@ -169,7 +169,7 @@ function encode$3(value) {
169
169
  }
170
170
  return encode$4(buffer);
171
171
  }
172
- const nextKey = new WeakMap();
172
+ const nextKey = /* @__PURE__ */ new WeakMap();
173
173
  function decode$3(key) {
174
174
  let i = 0;
175
175
  const buffer = decode$4(key, 0);
@@ -765,8 +765,12 @@ function sliceNode(graph, query, result) {
765
765
  function sliceRange(graph, query, result) {
766
766
  let { key, end, limit = Infinity, version } = query;
767
767
  const step = key < end ? 1 : -1;
768
- if (graph[0].key === "" && graph[0].prefix) {
769
- sliceNode(graph[0], query, result);
768
+ if (graph[0].key === "" && graph[0].prefix && graph[0].children) {
769
+ const { known, unknown } = slice(graph[0].children, [query], result.root);
770
+ if (known)
771
+ result.addKnown(__spreadProps(__spreadValues({}, graph[0]), { children: known }));
772
+ if (unknown)
773
+ result.addUnknown(__spreadProps(__spreadValues({}, query[0]), { children: unknown }));
770
774
  return;
771
775
  }
772
776
  if (key < end) {
@@ -1325,9 +1329,9 @@ function encode(value, { version, isGraph } = {}) {
1325
1329
  node2.prefix = true;
1326
1330
  return node2;
1327
1331
  }
1328
- if ((!isDef(key) || Number.isInteger(key)) && page && filter) {
1332
+ if ((!isDef(key) || Number.isInteger(key)) && page && (filter || isDef(page.$cursor))) {
1329
1333
  const node2 = makeNode({
1330
- $key: filter,
1334
+ $key: filter || "",
1331
1335
  $chi: [
1332
1336
  __spreadProps(__spreadValues({}, object), { $key: isDef(page.$cursor) ? page.$cursor : page })
1333
1337
  ]
@@ -1433,7 +1437,7 @@ async function* mergeStreams(...streams) {
1433
1437
  yield* mergeIterators(streams);
1434
1438
  }
1435
1439
  function makeWatcher() {
1436
- const listeners = new Set();
1440
+ const listeners = /* @__PURE__ */ new Set();
1437
1441
  function write(change) {
1438
1442
  for (const push of listeners)
1439
1443
  push(change);
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.15.21",
5
+ "version": "0.15.23-alpha.1",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "lodash": "^4.17.19",
20
20
  "nanoid": "^3.2.0",
21
- "merge-async-iterators": "^0.2.1",
22
- "@graffy/stream": "0.15.21"
21
+ "@graffy/stream": "0.15.23-alpha.1",
22
+ "merge-async-iterators": "^0.2.1"
23
23
  }
24
24
  }
@@ -1,2 +1,2 @@
1
- declare var _default: () => string;
1
+ declare var _default: (size?: number) => string;
2
2
  export default _default;