@ndn/endpoint
Advanced tools
Comparing version 0.0.20220501 to 0.0.20230121
@@ -15,8 +15,6 @@ import { CancelInterest, FwPacket } from "@ndn/fw"; | ||
const promise = new Promise((resolve, reject) => { | ||
const rx = pushable(); | ||
const rx = pushable({ objectMode: true }); | ||
let timer; | ||
const cancelRetx = () => { | ||
if (timer) { | ||
clearTimeout(timer); | ||
} | ||
clearTimeout(timer); | ||
timer = undefined; | ||
@@ -23,0 +21,0 @@ }; |
@@ -15,8 +15,6 @@ import { CancelInterest, FwPacket } from "@ndn/fw"; | ||
const promise = new Promise((resolve, reject) => { | ||
const rx = pushable(); | ||
const rx = pushable({ objectMode: true }); | ||
let timer; | ||
const cancelRetx = () => { | ||
if (timer) { | ||
clearTimeout(timer); | ||
} | ||
clearTimeout(timer); | ||
timer = undefined; | ||
@@ -23,0 +21,0 @@ }; |
import { type Forwarder } from "@ndn/fw"; | ||
import { type NameLike, type Verifier, Data, Interest } from "@ndn/packet"; | ||
import { type RetxPolicy } from "./retx"; | ||
import { type RetxPolicy } from "./retx.js"; | ||
export interface ConsumerOptions { | ||
@@ -5,0 +5,0 @@ /** Description for debugging purpose. */ |
@@ -13,2 +13,3 @@ import { assert } from "@ndn/util"; | ||
export class DataStoreBuffer { | ||
store; | ||
constructor(store, { ttl = 60000, dataSigner, } = {}) { | ||
@@ -20,2 +21,4 @@ this.store = store; | ||
} | ||
ttl; | ||
dataSigner; | ||
find(interest) { | ||
@@ -22,0 +25,0 @@ return this.store.find(interest); |
@@ -13,2 +13,3 @@ import { assert } from "@ndn/util"; | ||
export class DataStoreBuffer { | ||
store; | ||
constructor(store, { ttl = 60000, dataSigner, } = {}) { | ||
@@ -20,2 +21,4 @@ this.store = store; | ||
} | ||
ttl; | ||
dataSigner; | ||
find(interest) { | ||
@@ -22,0 +25,0 @@ return this.store.find(interest); |
@@ -11,2 +11,4 @@ import { __importDefault, __importStar } from "tslib"; | ||
export class Endpoint { | ||
opts; | ||
fw; | ||
constructor(opts = {}) { | ||
@@ -13,0 +15,0 @@ this.opts = opts; |
@@ -11,2 +11,4 @@ import { __importDefault, __importStar } from "tslib"; | ||
export class Endpoint { | ||
opts; | ||
fw; | ||
constructor(opts = {}) { | ||
@@ -13,0 +15,0 @@ this.opts = opts; |
import { Forwarder } from "@ndn/fw"; | ||
import { type ConsumerOptions, EndpointConsumer } from "./consumer"; | ||
import { type ProducerOptions, EndpointProducer } from "./producer"; | ||
import { type ConsumerOptions, EndpointConsumer } from "./consumer.js"; | ||
import { type ProducerOptions, EndpointProducer } from "./producer.js"; | ||
export interface Options extends ConsumerOptions, ProducerOptions { | ||
@@ -5,0 +5,0 @@ fw?: Forwarder; |
@@ -1,5 +0,5 @@ | ||
export type { RetxOptions, RetxPolicy } from "./retx"; | ||
export type { ConsumerContext, ConsumerOptions } from "./consumer"; | ||
export { DataBuffer, DataStoreBuffer } from "./data-buffer"; | ||
export type { ProducerHandler, ProducerOptions, Producer } from "./producer"; | ||
export * from "./endpoint"; | ||
export type { RetxOptions, RetxPolicy } from "./retx.js"; | ||
export type { ConsumerContext, ConsumerOptions } from "./consumer.js"; | ||
export { type DataBuffer, DataStoreBuffer } from "./data-buffer.js"; | ||
export type { ProducerHandler, ProducerOptions, Producer } from "./producer.js"; | ||
export * from "./endpoint.js"; |
import { type Forwarder, type FwFace } from "@ndn/fw"; | ||
import { type NameLike, type Signer, Data, Interest, Name } from "@ndn/packet"; | ||
import type { DataBuffer } from "./data-buffer"; | ||
import type { DataBuffer } from "./data-buffer.js"; | ||
/** | ||
@@ -14,3 +14,3 @@ * Producer handler function. | ||
*/ | ||
export declare type ProducerHandler = (interest: Interest, producer: Producer) => Promise<Data | undefined>; | ||
export type ProducerHandler = (interest: Interest, producer: Producer) => Promise<Data | undefined>; | ||
export interface ProducerOptions { | ||
@@ -17,0 +17,0 @@ /** Description for debugging purpose. */ |
@@ -0,1 +1,2 @@ | ||
import { randomJitter } from "@ndn/util"; | ||
/** Construct RetxGenerator from RetxPolicy. */ | ||
@@ -14,5 +15,6 @@ export function makeRetxGenerator(policy) { | ||
const { limit = 0, interval = interestLifetime * 0.5, randomize = 0.1, backoff = 1, max = interestLifetime * 0.9, } = policy; | ||
const jitter = randomJitter(randomize); | ||
let nextInterval = interval; | ||
for (let i = 0; i < limit; ++i) { | ||
yield nextInterval * (1 - randomize + Math.random() * 2 * randomize); | ||
yield nextInterval * jitter(); | ||
nextInterval = Math.min(nextInterval * backoff, max); | ||
@@ -19,0 +21,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { randomJitter } from "@ndn/util"; | ||
/** Construct RetxGenerator from RetxPolicy. */ | ||
@@ -14,5 +15,6 @@ export function makeRetxGenerator(policy) { | ||
const { limit = 0, interval = interestLifetime * 0.5, randomize = 0.1, backoff = 1, max = interestLifetime * 0.9, } = policy; | ||
const jitter = randomJitter(randomize); | ||
let nextInterval = interval; | ||
for (let i = 0; i < limit; ++i) { | ||
yield nextInterval * (1 - randomize + Math.random() * 2 * randomize); | ||
yield nextInterval * jitter(); | ||
nextInterval = Math.min(nextInterval * backoff, max); | ||
@@ -19,0 +21,0 @@ } |
@@ -37,3 +37,3 @@ /** Interest retransmission policy options. */ | ||
/** A function to generate retx intervals. */ | ||
export declare type RetxGenerator = (interestLifetime: number) => Iterable<number>; | ||
export type RetxGenerator = (interestLifetime: number) => Iterable<number>; | ||
/** | ||
@@ -45,4 +45,4 @@ * Interest retransmission policy. | ||
*/ | ||
export declare type RetxPolicy = RetxOptions | RetxGenerator | number; | ||
export type RetxPolicy = RetxOptions | RetxGenerator | number; | ||
/** Construct RetxGenerator from RetxPolicy. */ | ||
export declare function makeRetxGenerator(policy: RetxPolicy | undefined): RetxGenerator; |
{ | ||
"name": "@ndn/endpoint", | ||
"version": "0.0.20220501", | ||
"version": "0.0.20230121", | ||
"description": "NDNts: Client Endpoint", | ||
@@ -25,12 +25,11 @@ "keywords": [ | ||
"dependencies": { | ||
"@ndn/fw": "0.0.20220501", | ||
"@ndn/packet": "0.0.20220501", | ||
"@ndn/util": "0.0.20220501", | ||
"@ndn/fw": "0.0.20230121", | ||
"@ndn/packet": "0.0.20230121", | ||
"@ndn/util": "0.0.20230121", | ||
"applymixins": "^1.1.0", | ||
"it-pushable": "^2.0.1", | ||
"streaming-iterables": "^7.0.2", | ||
"tslib": "^2.4.0" | ||
"it-pushable": "^3.1.2", | ||
"streaming-iterables": "^7.1.0", | ||
"tslib": "^2.4.1" | ||
}, | ||
"types": "lib/mod.d.ts", | ||
"readme": "# @ndn/endpoint\n\nThis package is part of [NDNts](https://yoursunny.com/p/NDNts/), Named Data Networking libraries for the modern web.\n\nThis package implements **Endpoint** type, which is the basic abstraction through which an application can communicate with the NDN network.\n\nAn endpoint is similar to a \"client face\" in other NDN libraries, with the enhancement that it handles these details automatically:\n\n* [X] Outgoing packets are signed and incoming packets are verified, if trust schema is provided.\n* [X] Outgoing Interests are retransmitted periodically, if retransmission policy is specified.\n* [X] Outgoing Data buffer, if enabled, allows the producer to reply to one Interest with multiple Data (e.g. segments), or push generated Data without receiving an Interest.\n Data will be sent automatically upon Interest arrival.\n* [X] The underlying transport is reconnected upon failure, if transport failure policy is specified (implemented in `@ndn/l3face` package).\n* [ ] Prefix registrations are refreshed periodically or upon transport reconnection.\n" | ||
"types": "lib/mod.d.ts" | ||
} |
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
692
28582
+ Added@ndn/fw@0.0.20230121(transitive)
+ Added@ndn/packet@0.0.20230121(transitive)
+ Added@ndn/tlv@0.0.20230121(transitive)
+ Added@ndn/util@0.0.20230121(transitive)
+ Addedhirestime@7.0.4(transitive)
+ Addedit-pushable@3.2.3(transitive)
+ Addedp-defer@4.0.1(transitive)
- Removed@ndn/fw@0.0.20220501(transitive)
- Removed@ndn/packet@0.0.20220501(transitive)
- Removed@ndn/tlv@0.0.20220501(transitive)
- Removed@ndn/util@0.0.20220501(transitive)
- Removedhirestime@6.1.0(transitive)
- Removedit-pushable@2.0.2(transitive)
Updated@ndn/fw@0.0.20230121
Updated@ndn/packet@0.0.20230121
Updated@ndn/util@0.0.20230121
Updatedit-pushable@^3.1.2
Updatedstreaming-iterables@^7.1.0
Updatedtslib@^2.4.1