@peerbit/log 3.0.34 → 4.0.0-55cebfe

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.
Files changed (133) hide show
  1. package/dist/benchmark/append.d.ts +2 -0
  2. package/dist/benchmark/append.d.ts.map +1 -0
  3. package/dist/benchmark/append.js +40 -0
  4. package/dist/benchmark/append.js.map +1 -0
  5. package/dist/benchmark/memory/index.d.ts +2 -0
  6. package/dist/benchmark/memory/index.d.ts.map +1 -0
  7. package/dist/benchmark/memory/index.js +122 -0
  8. package/dist/benchmark/memory/index.js.map +1 -0
  9. package/dist/benchmark/memory/insert.d.ts +2 -0
  10. package/dist/benchmark/memory/insert.d.ts.map +1 -0
  11. package/dist/benchmark/memory/insert.js +59 -0
  12. package/dist/benchmark/memory/insert.js.map +1 -0
  13. package/dist/benchmark/memory/utils.d.ts +13 -0
  14. package/dist/benchmark/memory/utils.d.ts.map +1 -0
  15. package/dist/benchmark/memory/utils.js +2 -0
  16. package/dist/benchmark/memory/utils.js.map +1 -0
  17. package/dist/benchmark/payload.d.ts +2 -0
  18. package/dist/benchmark/payload.d.ts.map +1 -0
  19. package/{lib/esm/__benchmark__/index.js → dist/benchmark/payload.js} +20 -22
  20. package/dist/benchmark/payload.js.map +1 -0
  21. package/dist/src/change.d.ts +6 -0
  22. package/dist/src/change.d.ts.map +1 -0
  23. package/{lib/esm → dist/src}/clock.d.ts +3 -26
  24. package/dist/src/clock.d.ts.map +1 -0
  25. package/{lib/esm → dist/src}/clock.js +30 -39
  26. package/dist/src/clock.js.map +1 -0
  27. package/{lib/esm → dist/src}/difference.d.ts +1 -0
  28. package/dist/src/difference.d.ts.map +1 -0
  29. package/{lib/esm → dist/src}/encoding.d.ts +2 -1
  30. package/dist/src/encoding.d.ts.map +1 -0
  31. package/{lib/esm → dist/src}/encoding.js +2 -2
  32. package/{lib/esm → dist/src}/encoding.js.map +1 -1
  33. package/dist/src/entry-index.d.ts +78 -0
  34. package/dist/src/entry-index.d.ts.map +1 -0
  35. package/dist/src/entry-index.js +316 -0
  36. package/dist/src/entry-index.js.map +1 -0
  37. package/{lib/esm → dist/src}/entry-with-refs.d.ts +2 -1
  38. package/dist/src/entry-with-refs.d.ts.map +1 -0
  39. package/{lib/esm → dist/src}/entry.d.ts +22 -18
  40. package/dist/src/entry.d.ts.map +1 -0
  41. package/{lib/esm → dist/src}/entry.js +69 -42
  42. package/dist/src/entry.js.map +1 -0
  43. package/{lib/esm → dist/src}/find-uniques.d.ts +1 -0
  44. package/dist/src/find-uniques.d.ts.map +1 -0
  45. package/{lib/esm → dist/src}/heads-cache.d.ts +4 -3
  46. package/dist/src/heads-cache.d.ts.map +1 -0
  47. package/{lib/esm → dist/src}/heads-cache.js +9 -10
  48. package/dist/src/heads-cache.js.map +1 -0
  49. package/{lib/esm → dist/src}/index.d.ts +1 -0
  50. package/dist/src/index.d.ts.map +1 -0
  51. package/{lib/esm → dist/src}/log-errors.d.ts +1 -0
  52. package/dist/src/log-errors.d.ts.map +1 -0
  53. package/dist/src/log-sorting.d.ts +35 -0
  54. package/dist/src/log-sorting.d.ts.map +1 -0
  55. package/dist/src/log-sorting.js +105 -0
  56. package/dist/src/log-sorting.js.map +1 -0
  57. package/{lib/esm → dist/src}/log.d.ts +78 -56
  58. package/dist/src/log.d.ts.map +1 -0
  59. package/{lib/esm → dist/src}/log.js +355 -465
  60. package/dist/src/log.js.map +1 -0
  61. package/{lib/esm → dist/src}/logger.d.ts +1 -0
  62. package/dist/src/logger.d.ts.map +1 -0
  63. package/{lib/esm → dist/src}/logger.js.map +1 -1
  64. package/{lib/esm → dist/src}/snapshot.d.ts +5 -4
  65. package/dist/src/snapshot.d.ts.map +1 -0
  66. package/{lib/esm → dist/src}/snapshot.js +10 -10
  67. package/dist/src/snapshot.js.map +1 -0
  68. package/{lib/esm → dist/src}/trim.d.ts +11 -9
  69. package/dist/src/trim.d.ts.map +1 -0
  70. package/{lib/esm → dist/src}/trim.js +46 -35
  71. package/dist/src/trim.js.map +1 -0
  72. package/dist/src/utils.d.ts +4 -0
  73. package/dist/src/utils.d.ts.map +1 -0
  74. package/dist/src/utils.js +12 -0
  75. package/dist/src/utils.js.map +1 -0
  76. package/package.json +104 -78
  77. package/src/change.ts +3 -2
  78. package/src/clock.ts +22 -22
  79. package/src/encoding.ts +4 -4
  80. package/src/entry-index.ts +451 -52
  81. package/src/entry-with-refs.ts +1 -1
  82. package/src/entry.ts +95 -81
  83. package/src/heads-cache.ts +33 -29
  84. package/src/log-sorting.ts +116 -94
  85. package/src/log.ts +482 -571
  86. package/src/logger.ts +1 -0
  87. package/src/snapshot.ts +15 -17
  88. package/src/trim.ts +81 -50
  89. package/src/utils.ts +10 -0
  90. package/lib/esm/__benchmark__/index.d.ts +0 -1
  91. package/lib/esm/__benchmark__/index.js.map +0 -1
  92. package/lib/esm/change.d.ts +0 -5
  93. package/lib/esm/clock.js.map +0 -1
  94. package/lib/esm/entry-index.d.ts +0 -24
  95. package/lib/esm/entry-index.js +0 -74
  96. package/lib/esm/entry-index.js.map +0 -1
  97. package/lib/esm/entry.js.map +0 -1
  98. package/lib/esm/heads-cache.js.map +0 -1
  99. package/lib/esm/heads.d.ts +0 -69
  100. package/lib/esm/heads.js +0 -157
  101. package/lib/esm/heads.js.map +0 -1
  102. package/lib/esm/log-sorting.d.ts +0 -44
  103. package/lib/esm/log-sorting.js +0 -86
  104. package/lib/esm/log-sorting.js.map +0 -1
  105. package/lib/esm/log.js.map +0 -1
  106. package/lib/esm/snapshot.js.map +0 -1
  107. package/lib/esm/trim.js.map +0 -1
  108. package/lib/esm/types.d.ts +0 -6
  109. package/lib/esm/types.js +0 -23
  110. package/lib/esm/types.js.map +0 -1
  111. package/lib/esm/utils.d.ts +0 -2
  112. package/lib/esm/utils.js +0 -3
  113. package/lib/esm/utils.js.map +0 -1
  114. package/lib/esm/values.d.ts +0 -26
  115. package/lib/esm/values.js +0 -131
  116. package/lib/esm/values.js.map +0 -1
  117. package/src/__benchmark__/index.ts +0 -130
  118. package/src/heads.ts +0 -233
  119. package/src/types.ts +0 -12
  120. package/src/values.ts +0 -174
  121. /package/{lib/esm → dist/src}/change.js +0 -0
  122. /package/{lib/esm → dist/src}/change.js.map +0 -0
  123. /package/{lib/esm → dist/src}/difference.js +0 -0
  124. /package/{lib/esm → dist/src}/difference.js.map +0 -0
  125. /package/{lib/esm → dist/src}/entry-with-refs.js +0 -0
  126. /package/{lib/esm → dist/src}/entry-with-refs.js.map +0 -0
  127. /package/{lib/esm → dist/src}/find-uniques.js +0 -0
  128. /package/{lib/esm → dist/src}/find-uniques.js.map +0 -0
  129. /package/{lib/esm → dist/src}/index.js +0 -0
  130. /package/{lib/esm → dist/src}/index.js.map +0 -0
  131. /package/{lib/esm → dist/src}/log-errors.js +0 -0
  132. /package/{lib/esm → dist/src}/log-errors.js.map +0 -0
  133. /package/{lib/esm → dist/src}/logger.js +0 -0
@@ -1,130 +0,0 @@
1
- import B from "benchmark";
2
- import { field, option, serialize, variant } from "@dao-xyz/borsh";
3
- import { v4 as uuid } from "uuid";
4
- import crypto from "crypto";
5
- import { Log } from "../log.js";
6
- import { AnyBlockStore } from "@peerbit/blocks";
7
- import { Ed25519Keypair } from "@peerbit/crypto";
8
- import { BORSH_ENCODING } from "../encoding.js";
9
- import { Entry } from "../entry.js";
10
-
11
- // Run with "node --loader ts-node/esm ./src/__benchmark__/index.ts"
12
-
13
- @variant("document")
14
- class Document {
15
- @field({ type: "string" })
16
- id: string;
17
-
18
- @field({ type: option("string") })
19
- name?: string;
20
-
21
- @field({ type: option("u64") })
22
- number?: bigint;
23
-
24
- @field({ type: Uint8Array })
25
- bytes: Uint8Array;
26
-
27
- constructor(opts: Document) {
28
- if (opts) {
29
- this.id = opts.id;
30
- this.name = opts.name;
31
- this.number = opts.number;
32
- this.bytes = opts.bytes;
33
- }
34
- }
35
- }
36
- let log: Log<Document>;
37
- let store: AnyBlockStore;
38
- const key = await Ed25519Keypair.create();
39
-
40
- const reset = async () => {
41
- log = new Log<Document>();
42
- store = new AnyBlockStore();
43
- await log.open(store, key, { encoding: BORSH_ENCODING(Document) });
44
- };
45
- await reset();
46
-
47
- class NestedEntry {
48
- @field({ type: Entry })
49
- entry: Entry<any>;
50
-
51
- constructor(entry: Entry<any>) {
52
- this.entry = entry;
53
- }
54
- }
55
- const suite = new B.Suite({ delay: 100 });
56
- suite
57
- .add("1e3", {
58
- fn: async (deferred) => {
59
- const doc = new Document({
60
- id: uuid(),
61
- name: "hello",
62
- number: 1n,
63
- bytes: crypto.randomBytes(1e3)
64
- });
65
- await log.append(doc);
66
-
67
- deferred.resolve();
68
- },
69
- defer: true
70
- })
71
- .add("1e4", {
72
- fn: async (deferred) => {
73
- const doc = new Document({
74
- id: uuid(),
75
- name: "hello",
76
- number: 1n,
77
- bytes: crypto.randomBytes(1e4)
78
- });
79
- await log.append(doc);
80
-
81
- deferred.resolve();
82
- },
83
- defer: true
84
- })
85
- .add("1e5", {
86
- fn: async (deferred) => {
87
- const doc = new Document({
88
- id: uuid(),
89
- name: "hello",
90
- number: 1n,
91
- bytes: crypto.randomBytes(1e5)
92
- });
93
- const entry = await log.append(doc);
94
- serialize(new NestedEntry(entry.entry));
95
- serialize(new NestedEntry(entry.entry));
96
- serialize(new NestedEntry(entry.entry));
97
- serialize(new NestedEntry(entry.entry));
98
- serialize(new NestedEntry(entry.entry));
99
- serialize(new NestedEntry(entry.entry));
100
- serialize(new NestedEntry(entry.entry));
101
- serialize(new NestedEntry(entry.entry));
102
- serialize(new NestedEntry(entry.entry));
103
- serialize(new NestedEntry(entry.entry));
104
-
105
- deferred.resolve();
106
- },
107
- defer: true
108
- })
109
- .add("1e6", {
110
- fn: async (deferred) => {
111
- const doc = new Document({
112
- id: uuid(),
113
- name: "hello",
114
- number: 1n,
115
- bytes: crypto.randomBytes(1e5)
116
- });
117
- await log.append(doc);
118
-
119
- deferred.resolve();
120
- },
121
- defer: true
122
- })
123
- .on("cycle", async (event: any) => {
124
- console.log(String(event.target));
125
- await reset();
126
- })
127
- .on("error", (err) => {
128
- throw err;
129
- })
130
- .run();
package/src/heads.ts DELETED
@@ -1,233 +0,0 @@
1
- import { Entry } from "./entry.js";
2
- import { AnyStore } from "@peerbit/any-store";
3
- import { HeadsCache } from "./heads-cache.js";
4
- import { Blocks } from "@peerbit/blocks-interface";
5
- import { Keychain } from "@peerbit/keychain";
6
- import { Encoding } from "./encoding.js";
7
- import { Values } from "./values.js";
8
- import { logger } from "./logger.js";
9
- import { EntryIndex } from "./entry-index.js";
10
-
11
- export type CacheUpdateOptions = {
12
- cache?: { update?: false; reset?: false } | { update: true; reset?: boolean };
13
- };
14
-
15
- interface Log<T> {
16
- blocks: Blocks;
17
- keychain?: Keychain;
18
- memory?: AnyStore;
19
- encoding: Encoding<any>;
20
- entryIndex: EntryIndex<T>;
21
- values: Values<T>;
22
- }
23
- export class HeadsIndex<T> {
24
- private _id: Uint8Array;
25
- private _index: Set<string> = new Set();
26
- private _gids: Map<string, Map<string, Entry<T>>>; // gid -> hash -> entry
27
- private _headsCache: HeadsCache<T> | undefined;
28
- private _config: Log<T>;
29
- private _onGidRemoved?: (gid: string[]) => Promise<void> | void;
30
- constructor(id: Uint8Array) {
31
- this._gids = new Map();
32
- this._id = id;
33
- }
34
-
35
- async init(
36
- log: Log<T>,
37
- options: {
38
- entries?: Entry<T>[];
39
- onGidRemoved?: (gid: string[]) => Promise<void> | void;
40
- } = {}
41
- ) {
42
- this._config = log;
43
- this._onGidRemoved = options.onGidRemoved;
44
- await this.reset(options?.entries || []);
45
- if (log.memory) {
46
- this._headsCache = new HeadsCache(this);
47
- return this._headsCache.init(await log.memory.sublevel("heads"));
48
- }
49
- }
50
-
51
- async load(
52
- options?: {
53
- timeout?: number;
54
- replicate?: boolean;
55
- reload?: boolean;
56
- ignoreMissing?: boolean;
57
- } & CacheUpdateOptions
58
- ): Promise<Entry<T>[] | undefined> {
59
- if (!this._headsCache || (this._headsCache.loaded && !options?.reload)) {
60
- return;
61
- }
62
-
63
- // TODO make below into a promise that concurrenct caklls can wait on?
64
- const heads = await this._headsCache?.load();
65
- if (!heads) {
66
- return;
67
- }
68
- const entries = await Promise.all(
69
- heads.map(async (x) => {
70
- const entry = await this._config.entryIndex.get(x, { load: true });
71
- if (!entry) {
72
- if (options?.ignoreMissing) {
73
- logger.error("Failed to load entry from head with hash: " + x);
74
- return;
75
- } else {
76
- throw new Error("Failed to load entry from head with hash: " + x);
77
- }
78
- }
79
- await entry.getMeta(); // TODO types,decrypt gid
80
- return entry;
81
- })
82
- );
83
- const filtered = entries.filter((x): x is Entry<any> => !!x);
84
- await this.reset(filtered);
85
- return filtered;
86
- }
87
-
88
- get headsCache(): HeadsCache<T> | undefined {
89
- return this._headsCache;
90
- }
91
-
92
- close() {
93
- return this._headsCache?.close();
94
- }
95
-
96
- drop() {
97
- return this._headsCache?.drop();
98
- }
99
-
100
- get id(): Uint8Array {
101
- return this._id;
102
- }
103
-
104
- get index() {
105
- return this._index;
106
- }
107
-
108
- get gids(): Map<string, Map<string, Entry<T>>> {
109
- return this._gids;
110
- }
111
-
112
- get size() {
113
- return this._index.size;
114
- }
115
-
116
- async reset(
117
- entries: Entry<T>[],
118
- options: CacheUpdateOptions = { cache: { reset: true, update: true } }
119
- ) {
120
- this._index.clear();
121
- const gidKeys = [...this._gids.keys()];
122
-
123
- this._gids = new Map();
124
- if (entries?.length > 0) {
125
- await this.putAll(entries, options); // reset cache = true
126
- }
127
-
128
- if (gidKeys.length > 0) {
129
- this._onGidRemoved?.(gidKeys);
130
- }
131
- }
132
-
133
- has(cid: string) {
134
- return this._index.has(cid);
135
- }
136
-
137
- async put(entry: Entry<T>, options?: CacheUpdateOptions) {
138
- await this._putOne(entry);
139
- if (!options?.cache || options?.cache?.update) {
140
- await this._headsCache?.queue({ added: [entry] }, options?.cache?.reset);
141
- }
142
- }
143
-
144
- async putAll(entries: Entry<T>[], options?: CacheUpdateOptions) {
145
- await this._putAll(entries);
146
- if (!options?.cache || options?.cache?.update) {
147
- await this._headsCache?.queue({ added: entries }, options?.cache?.reset);
148
- }
149
- }
150
-
151
- async resetHeadsCache() {
152
- await this._headsCache?.queue(
153
- { added: [...this._index], removed: [] },
154
- true
155
- );
156
- }
157
- async updateHeadsCache(
158
- change: {
159
- added?: (Entry<T> | string)[];
160
- removed?: (Entry<T> | string)[];
161
- } = {},
162
- reset?: boolean
163
- ) {
164
- await this._headsCache?.queue(change, reset);
165
- }
166
-
167
- private async _putOne(entry: Entry<T>) {
168
- if (!entry.hash) {
169
- throw new Error("Missing hash");
170
- }
171
- if (this._index.has(entry.hash)) {
172
- return;
173
- }
174
-
175
- this._index.add(entry.hash);
176
- const map = this._gids.get(entry.meta.gid);
177
- if (!map) {
178
- const newMap = new Map();
179
- this._gids.set(entry.meta.gid, newMap);
180
- newMap.set(entry.hash, entry);
181
- } else {
182
- map.set(entry.hash, entry);
183
- }
184
-
185
- for (const next of entry.next) {
186
- const indexedEntry = this._config.entryIndex.getShallow(next);
187
- if (indexedEntry) {
188
- await this.del(indexedEntry, { cache: { update: false } }); // we dont update cache here because the put will update the cache that is calling _putOne
189
- }
190
- }
191
- }
192
-
193
- private async _putAll(entries: Entry<T>[]) {
194
- for (const entry of entries) {
195
- await this._putOne(entry);
196
- }
197
- }
198
-
199
- async del(
200
- entry: { hash: string; meta: { gid: string } },
201
- options?: CacheUpdateOptions
202
- ): Promise<boolean> {
203
- const wasHead = this._index.delete(entry.hash);
204
- if (!wasHead) {
205
- return false;
206
- }
207
- let removedGids: Set<string> | undefined = undefined;
208
- const map = this._gids.get(entry.meta.gid)!;
209
- map.delete(entry.hash);
210
- if (map.size <= 0) {
211
- this._gids.delete(entry.meta.gid);
212
- (removedGids || (removedGids = new Set<string>())).add(entry.meta.gid);
213
- }
214
-
215
- if (!entry.hash) {
216
- throw new Error("Missing hash");
217
- }
218
-
219
- if (removedGids) {
220
- await this._onGidRemoved?.([...removedGids]);
221
- }
222
-
223
- if (wasHead && !(options?.cache || options?.cache?.update)) {
224
- await this._headsCache?.queue(
225
- { removed: [entry.hash] },
226
- options?.cache?.reset
227
- );
228
- }
229
-
230
- return wasHead;
231
- // this._headsCache = undefined; // TODO do smarter things here, only remove the element needed (?)
232
- }
233
- }
package/src/types.ts DELETED
@@ -1,12 +0,0 @@
1
- import { field, vec } from "@dao-xyz/borsh";
2
-
3
- export class StringArray {
4
- @field({ type: vec("string") })
5
- arr: string[];
6
-
7
- constructor(properties?: { arr: string[] }) {
8
- if (properties) {
9
- this.arr = properties.arr;
10
- }
11
- }
12
- }
package/src/values.ts DELETED
@@ -1,174 +0,0 @@
1
- import { Entry, ShallowEntry } from "./entry";
2
- import { ISortFunction } from "./log-sorting";
3
- import yallist from "yallist";
4
- import { EntryIndex } from "./entry-index";
5
-
6
- export type EntryNode = yallist.Node<string>;
7
-
8
- export class Values<T> {
9
- /**
10
- * Keep track of sorted elements in descending sort order (i.e. newest elements)
11
- */
12
- private _values: yallist<string>;
13
- private _sortFn: ISortFunction;
14
- private _byteLength: number;
15
- private _entryIndex: EntryIndex<T>;
16
-
17
- constructor(
18
- entryIndex: EntryIndex<T>,
19
- sortFn: ISortFunction,
20
- entries: Entry<T>[] = []
21
- ) {
22
- this._values = yallist.create(
23
- entries
24
- .slice()
25
- .sort(sortFn)
26
- .reverse()
27
- .map((x) => {
28
- if (!x.hash) throw new Error("Unexpected");
29
- return x.hash; /* {
30
- hash: x.hash,
31
- byteLength: x._payload.byteLength,
32
- meta: {
33
- gids: x.gids,
34
- gid: x.gid,
35
- data: x.meta.data,
36
- },
37
- }; */
38
- })
39
- );
40
- this._byteLength = 0;
41
- entries.forEach((entry) => {
42
- this._byteLength += entry._payload.byteLength;
43
- });
44
- this._sortFn = sortFn;
45
- this._entryIndex = entryIndex;
46
- }
47
-
48
- toArray(): Promise<Entry<T>[]> {
49
- return Promise.all(
50
- this._values.toArrayReverse().map((x) => this._entryIndex.get(x))
51
- ).then((arr) => arr.filter((x) => !!x)) as Promise<Entry<T>[]>; // we do reverse because we assume the log is only meaningful if we read it from start to end
52
- }
53
-
54
- get head() {
55
- return this._values.head;
56
- }
57
- get tail() {
58
- return this._values.tail;
59
- }
60
- get length() {
61
- return this._values.length;
62
- }
63
-
64
- get entryIndex(): EntryIndex<T> {
65
- return this._entryIndex;
66
- }
67
- put(value: Entry<T>) {
68
- return this._put(value);
69
- }
70
- _put(value: Entry<T>) {
71
- // assume we want to insert at head (or somehere close)
72
- let walker = this._values.head;
73
- let last: EntryNode | undefined = undefined;
74
- while (walker) {
75
- const walkerValue = this._entryIndex.getShallow(walker.value);
76
- if (!walkerValue) {
77
- throw new Error("Missing walker value");
78
- }
79
- if (walkerValue.hash === value.hash) {
80
- return; // already exist!
81
- }
82
-
83
- if (this._sortFn(walkerValue, value) < 0) {
84
- break;
85
- }
86
- last = walker;
87
- walker = walker.next;
88
- continue;
89
- }
90
-
91
- this._byteLength += value._payload.byteLength;
92
- if (!value.hash) {
93
- throw new Error("Unexpected");
94
- }
95
-
96
- _insertAfter(this._values, last, value.hash);
97
- }
98
-
99
- async delete(value: Entry<T> | string) {
100
- const hash = typeof value === "string" ? value : value.hash;
101
- // Assume we want to delete at tail (or somwhere close)
102
-
103
- let walker = this._values.tail;
104
- while (walker) {
105
- const walkerValue = this._entryIndex.getShallow(walker.value);
106
-
107
- if (!walkerValue) {
108
- throw new Error("Missing walker value");
109
- }
110
-
111
- if (walkerValue.hash === hash) {
112
- this._values.removeNode(walker);
113
- this._byteLength -= walkerValue.payloadByteLength;
114
- return;
115
- }
116
- walker = walker.prev; // prev will be undefined if you do removeNode(walker)
117
- }
118
- throw new Error(
119
- "Failed to delete, entry does not exist" +
120
- " ??? " +
121
- this.length +
122
- " ??? " +
123
- hash
124
- );
125
- }
126
-
127
- deleteNode(node: EntryNode) {
128
- this._values.removeNode(node);
129
- this._byteLength -= this._entryIndex.getShallow(
130
- node.value
131
- )!.payloadByteLength;
132
- return;
133
- }
134
-
135
- pop() {
136
- const value = this._values.pop();
137
- if (value) {
138
- this._byteLength -= this._entryIndex.getShallow(value)!.payloadByteLength;
139
- }
140
- return value;
141
- }
142
-
143
- get byteLength() {
144
- return this._byteLength;
145
- }
146
- }
147
-
148
- function _insertAfter(
149
- self: yallist<any>,
150
- node: EntryNode | undefined,
151
- value: string
152
- ) {
153
- const inserted = !node
154
- ? new yallist.Node(
155
- value,
156
- null as any,
157
- self.head as EntryNode | undefined,
158
- self
159
- )
160
- : new yallist.Node(value, node, node.next as EntryNode | undefined, self);
161
-
162
- // is tail
163
- if (inserted.next === null) {
164
- self.tail = inserted;
165
- }
166
-
167
- // is head
168
- if (inserted.prev === null) {
169
- self.head = inserted;
170
- }
171
-
172
- self.length++;
173
- return inserted;
174
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes