@ethersphere/bee-js 9.0.2 → 9.0.3
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/dist/cjs/feed/index.js +3 -0
- package/dist/cjs/utils/typed-bytes.js +8 -1
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/feed/index.js +6 -3
- package/dist/mjs/utils/typed-bytes.js +8 -1
- package/dist/types/utils/typed-bytes.d.ts +2 -1
- package/package.json +1 -1
package/dist/mjs/feed/index.js
CHANGED
|
@@ -80,7 +80,8 @@ export function makeFeedReader(requestOptions, topic, owner) {
|
|
|
80
80
|
const feedIndex = typeof options.index === 'number' ? FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
|
|
81
81
|
return {
|
|
82
82
|
payload: update.payload,
|
|
83
|
-
feedIndex
|
|
83
|
+
feedIndex,
|
|
84
|
+
feedIndexNext: feedIndex.next()
|
|
84
85
|
};
|
|
85
86
|
};
|
|
86
87
|
const downloadPayload = async options => {
|
|
@@ -92,7 +93,8 @@ export function makeFeedReader(requestOptions, topic, owner) {
|
|
|
92
93
|
const feedIndex = typeof options.index === 'number' ? FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
|
|
93
94
|
return {
|
|
94
95
|
payload,
|
|
95
|
-
feedIndex
|
|
96
|
+
feedIndex,
|
|
97
|
+
feedIndexNext: feedIndex.next()
|
|
96
98
|
};
|
|
97
99
|
};
|
|
98
100
|
const downloadReference = async options => {
|
|
@@ -106,7 +108,8 @@ export function makeFeedReader(requestOptions, topic, owner) {
|
|
|
106
108
|
});
|
|
107
109
|
return {
|
|
108
110
|
reference: new Reference(payload.payload.toUint8Array()),
|
|
109
|
-
feedIndex: payload.feedIndex
|
|
111
|
+
feedIndex: payload.feedIndex,
|
|
112
|
+
feedIndexNext: payload.feedIndexNext ?? payload.feedIndex.next()
|
|
110
113
|
};
|
|
111
114
|
};
|
|
112
115
|
return {
|
|
@@ -145,6 +145,7 @@ export class Topic extends Bytes {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
Topic.LENGTH = 32;
|
|
148
|
+
const MAX_UINT64 = new Uint8Array(8).fill(0xff, 0, 8);
|
|
148
149
|
export class FeedIndex extends Bytes {
|
|
149
150
|
constructor(bytes) {
|
|
150
151
|
super(bytes, 8);
|
|
@@ -155,6 +156,12 @@ export class FeedIndex extends Bytes {
|
|
|
155
156
|
toBigInt() {
|
|
156
157
|
return Binary.uint64ToNumber(this.bytes, 'BE');
|
|
157
158
|
}
|
|
159
|
+
next() {
|
|
160
|
+
if (Binary.equals(this.bytes, MAX_UINT64)) {
|
|
161
|
+
return FeedIndex.fromBigInt(0n);
|
|
162
|
+
}
|
|
163
|
+
return FeedIndex.fromBigInt(this.toBigInt() + 1n);
|
|
164
|
+
}
|
|
158
165
|
}
|
|
159
166
|
FeedIndex.LENGTH = 8;
|
|
160
|
-
FeedIndex.MINUS_ONE = new FeedIndex(
|
|
167
|
+
FeedIndex.MINUS_ONE = new FeedIndex(MAX_UINT64);
|
|
@@ -35,7 +35,7 @@ export declare class TransactionId extends Bytes {
|
|
|
35
35
|
export declare class Span extends Bytes {
|
|
36
36
|
static readonly LENGTH = 8;
|
|
37
37
|
constructor(bytes: Uint8Array | string | Bytes);
|
|
38
|
-
static fromBigInt(number: bigint):
|
|
38
|
+
static fromBigInt(number: bigint): Span;
|
|
39
39
|
toBigInt(): bigint;
|
|
40
40
|
static fromSlice(bytes: Uint8Array, start: number): Span;
|
|
41
41
|
}
|
|
@@ -65,4 +65,5 @@ export declare class FeedIndex extends Bytes {
|
|
|
65
65
|
constructor(bytes: Uint8Array | string | Bytes);
|
|
66
66
|
static fromBigInt(number: bigint): FeedIndex;
|
|
67
67
|
toBigInt(): bigint;
|
|
68
|
+
next(): FeedIndex;
|
|
68
69
|
}
|