mirror of
https://github.com/pockethost/pockethost.git
synced 2025-05-31 03:06:41 +00:00
feat(pockethost): extensible filter data types
This commit is contained in:
parent
dd3ceaa324
commit
82dde2db37
5
.changeset/violet-hats-brake.md
Normal file
5
.changeset/violet-hats-brake.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'pockethost': minor
|
||||
---
|
||||
|
||||
Enhancement: filters now have extensible data types
|
@ -81,8 +81,15 @@ function createCustomFilterWithContext<TCarry, TContext extends {} = {}>(
|
||||
return [
|
||||
async (initialValue: TCarry, context: TContext) =>
|
||||
filter<TCarry, TContext>(filterName, initialValue, context),
|
||||
async (handler: FilterHandler<TCarry, TContext>, priority = 10) =>
|
||||
registerFilter<TCarry, TContext>(filterName, handler, priority),
|
||||
async <TExtraCarry = unknown>(
|
||||
handler: FilterHandler<TCarry & TExtraCarry, TContext>,
|
||||
priority = 10,
|
||||
) =>
|
||||
registerFilter<TCarry & TExtraCarry, TContext>(
|
||||
filterName,
|
||||
handler,
|
||||
priority,
|
||||
),
|
||||
] as const
|
||||
}
|
||||
|
||||
@ -90,8 +97,11 @@ function createCustomFilter<TCarry>(filterName: string) {
|
||||
return [
|
||||
async (initialValue: TCarry) =>
|
||||
filter<TCarry>(filterName, initialValue, {}),
|
||||
async (handler: FilterHandler<TCarry, {}>, priority = 10) =>
|
||||
registerFilter<TCarry, {}>(filterName, handler, priority),
|
||||
async <TExtraCarry = unknown>(
|
||||
handler: FilterHandler<TCarry & TExtraCarry, {}>,
|
||||
priority = 10,
|
||||
) =>
|
||||
registerFilter<TCarry & TExtraCarry, {}>(filterName, handler, priority),
|
||||
] as const
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user