Comparing version 0.1.0 to 0.2.0
@@ -11,2 +11,8 @@ /// <reference types="node" /> | ||
export declare class Cell { | ||
/** | ||
* Deserialize cells from BOC | ||
* @param src source buffer | ||
* @returns array of cells | ||
*/ | ||
static fromBoc(src: Buffer): Cell[]; | ||
readonly type: CellType; | ||
@@ -34,10 +40,38 @@ readonly bits: BitString; | ||
* Get cell hash | ||
* @param level level | ||
* @returns cell hash | ||
*/ | ||
hash: (level?: number) => Buffer; | ||
/** | ||
* Get cell depth | ||
* @param level level | ||
* @returns cell depth | ||
*/ | ||
depth: (level?: number) => number; | ||
/** | ||
* Get cell level | ||
* @returns cell level | ||
*/ | ||
level: () => number; | ||
/** | ||
* Checks cell to be euqal to another cell | ||
* @param other other cell | ||
* @returns true if cells are equal | ||
*/ | ||
equals: (other: Cell) => boolean; | ||
/** | ||
* Serializes cell to BOC | ||
* @param opts options | ||
*/ | ||
toBoc(opts?: { | ||
idx?: boolean | null | undefined; | ||
crc32?: boolean | null | undefined; | ||
}): Buffer; | ||
/** | ||
* Format cell to string | ||
* @param indent indentation | ||
* @returns string representation | ||
*/ | ||
toString(indent?: string): string; | ||
[inspectSymbol]: () => string; | ||
} |
@@ -14,2 +14,3 @@ "use strict"; | ||
const wonderCalculator_1 = require("./cell/wonderCalculator"); | ||
const serialization_1 = require("./cell/serialization"); | ||
/** | ||
@@ -19,2 +20,10 @@ * Cell as described in TVM spec | ||
class Cell { | ||
/** | ||
* Deserialize cells from BOC | ||
* @param src source buffer | ||
* @returns array of cells | ||
*/ | ||
static fromBoc(src) { | ||
return (0, serialization_1.deserializeBoc)(src); | ||
} | ||
constructor(opts) { | ||
@@ -33,2 +42,3 @@ // Level and depth information | ||
* Get cell hash | ||
* @param level level | ||
* @returns cell hash | ||
@@ -39,8 +49,22 @@ */ | ||
}; | ||
/** | ||
* Get cell depth | ||
* @param level level | ||
* @returns cell depth | ||
*/ | ||
this.depth = (level = 3) => { | ||
return this._depths[Math.min(this._depths.length - 1, level)]; | ||
}; | ||
/** | ||
* Get cell level | ||
* @returns cell level | ||
*/ | ||
this.level = () => { | ||
return this.mask.level; | ||
}; | ||
/** | ||
* Checks cell to be euqal to another cell | ||
* @param other other cell | ||
* @returns true if cells are equal | ||
*/ | ||
this.equals = (other) => { | ||
@@ -106,2 +130,16 @@ return this.hash().equals(other.hash()); | ||
} | ||
/** | ||
* Serializes cell to BOC | ||
* @param opts options | ||
*/ | ||
toBoc(opts) { | ||
let idx = (opts && opts.idx !== null && opts.idx !== undefined) ? opts.idx : false; | ||
let crc32 = (opts && opts.crc32 !== null && opts.crc32 !== undefined) ? opts.crc32 : true; | ||
return (0, serialization_1.serializeBoc)(this, { idx, crc32 }); | ||
} | ||
/** | ||
* Format cell to string | ||
* @param indent indentation | ||
* @returns string representation | ||
*/ | ||
toString(indent) { | ||
@@ -108,0 +146,0 @@ let id = indent || ''; |
{ | ||
"name": "ton-core", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/ton-community/ton-core.git", |
@@ -8,2 +8,3 @@ import inspectSymbol from 'symbol.inspect'; | ||
import { wonderCalculator } from './cell/wonderCalculator'; | ||
import { deserializeBoc, serializeBoc } from './cell/serialization'; | ||
@@ -15,2 +16,11 @@ /** | ||
/** | ||
* Deserialize cells from BOC | ||
* @param src source buffer | ||
* @returns array of cells | ||
*/ | ||
static fromBoc(src: Buffer) { | ||
return deserializeBoc(src); | ||
} | ||
// Public properties | ||
@@ -105,2 +115,3 @@ readonly type: CellType; | ||
* Get cell hash | ||
* @param level level | ||
* @returns cell hash | ||
@@ -112,2 +123,7 @@ */ | ||
/** | ||
* Get cell depth | ||
* @param level level | ||
* @returns cell depth | ||
*/ | ||
depth = (level: number = 3): number => { | ||
@@ -117,2 +133,6 @@ return this._depths[Math.min(this._depths.length - 1, level)]; | ||
/** | ||
* Get cell level | ||
* @returns cell level | ||
*/ | ||
level = (): number => { | ||
@@ -122,2 +142,7 @@ return this.mask.level; | ||
/** | ||
* Checks cell to be euqal to another cell | ||
* @param other other cell | ||
* @returns true if cells are equal | ||
*/ | ||
equals = (other: Cell): boolean => { | ||
@@ -127,2 +152,17 @@ return this.hash().equals(other.hash()); | ||
/** | ||
* Serializes cell to BOC | ||
* @param opts options | ||
*/ | ||
toBoc(opts?: { idx?: boolean | null | undefined, crc32?: boolean | null | undefined }): Buffer { | ||
let idx = (opts && opts.idx !== null && opts.idx !== undefined) ? opts.idx : false; | ||
let crc32 = (opts && opts.crc32 !== null && opts.crc32 !== undefined) ? opts.crc32 : true; | ||
return serializeBoc(this, { idx, crc32 }); | ||
} | ||
/** | ||
* Format cell to string | ||
* @param indent indentation | ||
* @returns string representation | ||
*/ | ||
toString(indent?: string): string { | ||
@@ -129,0 +169,0 @@ let id = indent || ''; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
438256
7886
0