Comparing version 3.4.0 to 3.5.0
13
index.js
@@ -295,5 +295,18 @@ // SPDX-FileCopyrightText: 2021 Anders Rune Jensen | ||
function decodeTypeFormat(input, typeName, formatName) { | ||
const tf = input.slice(0, 2) | ||
if (tf.equals(NIL_TF)) return null | ||
const type = NAMED_TYPES[typeName] | ||
const format = NAMED_TYPES[typeName].formats[formatName] | ||
if (format.sigil || format.suffix) | ||
return decoder.sigilSuffix(input, type, format) | ||
else return decoder.ssbURI(input, type, format) | ||
} | ||
module.exports = { | ||
encode, | ||
decode, | ||
decodeTypeFormat, | ||
bfeTypes: definitions, | ||
@@ -300,0 +313,0 @@ bfeNamedTypes: NAMED_TYPES, |
{ | ||
"name": "ssb-bfe", | ||
"description": "Binary Field Encodings (BFE) for Secure Scuttlebutt (SSB)", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"homepage": "https://github.com/ssbc/ssb-bfe", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -41,2 +41,8 @@ <!-- | ||
### `decodeTypeFormat(input, typeName, formatName)` | ||
Takes an encoded value (such as the output from `encode`), a typeName | ||
and formatName and returns the decoded counterparts as JavaScript | ||
primitives. This is much faster than decode if you know the type. | ||
### `bfeTypes` | ||
@@ -43,0 +49,0 @@ |
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
32068
348
137