New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ndn/tlv

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndn/tlv - npm Package Compare versions

Comparing version 0.0.20240630 to 0.0.20250122

2

lib/ev-decoder_browser.js

@@ -33,3 +33,3 @@ import { assert } from "@ndn/util";

this.typeName = typeName;
this.topTT = Array.isArray(topTT) ? topTT : [topTT];
this.topTT = typeof topTT === "number" ? [topTT] : topTT;
}

@@ -36,0 +36,0 @@ applyDefaultsToRuleOptions({ order = (this.nextOrder += AUTO_ORDER_SKIP), required = false, repeat = false, } = {}) {

@@ -33,3 +33,3 @@ import { assert } from "@ndn/util";

this.typeName = typeName;
this.topTT = Array.isArray(topTT) ? topTT : [topTT];
this.topTT = typeof topTT === "number" ? [topTT] : topTT;
}

@@ -36,0 +36,0 @@ applyDefaultsToRuleOptions({ order = (this.nextOrder += AUTO_ORDER_SKIP), required = false, repeat = false, } = {}) {

@@ -0,1 +1,2 @@

import type { Arrayable } from "type-fest";
import type { Decoder } from "./decoder.js";

@@ -23,3 +24,3 @@ /**

*/
constructor(typeName: string, topTT?: number | readonly number[]);
constructor(typeName: string, topTT?: Arrayable<number>);
applyDefaultsToRuleOptions({ order, required, repeat, }?: EvDecoder.RuleOptions): Required<EvDecoder.RuleOptions>;

@@ -26,0 +27,0 @@ /**

@@ -1,6 +0,8 @@

import { __importDefault, __importStar } from "tslib";
import _cjsDefaultImport0 from "mnemonist/default-weak-map.js"; const DefaultWeakMap = __importDefault(_cjsDefaultImport0).default;
import { getOrInsert } from "@ndn/util";
import { EvDecoder } from "./ev-decoder_browser.js";
import { encodeFields, makeField, sortFields } from "./impl-field_browser.js";
const RECORDS = new DefaultWeakMap(() => ({}));
const RECORDS = new WeakMap();
function getOrCreateRecord(obj) {
return getOrInsert(RECORDS, obj, () => ({}));
}
export var Extensible;

@@ -11,3 +13,3 @@ (function (Extensible) {

function cloneRecord(dst, src) {
const record = RECORDS.peek(src);
const record = RECORDS.get(src);
if (record !== undefined) {

@@ -47,3 +49,3 @@ RECORDS.set(dst, record);

function get(obj, tt) {
return RECORDS.peek(obj)?.[`ext_${tt}`];
return RECORDS.get(obj)?.[`ext_${tt}`];
}

@@ -53,3 +55,3 @@ Extension.get = get;

function set(obj, tt, value) {
RECORDS.get(obj)[`ext_${tt}`] = value;
getOrCreateRecord(obj)[`ext_${tt}`] = value;
}

@@ -59,3 +61,3 @@ Extension.set = set;

function clear(obj, tt) {
delete RECORDS.peek(obj)?.[`ext_${tt}`];
delete RECORDS.get(obj)?.[`ext_${tt}`];
}

@@ -82,3 +84,3 @@ Extension.clear = clear;

decodeUnknown = (target, tlv) => {
const record = RECORDS.get(target);
const record = getOrCreateRecord(target);
this.hasUnrecognized = false;

@@ -90,3 +92,3 @@ this.evd.decodeValue(record, tlv.decoder);

encode(source) {
const record = RECORDS.peek(source);
const record = RECORDS.get(source);
if (!record) {

@@ -93,0 +95,0 @@ return [];

@@ -1,6 +0,8 @@

import { __importDefault, __importStar } from "tslib";
import _cjsDefaultImport0 from "mnemonist/default-weak-map.js"; const DefaultWeakMap = __importDefault(_cjsDefaultImport0).default;
import { getOrInsert } from "@ndn/util";
import { EvDecoder } from "./ev-decoder_node.js";
import { encodeFields, makeField, sortFields } from "./impl-field_node.js";
const RECORDS = new DefaultWeakMap(() => ({}));
const RECORDS = new WeakMap();
function getOrCreateRecord(obj) {
return getOrInsert(RECORDS, obj, () => ({}));
}
export var Extensible;

@@ -11,3 +13,3 @@ (function (Extensible) {

function cloneRecord(dst, src) {
const record = RECORDS.peek(src);
const record = RECORDS.get(src);
if (record !== undefined) {

@@ -47,3 +49,3 @@ RECORDS.set(dst, record);

function get(obj, tt) {
return RECORDS.peek(obj)?.[`ext_${tt}`];
return RECORDS.get(obj)?.[`ext_${tt}`];
}

@@ -53,3 +55,3 @@ Extension.get = get;

function set(obj, tt, value) {
RECORDS.get(obj)[`ext_${tt}`] = value;
getOrCreateRecord(obj)[`ext_${tt}`] = value;
}

@@ -59,3 +61,3 @@ Extension.set = set;

function clear(obj, tt) {
delete RECORDS.peek(obj)?.[`ext_${tt}`];
delete RECORDS.get(obj)?.[`ext_${tt}`];
}

@@ -82,3 +84,3 @@ Extension.clear = clear;

decodeUnknown = (target, tlv) => {
const record = RECORDS.get(target);
const record = getOrCreateRecord(target);
this.hasUnrecognized = false;

@@ -90,3 +92,3 @@ this.evd.decodeValue(record, tlv.decoder);

encode(source) {
const record = RECORDS.peek(source);
const record = RECORDS.get(source);
if (!record) {

@@ -93,0 +95,0 @@ return [];

export function makeField(tt, key, type, opts, evd) {
const fo = { ...opts, ...(evd ? evd.applyDefaultsToRuleOptions(opts) : {
order: tt,
required: false,
repeat: false,
}) };
const fo = evd.applyDefaultsToRuleOptions(opts);
evd.add(tt, fo.repeat ?

@@ -8,0 +4,0 @@ (t, tlv) => t[key].push(type.decode(tlv)) :

export function makeField(tt, key, type, opts, evd) {
const fo = { ...opts, ...(evd ? evd.applyDefaultsToRuleOptions(opts) : {
order: tt,
required: false,
repeat: false,
}) };
const fo = evd.applyDefaultsToRuleOptions(opts);
evd.add(tt, fo.repeat ?

@@ -8,0 +4,0 @@ (t, tlv) => t[key].push(type.decode(tlv)) :

@@ -11,9 +11,4 @@ import type { Encodable, Encoder } from "./encoder.js";

}
interface Options extends EvDecoder.RuleOptions {
required?: boolean;
repeat?: boolean;
}
export declare function makeField<T>(tt: number, key: string, type: StructFieldType<T>, opts: Options, evd: EvDecoder<any>): Field<T[]> | Field<T | undefined>;
export declare function makeField<T>(tt: number, key: string, type: StructFieldType<T>, opts: EvDecoder.RuleOptions, evd: EvDecoder<any>): Field<T[]> | Field<T | undefined>;
export declare function sortFields(fields: Array<Field<any>>): void;
export declare function encodeFields(fields: ReadonlyArray<Field<any>>, obj: Record<string, any>): Encodable[];
export {};
import { assert } from "@ndn/util";
import {} from "./decoder_browser.js";
import {} from "./encoder_browser.js";
import { EvDecoder } from "./ev-decoder_browser.js";

@@ -41,6 +43,10 @@ import { encodeFields, makeField, sortFields } from "./impl-field_browser.js";

EVD;
/** Return field names. */
get keys() {
return this.fields.map(({ key }) => key);
/** Access EvDecoder for certain customizations. */
static evdOf(sb) {
return sb.EVD;
}
/** Retrieve field names. */
static keysOf(sb) {
return sb.fields.map(({ key }) => key);
}
/**

@@ -47,0 +53,0 @@ * Add a field.

import { assert } from "@ndn/util";
import {} from "./decoder_node.js";
import {} from "./encoder_node.js";
import { EvDecoder } from "./ev-decoder_node.js";

@@ -41,6 +43,10 @@ import { encodeFields, makeField, sortFields } from "./impl-field_node.js";

EVD;
/** Return field names. */
get keys() {
return this.fields.map(({ key }) => key);
/** Access EvDecoder for certain customizations. */
static evdOf(sb) {
return sb.EVD;
}
/** Retrieve field names. */
static keysOf(sb) {
return sb.fields.map(({ key }) => key);
}
/**

@@ -47,0 +53,0 @@ * Add a field.

@@ -1,2 +0,2 @@

import type { Constructor, IfNever, Simplify } from "type-fest";
import type { Constructor, Except, IfNever, Simplify } from "type-fest";
import { type Decodable } from "./decoder.js";

@@ -75,8 +75,10 @@ import { type EncodableObj } from "./encoder.js";

*/
subclass?: Constructor<U, []>;
subclass?: Constructor<U, []> & Decodable<U>;
private readonly fields;
private readonly flagBits;
private readonly EVD;
/** Return field names. */
get keys(): string[];
/** Access EvDecoder for certain customizations. */
static evdOf<U extends {}>(sb: StructBuilder<U>): Except<EvDecoder<U>, "add">;
/** Retrieve field names. */
static keysOf<U extends {}>(sb: StructBuilder<U>): Array<keyof U>;
/**

@@ -83,0 +85,0 @@ * Add a field.

@@ -123,2 +123,3 @@ import { toHex, toUtf8 } from "@ndn/util";

decode: ({ text }) => text,
asString: (value) => JSON.stringify(value),
};

@@ -125,0 +126,0 @@ /**

@@ -123,2 +123,3 @@ import { toHex, toUtf8 } from "@ndn/util";

decode: ({ text }) => text,
asString: (value) => JSON.stringify(value),
};

@@ -125,0 +126,0 @@ /**

{
"name": "@ndn/tlv",
"version": "0.0.20240630",
"version": "0.0.20250122",
"description": "NDNts: TLV",

@@ -25,8 +25,7 @@ "keywords": [

"dependencies": {
"@ndn/util": "0.0.20240630",
"mnemonist": "^0.39.8",
"tslib": "^2.6.3",
"type-fest": "^4.20.1"
"@ndn/util": "0.0.20250122",
"tslib": "^2.8.1",
"type-fest": "^4.33.0"
},
"types": "lib/mod.d.ts"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc