@typeberry/lib 0.1.2-dd9b0e2 → 0.1.2

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 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}${idx < data.length ? data[idx] : ""}`);
8056
- const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
8055
+ const val = strings.map((v, idx) => `${v}${data[idx]}`);
8056
+ const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
8057
8057
  if (level === Level.WARN) {
8058
8058
  console.warn(msg);
8059
8059
  }
@@ -14125,17 +14125,6 @@ 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
- }
14139
14128
  /** Checks if a range is empty (`length === 0`) */
14140
14129
  isEmpty() {
14141
14130
  return this.length === 0;
@@ -14476,11 +14465,10 @@ class MemoryBuilder {
14476
14465
  startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
14477
14466
  `;
14478
14467
  this.ensureNotFinalized();
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)) {
14468
+ const range = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
14469
+ const pages = PageRange.fromMemoryRange(range);
14470
+ for (const pageNumber of pages) {
14471
+ if (this.initialMemory.has(pageNumber)) {
14484
14472
  throw new IncorrectSbrkIndex();
14485
14473
  }
14486
14474
  }
package/index.d.ts CHANGED
@@ -14780,12 +14780,11 @@ declare class MemoryBuilder {
14780
14780
  `;
14781
14781
  this.ensureNotFinalized();
14782
14782
 
14783
- const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
14784
- const heapPagesRange = PageRange.fromMemoryRange(heapRange);
14785
- const initializedPageNumbers = Array.from(this.initialMemory.keys());
14783
+ const range = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
14784
+ const pages = PageRange.fromMemoryRange(range);
14786
14785
 
14787
- for (const pageNumber of initializedPageNumbers) {
14788
- if (heapPagesRange.isInRange(pageNumber)) {
14786
+ for (const pageNumber of pages) {
14787
+ if (this.initialMemory.has(pageNumber)) {
14789
14788
  throw new IncorrectSbrkIndex();
14790
14789
  }
14791
14790
  }
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}${idx < data.length ? data[idx] : ""}`);
8053
- const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
8052
+ const val = strings.map((v, idx) => `${v}${data[idx]}`);
8053
+ const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
8054
8054
  if (level === Level.WARN) {
8055
8055
  console.warn(msg);
8056
8056
  }
@@ -14122,17 +14122,6 @@ 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
- }
14136
14125
  /** Checks if a range is empty (`length === 0`) */
14137
14126
  isEmpty() {
14138
14127
  return this.length === 0;
@@ -14473,11 +14462,10 @@ class MemoryBuilder {
14473
14462
  startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
14474
14463
  `;
14475
14464
  this.ensureNotFinalized();
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)) {
14465
+ const range = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
14466
+ const pages = PageRange.fromMemoryRange(range);
14467
+ for (const pageNumber of pages) {
14468
+ if (this.initialMemory.has(pageNumber)) {
14481
14469
  throw new IncorrectSbrkIndex();
14482
14470
  }
14483
14471
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeberry/lib",
3
- "version": "0.1.2-dd9b0e2",
3
+ "version": "0.1.2",
4
4
  "main": "index.js",
5
5
  "author": "Fluffy Labs",
6
6
  "license": "MPL-2.0",