Comparing version 0.2.0 to 0.3.0
@@ -14,2 +14,6 @@ /// <reference types="node" /> | ||
/** | ||
* Number of bits remaining | ||
*/ | ||
get remaining(): number; | ||
/** | ||
* Skip bits | ||
@@ -16,0 +20,0 @@ * @param bits number of bits to skip |
@@ -16,2 +16,8 @@ "use strict"; | ||
/** | ||
* Number of bits remaining | ||
*/ | ||
get remaining() { | ||
return this._bits.length - this._offset; | ||
} | ||
/** | ||
* Skip bits | ||
@@ -18,0 +24,0 @@ * @param bits number of bits to skip |
@@ -5,3 +5,5 @@ /// <reference types="node" /> | ||
import { BitString } from "./BitString"; | ||
import { Writable } from "./Writable"; | ||
import { Cell } from "./Cell"; | ||
import { Slice } from "./Slice"; | ||
/** | ||
@@ -90,2 +92,22 @@ * Start building a cell | ||
/** | ||
* Read slice and store it in this builder | ||
* @param src source slice | ||
*/ | ||
storeSlice(src: Slice): this; | ||
/** | ||
* Read slice and store it in this builder if not null | ||
* @param src source slice | ||
*/ | ||
storeMaybeSlice(src: Slice | null): this; | ||
/** | ||
* Store writer or builder | ||
* @param writer writer or builder to store | ||
*/ | ||
storeWritable(writer: ((builder: Builder) => void) | Writable): void; | ||
/** | ||
* Store writer or builder if not null | ||
* @param writer writer or builder to store | ||
*/ | ||
storeMaybeWritable(writer: ((builder: Builder) => void) | Writable | null): void; | ||
/** | ||
* Complete cell | ||
@@ -92,0 +114,0 @@ * @returns cell |
@@ -145,2 +145,54 @@ "use strict"; | ||
/** | ||
* Read slice and store it in this builder | ||
* @param src source slice | ||
*/ | ||
storeSlice(src) { | ||
if (src.remainingBits > 0) { | ||
this.storeBits(src.loadBits(src.remainingBits)); | ||
} | ||
while (src.remainingRefs > 0) { | ||
this.storeRef(src.loadRef()); | ||
} | ||
return this; | ||
} | ||
/** | ||
* Read slice and store it in this builder if not null | ||
* @param src source slice | ||
*/ | ||
storeMaybeSlice(src) { | ||
if (src) { | ||
this.storeBit(1); | ||
this.storeSlice(src); | ||
} | ||
else { | ||
this.storeBit(0); | ||
} | ||
return this; | ||
} | ||
/** | ||
* Store writer or builder | ||
* @param writer writer or builder to store | ||
*/ | ||
storeWritable(writer) { | ||
if (typeof writer === 'object') { | ||
writer.writeTo(this); | ||
} | ||
else { | ||
writer(this); | ||
} | ||
} | ||
/** | ||
* Store writer or builder if not null | ||
* @param writer writer or builder to store | ||
*/ | ||
storeMaybeWritable(writer) { | ||
if (writer) { | ||
this.storeBit(1); | ||
this.storeWritable(writer); | ||
} | ||
else { | ||
this.storeBit(0); | ||
} | ||
} | ||
/** | ||
* Complete cell | ||
@@ -147,0 +199,0 @@ * @returns cell |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { Cell } from "./Cell"; | ||
@@ -10,2 +11,10 @@ /** | ||
/** | ||
* Get remaining bits | ||
*/ | ||
get remainingBits(): number; | ||
/** | ||
* Get remaining refs | ||
*/ | ||
get remainingRefs(): number; | ||
/** | ||
* Skip bits | ||
@@ -188,2 +197,14 @@ * @param bits | ||
preloadMaybeCell(): Cell | null; | ||
/** | ||
* Load byte buffer | ||
* @param bytes number of bytes to load | ||
* @returns Buffer | ||
*/ | ||
loadBuffer(bytes: number): Buffer; | ||
/** | ||
* Load byte buffer | ||
* @param bytes number of bytes to load | ||
* @returns Buffer | ||
*/ | ||
preloadBuffer(bytes: number): Buffer; | ||
} |
@@ -14,2 +14,14 @@ "use strict"; | ||
/** | ||
* Get remaining bits | ||
*/ | ||
get remainingBits() { | ||
return this._reader.remaining; | ||
} | ||
/** | ||
* Get remaining refs | ||
*/ | ||
get remainingRefs() { | ||
return this._refs.length; | ||
} | ||
/** | ||
* Skip bits | ||
@@ -272,3 +284,19 @@ * @param bits | ||
} | ||
/** | ||
* Load byte buffer | ||
* @param bytes number of bytes to load | ||
* @returns Buffer | ||
*/ | ||
loadBuffer(bytes) { | ||
return this._reader.loadBuffer(bytes); | ||
} | ||
/** | ||
* Load byte buffer | ||
* @param bytes number of bytes to load | ||
* @returns Buffer | ||
*/ | ||
preloadBuffer(bytes) { | ||
return this._reader.preloadBuffer(bytes); | ||
} | ||
} | ||
exports.Slice = Slice; |
@@ -11,4 +11,5 @@ export { Address } from './address/Address'; | ||
export { Cell } from './boc/Cell'; | ||
export { Writable } from './boc/Writable'; | ||
export { exoticMerkleProof } from './boc/cell/exoticMerkleProof'; | ||
export { exoticMerkleUpdate } from './boc/cell/exoticMerkleUpdate'; | ||
export { exoticPruned } from './boc/cell/exoticPruned'; |
{ | ||
"name": "ton-core", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/ton-community/ton-core.git", |
@@ -20,2 +20,9 @@ import { Address } from "../address/Address"; | ||
/** | ||
* Number of bits remaining | ||
*/ | ||
get remaining() { | ||
return this._bits.length - this._offset; | ||
} | ||
/** | ||
* Skip bits | ||
@@ -22,0 +29,0 @@ * @param bits number of bits to skip |
@@ -5,3 +5,5 @@ import { Address } from "../address/Address"; | ||
import { BitString } from "./BitString"; | ||
import { Writable } from "./Writable"; | ||
import { Cell } from "./Cell"; | ||
import { Slice } from "./Slice"; | ||
@@ -163,2 +165,55 @@ /** | ||
/** | ||
* Read slice and store it in this builder | ||
* @param src source slice | ||
*/ | ||
storeSlice(src: Slice) { | ||
if (src.remainingBits > 0) { | ||
this.storeBits(src.loadBits(src.remainingBits)); | ||
} | ||
while (src.remainingRefs > 0) { | ||
this.storeRef(src.loadRef()); | ||
} | ||
return this; | ||
} | ||
/** | ||
* Read slice and store it in this builder if not null | ||
* @param src source slice | ||
*/ | ||
storeMaybeSlice(src: Slice | null) { | ||
if (src) { | ||
this.storeBit(1); | ||
this.storeSlice(src); | ||
} else { | ||
this.storeBit(0); | ||
} | ||
return this; | ||
} | ||
/** | ||
* Store writer or builder | ||
* @param writer writer or builder to store | ||
*/ | ||
storeWritable(writer: ((builder: Builder) => void) | Writable) { | ||
if (typeof writer === 'object') { | ||
writer.writeTo(this); | ||
} else { | ||
writer(this); | ||
} | ||
} | ||
/** | ||
* Store writer or builder if not null | ||
* @param writer writer or builder to store | ||
*/ | ||
storeMaybeWritable(writer: ((builder: Builder) => void) | Writable | null) { | ||
if (writer) { | ||
this.storeBit(1); | ||
this.storeWritable(writer); | ||
} else { | ||
this.storeBit(0); | ||
} | ||
} | ||
/** | ||
* Complete cell | ||
@@ -165,0 +220,0 @@ * @returns cell |
@@ -17,2 +17,16 @@ import { BitReader } from "./BitReader"; | ||
/** | ||
* Get remaining bits | ||
*/ | ||
get remainingBits() { | ||
return this._reader.remaining; | ||
} | ||
/** | ||
* Get remaining refs | ||
*/ | ||
get remainingRefs() { | ||
return this._refs.length; | ||
} | ||
/** | ||
* Skip bits | ||
@@ -305,2 +319,20 @@ * @param bits | ||
} | ||
/** | ||
* Load byte buffer | ||
* @param bytes number of bytes to load | ||
* @returns Buffer | ||
*/ | ||
loadBuffer(bytes: number) { | ||
return this._reader.loadBuffer(bytes); | ||
} | ||
/** | ||
* Load byte buffer | ||
* @param bytes number of bytes to load | ||
* @returns Buffer | ||
*/ | ||
preloadBuffer(bytes: number) { | ||
return this._reader.preloadBuffer(bytes); | ||
} | ||
} |
@@ -16,2 +16,3 @@ // Address | ||
export { Cell } from './boc/Cell'; | ||
export { Writable } from './boc/Writable'; | ||
@@ -18,0 +19,0 @@ // Exotics |
443956
128
8113