@ipld/dag-pb
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -9,2 +9,4 @@ 'use strict'; | ||
const name = 'dag-pb'; | ||
const code = 112; | ||
const pbNodeProperties = [ | ||
@@ -141,3 +143,3 @@ 'Data', | ||
} | ||
function _encode(node) { | ||
function encode(node) { | ||
validate(node); | ||
@@ -165,3 +167,3 @@ const pbn = {}; | ||
} | ||
function _decode(bytes) { | ||
function decode(bytes) { | ||
const pbn = pbDecode.decodeNode(bytes); | ||
@@ -193,8 +195,2 @@ const node = {}; | ||
} | ||
const {name, code, decode, encode} = { | ||
name: 'dag-pb', | ||
code: 112, | ||
encode: _encode, | ||
decode: _decode | ||
}; | ||
@@ -201,0 +197,0 @@ exports.code = code; |
import { CID } from 'multiformats/cid'; | ||
import { decodeNode } from './pb-decode.js'; | ||
import { encodeNode } from './pb-encode.js'; | ||
export const name = 'dag-pb'; | ||
export const code = 112; | ||
const pbNodeProperties = [ | ||
@@ -135,3 +137,3 @@ 'Data', | ||
} | ||
function _encode(node) { | ||
export function encode(node) { | ||
validate(node); | ||
@@ -159,3 +161,3 @@ const pbn = {}; | ||
} | ||
function _decode(bytes) { | ||
export function decode(bytes) { | ||
const pbn = decodeNode(bytes); | ||
@@ -186,8 +188,2 @@ const node = {}; | ||
return node; | ||
} | ||
export const {name, code, decode, encode} = { | ||
name: 'dag-pb', | ||
code: 112, | ||
encode: _encode, | ||
decode: _decode | ||
}; | ||
} |
{ | ||
"name": "@ipld/dag-pb", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "JS implementation of DAG-PB", | ||
@@ -5,0 +5,0 @@ "main": "./cjs/src/index.js", |
@@ -6,5 +6,4 @@ import { CID } from 'multiformats/cid' | ||
/** | ||
* @template {number} Code | ||
* @template T | ||
* @typedef {import('multiformats/codecs/interface').BlockCodec<Code, T>} BlockCodec | ||
* @typedef {import('multiformats/codecs/interface').ByteView<T>} ByteView | ||
*/ | ||
@@ -17,2 +16,5 @@ | ||
export const name = 'dag-pb' | ||
export const code = 0x70 | ||
const pbNodeProperties = ['Data', 'Links'] | ||
@@ -215,5 +217,5 @@ const pbLinkProperties = ['Hash', 'Name', 'Tsize'] | ||
* @param {PBNode} node | ||
* @returns {Uint8Array} | ||
* @returns {ByteView<PBNode>} | ||
*/ | ||
function _encode (node) { | ||
export function encode (node) { | ||
validate(node) | ||
@@ -245,6 +247,6 @@ | ||
/** | ||
* @param {Uint8Array} bytes | ||
* @param {ByteView<PBNode>} bytes | ||
* @returns {PBNode} | ||
*/ | ||
function _decode (bytes) { | ||
export function decode (bytes) { | ||
const pbn = decodeNode(bytes) | ||
@@ -279,11 +281,1 @@ | ||
} | ||
/** | ||
* @type {BlockCodec<0x70, PBNode>} | ||
*/ | ||
export const { name, code, decode, encode } = { | ||
name: 'dag-pb', | ||
code: 0x70, | ||
encode: _encode, | ||
decode: _decode | ||
} |
@@ -10,9 +10,25 @@ /** | ||
export function validate(node: PBNode): void; | ||
export const name: string; | ||
/** | ||
* @param {PBNode} node | ||
* @returns {ByteView<PBNode>} | ||
*/ | ||
export function encode(node: PBNode): ByteView<PBNode>; | ||
/** | ||
* @param {ByteView<PBNode>} bytes | ||
* @returns {PBNode} | ||
*/ | ||
export function decode(bytes: ByteView<PBNode>): PBNode; | ||
/** | ||
* @template T | ||
* @typedef {import('multiformats/codecs/interface').ByteView<T>} ByteView | ||
*/ | ||
/** | ||
* @typedef {import('./interface').PBLink} PBLink | ||
* @typedef {import('./interface').PBNode} PBNode | ||
*/ | ||
export const name: "dag-pb"; | ||
export const code: 112; | ||
export const decode: (bytes: import("multiformats/codecs/interface").ByteView<import("./interface").PBNode>) => import("./interface").PBNode; | ||
export const encode: (data: import("./interface").PBNode) => import("multiformats/codecs/interface").ByteView<import("./interface").PBNode>; | ||
export type BlockCodec<Code extends number, T> = import('multiformats/codecs/interface').BlockCodec<Code, T>; | ||
export type ByteView<T> = import('multiformats/codecs/interface').ByteView<T>; | ||
export type PBLink = import('./interface').PBLink; | ||
export type PBNode = import('./interface').PBNode; | ||
//# sourceMappingURL=index.d.ts.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
213651