@dxos/timeframe 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d

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.
@@ -3,22 +3,13 @@ import "@dxos/node-std/globals";
3
3
  // src/timeframe.ts
4
4
  import { inspect } from "@dxos/node-std/util";
5
5
  import { equalsSymbol } from "@dxos/debug";
6
- function _define_property(obj, key, value) {
7
- if (key in obj) {
8
- Object.defineProperty(obj, key, {
9
- value,
10
- enumerable: true,
11
- configurable: true,
12
- writable: true
13
- });
14
- } else {
15
- obj[key] = value;
16
- }
17
- return obj;
18
- }
19
- var _inspect_custom = inspect.custom;
20
- var _equalsSymbol = equalsSymbol;
21
6
  var Timeframe = class _Timeframe {
7
+ _frames = /* @__PURE__ */ new Map();
8
+ constructor(frames = []) {
9
+ for (const [key, seq] of frames) {
10
+ this.set(key, seq);
11
+ }
12
+ }
22
13
  toJSON() {
23
14
  return this.frames().reduce((frames, [key, seq]) => {
24
15
  frames[key.truncate()] = seq;
@@ -83,10 +74,10 @@ var Timeframe = class _Timeframe {
83
74
  /**
84
75
  * Used by NodeJS to get textual representation of this object in `console.log`.
85
76
  */
86
- [_inspect_custom]() {
77
+ [inspect.custom]() {
87
78
  return `Timeframe${this.toString()}`;
88
79
  }
89
- [_equalsSymbol](other) {
80
+ [equalsSymbol](other) {
90
81
  if (!(other instanceof _Timeframe)) {
91
82
  return false;
92
83
  }
@@ -122,12 +113,6 @@ var Timeframe = class _Timeframe {
122
113
  }
123
114
  return result;
124
115
  }
125
- constructor(frames = []) {
126
- _define_property(this, "_frames", /* @__PURE__ */ new Map());
127
- for (const [key, seq] of frames) {
128
- this.set(key, seq);
129
- }
130
- }
131
116
  };
132
117
  export {
133
118
  Timeframe
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/timeframe.ts"],
4
4
  "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { type Equatable, equalsSymbol } from '@dxos/debug';\nimport { type PublicKey } from '@dxos/keys';\n\ntype Entry = {\n key: PublicKey;\n seq: number;\n};\n\n/**\n * A vector clock that implements ordering over a set of feed messages.\n */\nexport class Timeframe implements Equatable {\n private readonly _frames = new Map<string, Entry>();\n\n constructor(frames: [PublicKey, number][] = []) {\n for (const [key, seq] of frames) {\n this.set(key, seq);\n }\n }\n\n toJSON(): Record<string, number> {\n return this.frames().reduce((frames: Record<string, number>, [key, seq]) => {\n frames[key.truncate()] = seq;\n return frames;\n }, {});\n }\n\n toString(): string {\n return `(${this.frames()\n .map(([key, seq]) => `${key.truncate()}[${seq}]`)\n .join(', ')})`;\n }\n\n equals(object: Timeframe): boolean {\n return this.size() === object.size() && this.frames().every(([key, seq]) => object.get(key) === seq);\n }\n\n // TODO(burdon): Rename getFrame.\n get(key: PublicKey): number | undefined {\n return this._frames.get(key.toHex())?.seq;\n }\n\n // TODO(burdon): Rename setFrame.\n set(key: PublicKey, seq: number): void {\n const hex = key.toHex();\n this._frames.set(hex, { key, seq });\n }\n\n // TODO(burdon): Change to getter.\n frames(): [PublicKey, number][] {\n return Array.from(this._frames.values()).map(({ key, seq }) => [key, seq]);\n }\n\n // TODO(burdon): Change to getter.\n size(): number {\n return this._frames.size;\n }\n\n // TODO(burdon): Change to getter (empty).\n isEmpty(): boolean {\n return this.size() === 0;\n }\n\n /**\n * Returns a new timeframe with specified keys removed.\n * @param keys\n */\n withoutKeys(keys: PublicKey[]): Timeframe {\n return new Timeframe(this.frames().filter(([frameKey]) => keys.every((key) => !key.equals(frameKey))));\n }\n\n map(fn: (frame: [key: PublicKey, seq: number]) => [PublicKey, number]): Timeframe {\n return new Timeframe(this.frames().map(fn));\n }\n\n /**\n * Returns a total amount of messages represented by this timeframe.\n */\n totalMessages(): number {\n return Array.from(this._frames.values()).reduce((result, { seq }) => result + seq + 1, 0);\n }\n\n /**\n * Returns a total amount of messages that are present in this timeframe but are missing in `base`.\n */\n newMessages(base: Timeframe): number {\n return Array.from(this._frames.entries()).reduce(\n (result, [hex, { seq }]) => result + Math.max(seq - (base._frames.get(hex)?.seq ?? -1), 0),\n 0,\n );\n }\n\n /**\n * Used by NodeJS to get textual representation of this object in `console.log`.\n */\n [inspect.custom](): string {\n return `Timeframe${this.toString()}`;\n }\n\n [equalsSymbol](other: any): boolean {\n if (!(other instanceof Timeframe)) {\n return false;\n }\n\n return this.equals(other);\n }\n\n /**\n * Merges the values, updating the highest sequence numbers.\n * @param timeframes\n */\n static merge(...timeframes: Timeframe[]): Timeframe {\n const result = new Timeframe();\n for (const timeframe of timeframes) {\n for (const [hex, entry] of timeframe._frames) {\n const currentEntry = result._frames.get(hex);\n if (currentEntry === undefined || entry.seq > currentEntry.seq) {\n result._frames.set(hex, entry);\n }\n }\n }\n\n return result;\n }\n\n /**\n * Compares two timeframes and returns an array of frames from the first timeframe where the sequence number\n * is greater than the associated sequence number from the second timeframe.\n */\n static dependencies(tf1: Timeframe, tf2: Timeframe): Timeframe {\n const result = new Timeframe();\n for (const [hex, entry] of tf1._frames) {\n const otherEntry = tf2._frames.get(hex);\n if (otherEntry === undefined || otherEntry.seq < entry.seq) {\n result._frames.set(hex, entry);\n }\n }\n\n return result;\n }\n}\n"],
5
- "mappings": ";;;AAIA,SAASA,eAAe;AAExB,SAAyBC,oBAAoB;;;;;;;;;;;;;;IA+F1CC,kBAAAA,QAAQC;IAIRC,gBAAAA;AAxFI,IAAMC,YAAN,MAAMA,WAAAA;EASXC,SAAiC;AAC/B,WAAO,KAAKC,OAAM,EAAGC,OAAO,CAACD,QAAgC,CAACE,KAAKC,GAAAA,MAAI;AACrEH,aAAOE,IAAIE,SAAQ,CAAA,IAAMD;AACzB,aAAOH;IACT,GAAG,CAAC,CAAA;EACN;EAEAK,WAAmB;AACjB,WAAO,IAAI,KAAKL,OAAM,EACnBM,IAAI,CAAC,CAACJ,KAAKC,GAAAA,MAAS,GAAGD,IAAIE,SAAQ,CAAA,IAAMD,GAAA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bol", "inspect", "custom", "equalsSymbol", "Timeframe", "toJSON", "frames", "reduce", "key", "seq", "truncate", "toString", "map", "join", "equals", "object", "size", "every", "get", "_frames", "toHex", "set", "hex", "Array", "from", "values", "isEmpty", "withoutKeys", "keys", "filter", "frameKey", "fn", "totalMessages", "result", "newMessages", "base", "entries", "Math", "max", "other", "merge", "timeframes", "timeframe", "entry", "currentEntry", "undefined", "dependencies", "tf1", "tf2", "otherEntry", "Map"]
5
+ "mappings": ";;;AAIA,SAASA,eAAe;AAExB,SAAyBC,oBAAoB;AAWtC,IAAMC,YAAN,MAAMA,WAAAA;EACMC,UAAU,oBAAIC,IAAAA;EAE/B,YAAYC,SAAgC,CAAA,GAAI;AAC9C,eAAW,CAACC,KAAKC,GAAAA,KAAQF,QAAQ;AAC/B,WAAKG,IAAIF,KAAKC,GAAAA;IAChB;EACF;EAEAE,SAAiC;AAC/B,WAAO,KAAKJ,OAAM,EAAGK,OAAO,CAACL,QAAgC,CAACC,KAAKC,GAAAA,MAAI;AACrEF,aAAOC,IAAIK,SAAQ,CAAA,IAAMJ;AACzB,aAAOF;IACT,GAAG,CAAC,CAAA;EACN;EAEAO,WAAmB;AACjB,WAAO,IAAI,KAAKP,OAAM,EACnBQ,IAAI,CAAC,CAACP,KAAKC,GAAAA,MAAS,GAAGD,IAAIK,SAAQ,CAAA,IAAMJ,GAAAA,GAAM,EAC/CO,KAAK,IAAA,CAAA;EACV;EAEAC,OAAOC,QAA4B;AACjC,WAAO,KAAKC,KAAI,MAAOD,OAAOC,KAAI,KAAM,KAAKZ,OAAM,EAAGa,MAAM,CAAC,CAACZ,KAAKC,GAAAA,MAASS,OAAOG,IAAIb,GAAAA,MAASC,GAAAA;EAClG;;EAGAY,IAAIb,KAAoC;AACtC,WAAO,KAAKH,QAAQgB,IAAIb,IAAIc,MAAK,CAAA,GAAKb;EACxC;;EAGAC,IAAIF,KAAgBC,KAAmB;AACrC,UAAMc,MAAMf,IAAIc,MAAK;AACrB,SAAKjB,QAA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AASC,YAAoC;AAClD,UAAMX,SAAS,IAAI9B,WAAAA;AACnB,eAAW0C,aAAaD,YAAY;AAClC,iBAAW,CAACtB,KAAKwB,KAAAA,KAAUD,UAAUzC,SAAS;AAC5C,cAAM2C,eAAed,OAAO7B,QAAQgB,IAAIE,GAAAA;AACxC,YAAIyB,iBAAiBC,UAAaF,MAAMtC,MAAMuC,aAAavC,KAAK;AAC9DyB,iBAAO7B,QAAQK,IAAIa,KAAKwB,KAAAA;QAC1B;MACF;IACF;AAEA,WAAOb;EACT;;;;;EAMA,OAAOgB,aAAaC,KAAgBC,KAA2B;AAC7D,UAAMlB,SAAS,IAAI9B,WAAAA;AACnB,eAAW,CAACmB,KAAKwB,KAAAA,KAAUI,IAAI9C,SAAS;AACtC,YAAMgD,aAAaD,IAAI/C,QAAQgB,IAAIE,GAAAA;AACnC,UAAI8B,eAAeJ,UAAaI,WAAW5C,MAAMsC,MAAMtC,KAAK;AAC1DyB,eAAO7B,QAAQK,IAAIa,KAAKwB,KAAAA;MAC1B;IACF;AAEA,WAAOb;EACT;AACF;",
6
+ "names": ["inspect", "equalsSymbol", "Timeframe", "_frames", "Map", "frames", "key", "seq", "set", "toJSON", "reduce", "truncate", "toString", "map", "join", "equals", "object", "size", "every", "get", "toHex", "hex", "Array", "from", "values", "isEmpty", "withoutKeys", "keys", "filter", "frameKey", "fn", "totalMessages", "result", "newMessages", "base", "entries", "Math", "max", "inspect", "custom", "equalsSymbol", "other", "merge", "timeframes", "timeframe", "entry", "currentEntry", "undefined", "dependencies", "tf1", "tf2", "otherEntry"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/timeframe.ts":{"bytes":14250,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":457,"imports":[{"path":"src/timeframe.ts","kind":"import-statement","original":"./timeframe"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7212},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"exports":["Timeframe"],"entryPoint":"src/index.ts","inputs":{"src/timeframe.ts":{"bytesInOutput":3619},"src/index.ts":{"bytesInOutput":0}},"bytes":3732}}}
1
+ {"inputs":{"src/timeframe.ts":{"bytes":13804,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":457,"imports":[{"path":"src/timeframe.ts","kind":"import-statement","original":"./timeframe"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7161},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"exports":["Timeframe"],"entryPoint":"src/index.ts","inputs":{"src/timeframe.ts":{"bytesInOutput":3270},"src/index.ts":{"bytesInOutput":0}},"bytes":3383}}}
@@ -3,22 +3,13 @@ import { createRequire } from 'node:module';const require = createRequire(import
3
3
  // src/timeframe.ts
4
4
  import { inspect } from "node:util";
5
5
  import { equalsSymbol } from "@dxos/debug";
6
- function _define_property(obj, key, value) {
7
- if (key in obj) {
8
- Object.defineProperty(obj, key, {
9
- value,
10
- enumerable: true,
11
- configurable: true,
12
- writable: true
13
- });
14
- } else {
15
- obj[key] = value;
16
- }
17
- return obj;
18
- }
19
- var _inspect_custom = inspect.custom;
20
- var _equalsSymbol = equalsSymbol;
21
6
  var Timeframe = class _Timeframe {
7
+ _frames = /* @__PURE__ */ new Map();
8
+ constructor(frames = []) {
9
+ for (const [key, seq] of frames) {
10
+ this.set(key, seq);
11
+ }
12
+ }
22
13
  toJSON() {
23
14
  return this.frames().reduce((frames, [key, seq]) => {
24
15
  frames[key.truncate()] = seq;
@@ -83,10 +74,10 @@ var Timeframe = class _Timeframe {
83
74
  /**
84
75
  * Used by NodeJS to get textual representation of this object in `console.log`.
85
76
  */
86
- [_inspect_custom]() {
77
+ [inspect.custom]() {
87
78
  return `Timeframe${this.toString()}`;
88
79
  }
89
- [_equalsSymbol](other) {
80
+ [equalsSymbol](other) {
90
81
  if (!(other instanceof _Timeframe)) {
91
82
  return false;
92
83
  }
@@ -122,12 +113,6 @@ var Timeframe = class _Timeframe {
122
113
  }
123
114
  return result;
124
115
  }
125
- constructor(frames = []) {
126
- _define_property(this, "_frames", /* @__PURE__ */ new Map());
127
- for (const [key, seq] of frames) {
128
- this.set(key, seq);
129
- }
130
- }
131
116
  };
132
117
  export {
133
118
  Timeframe
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/timeframe.ts"],
4
4
  "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { type Equatable, equalsSymbol } from '@dxos/debug';\nimport { type PublicKey } from '@dxos/keys';\n\ntype Entry = {\n key: PublicKey;\n seq: number;\n};\n\n/**\n * A vector clock that implements ordering over a set of feed messages.\n */\nexport class Timeframe implements Equatable {\n private readonly _frames = new Map<string, Entry>();\n\n constructor(frames: [PublicKey, number][] = []) {\n for (const [key, seq] of frames) {\n this.set(key, seq);\n }\n }\n\n toJSON(): Record<string, number> {\n return this.frames().reduce((frames: Record<string, number>, [key, seq]) => {\n frames[key.truncate()] = seq;\n return frames;\n }, {});\n }\n\n toString(): string {\n return `(${this.frames()\n .map(([key, seq]) => `${key.truncate()}[${seq}]`)\n .join(', ')})`;\n }\n\n equals(object: Timeframe): boolean {\n return this.size() === object.size() && this.frames().every(([key, seq]) => object.get(key) === seq);\n }\n\n // TODO(burdon): Rename getFrame.\n get(key: PublicKey): number | undefined {\n return this._frames.get(key.toHex())?.seq;\n }\n\n // TODO(burdon): Rename setFrame.\n set(key: PublicKey, seq: number): void {\n const hex = key.toHex();\n this._frames.set(hex, { key, seq });\n }\n\n // TODO(burdon): Change to getter.\n frames(): [PublicKey, number][] {\n return Array.from(this._frames.values()).map(({ key, seq }) => [key, seq]);\n }\n\n // TODO(burdon): Change to getter.\n size(): number {\n return this._frames.size;\n }\n\n // TODO(burdon): Change to getter (empty).\n isEmpty(): boolean {\n return this.size() === 0;\n }\n\n /**\n * Returns a new timeframe with specified keys removed.\n * @param keys\n */\n withoutKeys(keys: PublicKey[]): Timeframe {\n return new Timeframe(this.frames().filter(([frameKey]) => keys.every((key) => !key.equals(frameKey))));\n }\n\n map(fn: (frame: [key: PublicKey, seq: number]) => [PublicKey, number]): Timeframe {\n return new Timeframe(this.frames().map(fn));\n }\n\n /**\n * Returns a total amount of messages represented by this timeframe.\n */\n totalMessages(): number {\n return Array.from(this._frames.values()).reduce((result, { seq }) => result + seq + 1, 0);\n }\n\n /**\n * Returns a total amount of messages that are present in this timeframe but are missing in `base`.\n */\n newMessages(base: Timeframe): number {\n return Array.from(this._frames.entries()).reduce(\n (result, [hex, { seq }]) => result + Math.max(seq - (base._frames.get(hex)?.seq ?? -1), 0),\n 0,\n );\n }\n\n /**\n * Used by NodeJS to get textual representation of this object in `console.log`.\n */\n [inspect.custom](): string {\n return `Timeframe${this.toString()}`;\n }\n\n [equalsSymbol](other: any): boolean {\n if (!(other instanceof Timeframe)) {\n return false;\n }\n\n return this.equals(other);\n }\n\n /**\n * Merges the values, updating the highest sequence numbers.\n * @param timeframes\n */\n static merge(...timeframes: Timeframe[]): Timeframe {\n const result = new Timeframe();\n for (const timeframe of timeframes) {\n for (const [hex, entry] of timeframe._frames) {\n const currentEntry = result._frames.get(hex);\n if (currentEntry === undefined || entry.seq > currentEntry.seq) {\n result._frames.set(hex, entry);\n }\n }\n }\n\n return result;\n }\n\n /**\n * Compares two timeframes and returns an array of frames from the first timeframe where the sequence number\n * is greater than the associated sequence number from the second timeframe.\n */\n static dependencies(tf1: Timeframe, tf2: Timeframe): Timeframe {\n const result = new Timeframe();\n for (const [hex, entry] of tf1._frames) {\n const otherEntry = tf2._frames.get(hex);\n if (otherEntry === undefined || otherEntry.seq < entry.seq) {\n result._frames.set(hex, entry);\n }\n }\n\n return result;\n }\n}\n"],
5
- "mappings": ";;;AAIA,SAASA,eAAe;AAExB,SAAyBC,oBAAoB;;;;;;;;;;;;;;IA+F1CC,kBAAAA,QAAQC;IAIRC,gBAAAA;AAxFI,IAAMC,YAAN,MAAMA,WAAAA;EASXC,SAAiC;AAC/B,WAAO,KAAKC,OAAM,EAAGC,OAAO,CAACD,QAAgC,CAACE,KAAKC,GAAAA,MAAI;AACrEH,aAAOE,IAAIE,SAAQ,CAAA,IAAMD;AACzB,aAAOH;IACT,GAAG,CAAC,CAAA;EACN;EAEAK,WAAmB;AACjB,WAAO,IAAI,KAAKL,OAAM,EACnBM,IAAI,CAAC,CAACJ,KAAKC,GAAAA,MAAS,GAAGD,IAAIE,SAAQ,CAAA,IAAMD,GAAAA,GAAM,EAC/CI,KAAK,IAAA,CAAA;EACV;EAEAC,OAAOC,QAA4B;AACjC,WAAO,KAAKC,KAAI,MAAOD,OAAOC,KAAI,KAAM,KAAKV,OAAM,EAAGW,MAAM,CAAC,CAACT,KAAKC,GAAAA,MAASM,OAAOG,IAAIV,GAAAA,MAASC,GAAAA;EAClG;;EAGAS,IAAIV,KAAoC;AACtC,WAAO,KAAKW,QAAQD,IAAIV,IAAIY,MAAK,CAAA,GAAKX;EACxC;;EAGAY,IAAIb,KAAgBC,KAAmB;AACrC,UAAMa,MAAMd,IAAIY,MAAK;AACrB,SAAKD,QAAQE,IAAIC,KAAK;MAAEd;MAAKC;IAAI,CAAA;EACnC;;EAGAH,SAAgC;AAC9B,WAAOiB,MAAMC,KAAK,KAAKL,QAAQM,OAAM,CAAA,EAAIb,IAAI,CAAC,EAAEJ,KAAKC,IAAG,MAAO;MAACD;MAAKC;KAAI;EAC3E;;EAGAO,OAAe;AACb,WAAO,KAAKG,QAAQH;EACtB;;EAGAU,UAAmB;AACjB,WAAO,KAAKV,KAAI,MAAO;EACzB;;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EA,WAAOV;EACT;;;;;EAMA,OAAOa,aAAaC,KAAgBC,KAA2B;AAC7D,UAAMf,SAAS,IAAI7B,WAAAA;AACnB,eAAW,CAACkB,KAAKqB,KAAAA,KAAUI,IAAI5B,SAAS;AACtC,YAAM8B,aAAaD,IAAI7B,QAAQD,IAAII,GAAAA;AACnC,UAAI2B,eAAeJ,UAAaI,WAAWxC,MAAMkC,MAAMlC,KAAK;AAC1DwB,eAAOd,QAAQE,IAAIC,KAAKqB,KAAAA;MAC1B;IACF;AAEA,WAAOV;EACT;EA7HA,YAAY3B,SAAgC,CAAA,GAAI;AAFhD,qBAAA,MAAiBa,WAAU,oBAAI+B,IAAAA,CAAAA;AAG7B,eAAW,CAAC1C,KAAKC,GAAAA,KAAQH,QAAQ;AAC/B,WAAKe,IAAIb,KAAKC,GAAAA;IAChB;EACF;AA0HF;",
6
- "names": ["inspect", "equalsSymbol", "inspect", "custom", "equalsSymbol", "Timeframe", "toJSON", "frames", "reduce", "key", "seq", "truncate", "toString", "map", "join", "equals", "object", "size", "every", "get", "_frames", "toHex", "set", "hex", "Array", "from", "values", "isEmpty", "withoutKeys", "keys", "filter", "frameKey", "fn", "totalMessages", "result", "newMessages", "base", "entries", "Math", "max", "other", "merge", "timeframes", "timeframe", "entry", "currentEntry", "undefined", "dependencies", "tf1", "tf2", "otherEntry", "Map"]
5
+ "mappings": ";;;AAIA,SAASA,eAAe;AAExB,SAAyBC,oBAAoB;AAWtC,IAAMC,YAAN,MAAMA,WAAAA;EACMC,UAAU,oBAAIC,IAAAA;EAE/B,YAAYC,SAAgC,CAAA,GAAI;AAC9C,eAAW,CAACC,KAAKC,GAAAA,KAAQF,QAAQ;AAC/B,WAAKG,IAAIF,KAAKC,GAAAA;IAChB;EACF;EAEAE,SAAiC;AAC/B,WAAO,KAAKJ,OAAM,EAAGK,OAAO,CAACL,QAAgC,CAACC,KAAKC,GAAAA,MAAI;AACrEF,aAAOC,IAAIK,SAAQ,CAAA,IAAMJ;AACzB,aA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inspect", "equalsSymbol", "Timeframe", "_frames", "Map", "frames", "key", "seq", "set", "toJSON", "reduce", "truncate", "toString", "map", "join", "equals", "object", "size", "every", "get", "toHex", "hex", "Array", "from", "values", "isEmpty", "withoutKeys", "keys", "filter", "frameKey", "fn", "totalMessages", "result", "newMessages", "base", "entries", "Math", "max", "inspect", "custom", "equalsSymbol", "other", "merge", "timeframes", "timeframe", "entry", "currentEntry", "undefined", "dependencies", "tf1", "tf2", "otherEntry"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/timeframe.ts":{"bytes":14250,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":457,"imports":[{"path":"src/timeframe.ts","kind":"import-statement","original":"./timeframe"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7212},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"exports":["Timeframe"],"entryPoint":"src/index.ts","inputs":{"src/timeframe.ts":{"bytesInOutput":3609},"src/index.ts":{"bytesInOutput":0}},"bytes":3781}}}
1
+ {"inputs":{"src/timeframe.ts":{"bytes":13804,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":457,"imports":[{"path":"src/timeframe.ts","kind":"import-statement","original":"./timeframe"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7161},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"exports":["Timeframe"],"entryPoint":"src/index.ts","inputs":{"src/timeframe.ts":{"bytesInOutput":3260},"src/index.ts":{"bytesInOutput":0}},"bytes":3432}}}