@wovin/core 0.1.4 → 0.1.6

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.
@@ -46,7 +46,7 @@ import {
46
46
  variableNameWithoutQuestionmark,
47
47
  withPvFrom,
48
48
  withTs
49
- } from "./chunk-S4ODHUJZ.min.js";
49
+ } from "./chunk-AOM4CWTC.min.js";
50
50
  import "./chunk-KEHU7HGZ.min.js";
51
51
  import "./chunk-HYMC7W6S.min.js";
52
52
  import "./chunk-PHITDXZT.min.js";
@@ -3,7 +3,7 @@ import {
3
3
  areCidsEqual,
4
4
  decode,
5
5
  g
6
- } from "./chunk-S4ODHUJZ.min.js";
6
+ } from "./chunk-AOM4CWTC.min.js";
7
7
 
8
8
  // src/ipfs/fetch-snapshot-chain.ts
9
9
  var { WARN, LOG, DEBUG, VERBOSE, ERROR } = g.setup(g.INFO);
@@ -67,4 +67,4 @@ function createMemoryBlockStore() {
67
67
  export {
68
68
  fetchSnapshotChainUntil
69
69
  };
70
- //# sourceMappingURL=chunk-MGJYJPOD.min.js.map
70
+ //# sourceMappingURL=chunk-4APURYN7.min.js.map
@@ -10877,6 +10877,19 @@ var WriteableThread = class extends Thread {
10877
10877
  DEBUG8(`[WriteableThread.insert] insertRaw completed`);
10878
10878
  return result;
10879
10879
  }
10880
+ /**
10881
+ * Insert only applogs not already in this thread.
10882
+ * @param byRef If true, compares by reference; if false, compares by CID (default)
10883
+ * @returns The applogs that were actually inserted
10884
+ */
10885
+ insertMissing(appLogsToInsert, byRef = false) {
10886
+ const missing = appLogsToInsert.filter((log) => !this.hasApplog(log, byRef));
10887
+ if (missing.length === 0) {
10888
+ VERBOSE8(`[insertMissing] no missing applogs`);
10889
+ return [];
10890
+ }
10891
+ return this.insertRaw(missing) ?? [];
10892
+ }
10880
10893
  /**
10881
10894
  * @param appLogsToInsert It needs to be mutable because it will be sorted
10882
10895
  * (and if you need to clone it, so do it when you need to) - this is weird as TS is slathering type safety onto ducks
@@ -11056,6 +11069,16 @@ function holdTillFirstWrite(thread, applogsToHold, opts) {
11056
11069
  function getAgents(thread) {
11057
11070
  return uniq_default(thread.map((l2) => l2.ag));
11058
11071
  }
11072
+ var excludeApplogsContainedIn = (applogs, exclude) => {
11073
+ const excludeCids = exclude instanceof Set ? new Set([...exclude].map((c) => c.toString())) : exclude instanceof Thread ? new Set(exclude.applogsCids) : new Set(exclude.map((a) => a.cid));
11074
+ return applogs.filter((applog) => {
11075
+ if (!applog.cid) {
11076
+ ERROR9(`applog with missing CID`, applog);
11077
+ throw new Error(`applog with missing CID`);
11078
+ }
11079
+ return !excludeCids.has(applog.cid);
11080
+ });
11081
+ };
11059
11082
 
11060
11083
  export {
11061
11084
  g,
@@ -11150,6 +11173,7 @@ export {
11150
11173
  debounceWrites,
11151
11174
  holdTillFirstWrite,
11152
11175
  getAgents,
11176
+ excludeApplogsContainedIn,
11153
11177
  ensureTsPvAndFinalizeApplogs,
11154
11178
  ensureTsPvAndFinalizeApplog,
11155
11179
  finalizeApplogForInsert,
@@ -11176,4 +11200,4 @@ lodash-es/lodash.js:
11176
11200
  @noble/hashes/utils.js:
11177
11201
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
11178
11202
  */
11179
- //# sourceMappingURL=chunk-S4ODHUJZ.min.js.map
11203
+ //# sourceMappingURL=chunk-AOM4CWTC.min.js.map