-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
53 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { Forwarder } from "@ndn/fw"; | ||
|
||
export interface CommonOptions { | ||
/** | ||
* Logical forwarder instance. | ||
* @defaultValue `Forwarder.getDefault()` | ||
*/ | ||
fw?: Forwarder; | ||
|
||
/** | ||
* Description for debugging purpose. | ||
* @defaultValue | ||
* In a consumer, "consume" + Interest name. | ||
* In a producer, "produce" + main prefix. | ||
*/ | ||
describe?: string; | ||
|
||
/** | ||
* AbortSignal that allows cancelation via AbortController. | ||
* | ||
* @remarks | ||
* In a consumer, the promise returned by consume() is rejected. | ||
* In a producer, the producer is closed. | ||
*/ | ||
signal?: AbortSignal; | ||
} | ||
|
||
const commonKeys: readonly string[] = [ | ||
"fw", "describe", "signal", | ||
] satisfies ReadonlyArray<keyof CommonOptions>; | ||
|
||
export function exactOptions<O extends CommonOptions>(opts: O, keys: ReadonlyArray<keyof O>): O { | ||
return Object.fromEntries(Object.entries(opts).filter( | ||
([key]) => commonKeys.includes(key) || (keys as readonly string[]).includes(key)), | ||
) as O; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters