@typeberry/lib 0.1.2-b7cae5d → 0.1.2-dd9b0e2
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 +18 -6
- package/index.d.ts +5 -4
- package/index.js +18 -6
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -8052,8 +8052,8 @@ function print(level, levelAndName, strings, data) {
|
|
|
8052
8052
|
return;
|
|
8053
8053
|
}
|
|
8054
8054
|
const lvlText = Level[level].padEnd(5);
|
|
8055
|
-
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
8056
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
8055
|
+
const val = strings.map((v, idx) => `${v}${idx < data.length ? data[idx] : ""}`);
|
|
8056
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
|
|
8057
8057
|
if (level === Level.WARN) {
|
|
8058
8058
|
console.warn(msg);
|
|
8059
8059
|
}
|
|
@@ -14125,6 +14125,17 @@ class PageRange {
|
|
|
14125
14125
|
}
|
|
14126
14126
|
return new PageRange(start, length);
|
|
14127
14127
|
}
|
|
14128
|
+
/** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
|
|
14129
|
+
isWrapped() {
|
|
14130
|
+
return this.start >= this.end && !this.isEmpty();
|
|
14131
|
+
}
|
|
14132
|
+
/** Checks if given page number is within the range */
|
|
14133
|
+
isInRange(page) {
|
|
14134
|
+
if (this.isWrapped()) {
|
|
14135
|
+
return page >= this.start || page < this.end;
|
|
14136
|
+
}
|
|
14137
|
+
return page >= this.start && page < this.end;
|
|
14138
|
+
}
|
|
14128
14139
|
/** Checks if a range is empty (`length === 0`) */
|
|
14129
14140
|
isEmpty() {
|
|
14130
14141
|
return this.length === 0;
|
|
@@ -14465,10 +14476,11 @@ class MemoryBuilder {
|
|
|
14465
14476
|
startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
|
|
14466
14477
|
`;
|
|
14467
14478
|
this.ensureNotFinalized();
|
|
14468
|
-
const
|
|
14469
|
-
const
|
|
14470
|
-
|
|
14471
|
-
|
|
14479
|
+
const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14480
|
+
const heapPagesRange = PageRange.fromMemoryRange(heapRange);
|
|
14481
|
+
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
14482
|
+
for (const pageNumber of initializedPageNumbers) {
|
|
14483
|
+
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14472
14484
|
throw new IncorrectSbrkIndex();
|
|
14473
14485
|
}
|
|
14474
14486
|
}
|
package/index.d.ts
CHANGED
|
@@ -14780,11 +14780,12 @@ declare class MemoryBuilder {
|
|
|
14780
14780
|
`;
|
|
14781
14781
|
this.ensureNotFinalized();
|
|
14782
14782
|
|
|
14783
|
-
const
|
|
14784
|
-
const
|
|
14783
|
+
const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14784
|
+
const heapPagesRange = PageRange.fromMemoryRange(heapRange);
|
|
14785
|
+
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
14785
14786
|
|
|
14786
|
-
for (const pageNumber of
|
|
14787
|
-
if (
|
|
14787
|
+
for (const pageNumber of initializedPageNumbers) {
|
|
14788
|
+
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14788
14789
|
throw new IncorrectSbrkIndex();
|
|
14789
14790
|
}
|
|
14790
14791
|
}
|
package/index.js
CHANGED
|
@@ -8049,8 +8049,8 @@ function print(level, levelAndName, strings, data) {
|
|
|
8049
8049
|
return;
|
|
8050
8050
|
}
|
|
8051
8051
|
const lvlText = Level[level].padEnd(5);
|
|
8052
|
-
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
8053
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
8052
|
+
const val = strings.map((v, idx) => `${v}${idx < data.length ? data[idx] : ""}`);
|
|
8053
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
|
|
8054
8054
|
if (level === Level.WARN) {
|
|
8055
8055
|
console.warn(msg);
|
|
8056
8056
|
}
|
|
@@ -14122,6 +14122,17 @@ class PageRange {
|
|
|
14122
14122
|
}
|
|
14123
14123
|
return new PageRange(start, length);
|
|
14124
14124
|
}
|
|
14125
|
+
/** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
|
|
14126
|
+
isWrapped() {
|
|
14127
|
+
return this.start >= this.end && !this.isEmpty();
|
|
14128
|
+
}
|
|
14129
|
+
/** Checks if given page number is within the range */
|
|
14130
|
+
isInRange(page) {
|
|
14131
|
+
if (this.isWrapped()) {
|
|
14132
|
+
return page >= this.start || page < this.end;
|
|
14133
|
+
}
|
|
14134
|
+
return page >= this.start && page < this.end;
|
|
14135
|
+
}
|
|
14125
14136
|
/** Checks if a range is empty (`length === 0`) */
|
|
14126
14137
|
isEmpty() {
|
|
14127
14138
|
return this.length === 0;
|
|
@@ -14462,10 +14473,11 @@ class MemoryBuilder {
|
|
|
14462
14473
|
startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
|
|
14463
14474
|
`;
|
|
14464
14475
|
this.ensureNotFinalized();
|
|
14465
|
-
const
|
|
14466
|
-
const
|
|
14467
|
-
|
|
14468
|
-
|
|
14476
|
+
const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14477
|
+
const heapPagesRange = PageRange.fromMemoryRange(heapRange);
|
|
14478
|
+
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
14479
|
+
for (const pageNumber of initializedPageNumbers) {
|
|
14480
|
+
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14469
14481
|
throw new IncorrectSbrkIndex();
|
|
14470
14482
|
}
|
|
14471
14483
|
}
|