Comparing version 0.6.0 to 0.7.0
@@ -12,3 +12,3 @@ /// <reference types="node" /> | ||
private _checkpoints; | ||
constructor(bits: BitString); | ||
constructor(bits: BitString, offset?: number); | ||
/** | ||
@@ -202,2 +202,6 @@ * Number of bits remaining | ||
/** | ||
* Clone BitReader | ||
*/ | ||
clone(): BitReader; | ||
/** | ||
* Preload int from specific offset | ||
@@ -204,0 +208,0 @@ * @param bits bits to preload |
@@ -10,6 +10,6 @@ "use strict"; | ||
class BitReader { | ||
constructor(bits) { | ||
this._offset = 0; | ||
constructor(bits, offset = 0) { | ||
this._checkpoints = []; | ||
this._bits = bits; | ||
this._offset = offset; | ||
} | ||
@@ -366,2 +366,8 @@ /** | ||
/** | ||
* Clone BitReader | ||
*/ | ||
clone() { | ||
return new BitReader(this._bits, this._offset); | ||
} | ||
/** | ||
* Preload int from specific offset | ||
@@ -368,0 +374,0 @@ * @param bits bits to preload |
@@ -15,2 +15,3 @@ "use strict"; | ||
const serialization_1 = require("./cell/serialization"); | ||
const BitReader_1 = require("./BitReader"); | ||
/** | ||
@@ -37,3 +38,3 @@ * Cell as described in TVM spec | ||
this.beginParse = () => { | ||
return new Slice_1.Slice(this); | ||
return new Slice_1.Slice(new BitReader_1.BitReader(this.bits), this.refs); | ||
}; | ||
@@ -40,0 +41,0 @@ /** |
/// <reference types="node" /> | ||
import { BitReader } from "./BitReader"; | ||
import { Cell } from "./Cell"; | ||
@@ -9,3 +10,3 @@ /** | ||
private _refs; | ||
constructor(cell: Cell); | ||
constructor(reader: BitReader, refs: Cell[]); | ||
/** | ||
@@ -209,2 +210,7 @@ * Get remaining bits | ||
preloadBuffer(bytes: number): Buffer; | ||
/** | ||
* Clone slice | ||
* @returns cloned slice | ||
*/ | ||
clone(): Slice; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Slice = void 0; | ||
const BitReader_1 = require("./BitReader"); | ||
/** | ||
@@ -9,5 +8,5 @@ * Slice is a class that allows to read cell data | ||
class Slice { | ||
constructor(cell) { | ||
this._reader = new BitReader_1.BitReader(cell.bits); | ||
this._refs = [...cell.refs]; | ||
constructor(reader, refs) { | ||
this._reader = reader; | ||
this._refs = refs; | ||
} | ||
@@ -300,3 +299,10 @@ /** | ||
} | ||
/** | ||
* Clone slice | ||
* @returns cloned slice | ||
*/ | ||
clone() { | ||
return new Slice(this._reader.clone(), [...this._refs]); | ||
} | ||
} | ||
exports.Slice = Slice; |
{ | ||
"name": "ton-core", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/ton-community/ton-core.git", |
import { Address } from "../address/Address"; | ||
import { ExternalAddress } from "../address/ExternalAddress"; | ||
import { BitBuilder } from "./BitBuilder"; | ||
import { BitString } from "./BitString"; | ||
@@ -12,7 +11,8 @@ | ||
private _bits: BitString; | ||
private _offset = 0; | ||
private _offset; | ||
private _checkpoints: number[] = []; | ||
constructor(bits: BitString) { | ||
constructor(bits: BitString, offset: number = 0) { | ||
this._bits = bits; | ||
this._offset = offset; | ||
} | ||
@@ -395,2 +395,9 @@ | ||
/** | ||
* Clone BitReader | ||
*/ | ||
clone() { | ||
return new BitReader(this._bits, this._offset); | ||
} | ||
/** | ||
* Preload int from specific offset | ||
@@ -397,0 +404,0 @@ * @param bits bits to preload |
@@ -9,2 +9,3 @@ import inspectSymbol from 'symbol.inspect'; | ||
import { deserializeBoc, serializeBoc } from './cell/serialization'; | ||
import { BitReader } from './BitReader'; | ||
@@ -109,3 +110,3 @@ /** | ||
beginParse = () => { | ||
return new Slice(this); | ||
return new Slice(new BitReader(this.bits), this.refs); | ||
} | ||
@@ -112,0 +113,0 @@ |
@@ -11,5 +11,5 @@ import { BitReader } from "./BitReader"; | ||
constructor(cell: Cell) { | ||
this._reader = new BitReader(cell.bits); | ||
this._refs = [...cell.refs]; | ||
constructor(reader: BitReader, refs: Cell[]) { | ||
this._reader = reader; | ||
this._refs = refs; | ||
} | ||
@@ -337,2 +337,10 @@ | ||
} | ||
/** | ||
* Clone slice | ||
* @returns cloned slice | ||
*/ | ||
clone() { | ||
return new Slice(this._reader.clone(), [...this._refs]); | ||
} | ||
} |
447665
8291