Comparing version 0.7.0 to 0.8.0
@@ -107,3 +107,3 @@ /// <reference types="node" /> | ||
/** | ||
* Read slice and store it in this builder | ||
* Store slice it in this builder | ||
* @param src source slice | ||
@@ -113,3 +113,3 @@ */ | ||
/** | ||
* Read slice and store it in this builder if not null | ||
* Store slice in this builder if not null | ||
* @param src source slice | ||
@@ -145,2 +145,12 @@ */ | ||
endCell(): Cell; | ||
/** | ||
* Convert to cell | ||
* @returns cell | ||
*/ | ||
asCell(): Cell; | ||
/** | ||
* Convert to slice | ||
* @returns slice | ||
*/ | ||
asSlice(): Slice; | ||
} |
@@ -169,11 +169,12 @@ "use strict"; | ||
/** | ||
* Read slice and store it in this builder | ||
* Store slice it in this builder | ||
* @param src source slice | ||
*/ | ||
storeSlice(src) { | ||
if (src.remainingBits > 0) { | ||
this.storeBits(src.loadBits(src.remainingBits)); | ||
let c = src.clone(); | ||
if (c.remainingBits > 0) { | ||
this.storeBits(c.loadBits(c.remainingBits)); | ||
} | ||
while (src.remainingRefs > 0) { | ||
this.storeRef(src.loadRef()); | ||
while (c.remainingRefs > 0) { | ||
this.storeRef(c.loadRef()); | ||
} | ||
@@ -183,3 +184,3 @@ return this; | ||
/** | ||
* Read slice and store it in this builder if not null | ||
* Store slice in this builder if not null | ||
* @param src source slice | ||
@@ -257,3 +258,17 @@ */ | ||
} | ||
/** | ||
* Convert to cell | ||
* @returns cell | ||
*/ | ||
asCell() { | ||
return this.endCell(); | ||
} | ||
/** | ||
* Convert to slice | ||
* @returns slice | ||
*/ | ||
asSlice() { | ||
return this.endCell().beginParse(); | ||
} | ||
} | ||
exports.Builder = Builder; |
@@ -74,3 +74,13 @@ /// <reference types="node" /> | ||
toString(indent?: string): string; | ||
/** | ||
* Covnert cell to slice | ||
* @returns slice | ||
*/ | ||
asSlice(): Slice; | ||
/** | ||
* Convert cell to a builder that has this cell stored | ||
* @returns builder | ||
*/ | ||
asBuilder(): import("./Builder").Builder; | ||
[inspectSymbol]: () => string; | ||
} |
@@ -16,2 +16,3 @@ "use strict"; | ||
const BitReader_1 = require("./BitReader"); | ||
const Builder_1 = require("./Builder"); | ||
/** | ||
@@ -151,4 +152,18 @@ * Cell as described in TVM spec | ||
} | ||
/** | ||
* Covnert cell to slice | ||
* @returns slice | ||
*/ | ||
asSlice() { | ||
return this.beginParse(); | ||
} | ||
/** | ||
* Convert cell to a builder that has this cell stored | ||
* @returns builder | ||
*/ | ||
asBuilder() { | ||
return (0, Builder_1.beginCell)().storeSlice(this.asSlice()); | ||
} | ||
} | ||
exports.Cell = Cell; | ||
_a = symbol_inspect_1.default; |
@@ -210,2 +210,11 @@ /// <reference types="node" /> | ||
/** | ||
* Convert slice to cell | ||
*/ | ||
asCell(): Cell; | ||
/** | ||
* | ||
* @returns | ||
*/ | ||
asBuilder(): import("./Builder").Builder; | ||
/** | ||
* Clone slice | ||
@@ -212,0 +221,0 @@ * @returns cloned slice |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Slice = void 0; | ||
const Builder_1 = require("./Builder"); | ||
/** | ||
@@ -299,2 +300,15 @@ * Slice is a class that allows to read cell data | ||
/** | ||
* Convert slice to cell | ||
*/ | ||
asCell() { | ||
return (0, Builder_1.beginCell)().storeSlice(this).endCell(); | ||
} | ||
/** | ||
* | ||
* @returns | ||
*/ | ||
asBuilder() { | ||
return (0, Builder_1.beginCell)().storeSlice(this); | ||
} | ||
/** | ||
* Clone slice | ||
@@ -301,0 +315,0 @@ * @returns cloned slice |
{ | ||
"name": "ton-core", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/ton-community/ton-core.git", |
@@ -192,11 +192,12 @@ import { Address } from "../address/Address"; | ||
/** | ||
* Read slice and store it in this builder | ||
* Store slice it in this builder | ||
* @param src source slice | ||
*/ | ||
storeSlice(src: Slice) { | ||
if (src.remainingBits > 0) { | ||
this.storeBits(src.loadBits(src.remainingBits)); | ||
let c = src.clone(); | ||
if (c.remainingBits > 0) { | ||
this.storeBits(c.loadBits(c.remainingBits)); | ||
} | ||
while (src.remainingRefs > 0) { | ||
this.storeRef(src.loadRef()); | ||
while (c.remainingRefs > 0) { | ||
this.storeRef(c.loadRef()); | ||
} | ||
@@ -207,3 +208,3 @@ return this; | ||
/** | ||
* Read slice and store it in this builder if not null | ||
* Store slice in this builder if not null | ||
* @param src source slice | ||
@@ -282,2 +283,18 @@ */ | ||
} | ||
/** | ||
* Convert to cell | ||
* @returns cell | ||
*/ | ||
asCell() { | ||
return this.endCell(); | ||
} | ||
/** | ||
* Convert to slice | ||
* @returns slice | ||
*/ | ||
asSlice() { | ||
return this.endCell().beginParse(); | ||
} | ||
} |
@@ -10,2 +10,3 @@ import inspectSymbol from 'symbol.inspect'; | ||
import { BitReader } from './BitReader'; | ||
import { beginCell } from './Builder'; | ||
@@ -173,3 +174,19 @@ /** | ||
/** | ||
* Covnert cell to slice | ||
* @returns slice | ||
*/ | ||
asSlice() { | ||
return this.beginParse(); | ||
} | ||
/** | ||
* Convert cell to a builder that has this cell stored | ||
* @returns builder | ||
*/ | ||
asBuilder() { | ||
return beginCell().storeSlice(this.asSlice()); | ||
} | ||
[inspectSymbol] = () => this.toString() | ||
} |
import { BitReader } from "./BitReader"; | ||
import { beginCell } from "./Builder"; | ||
import { Cell } from "./Cell"; | ||
@@ -338,2 +339,17 @@ | ||
/** | ||
* Convert slice to cell | ||
*/ | ||
asCell() { | ||
return beginCell().storeSlice(this).endCell(); | ||
} | ||
/** | ||
* | ||
* @returns | ||
*/ | ||
asBuilder() { | ||
return beginCell().storeSlice(this); | ||
} | ||
/** | ||
* Clone slice | ||
@@ -340,0 +356,0 @@ * @returns cloned slice |
449939
8408