mirror of
https://github.com/pockethost/pockethost.git
synced 2025-06-05 21:56:48 +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 [
|
return [
|
||||||
async (initialValue: TCarry, context: TContext) =>
|
async (initialValue: TCarry, context: TContext) =>
|
||||||
filter<TCarry, TContext>(filterName, initialValue, context),
|
filter<TCarry, TContext>(filterName, initialValue, context),
|
||||||
async (handler: FilterHandler<TCarry, TContext>, priority = 10) =>
|
async <TExtraCarry = unknown>(
|
||||||
registerFilter<TCarry, TContext>(filterName, handler, priority),
|
handler: FilterHandler<TCarry & TExtraCarry, TContext>,
|
||||||
|
priority = 10,
|
||||||
|
) =>
|
||||||
|
registerFilter<TCarry & TExtraCarry, TContext>(
|
||||||
|
filterName,
|
||||||
|
handler,
|
||||||
|
priority,
|
||||||
|
),
|
||||||
] as const
|
] as const
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,8 +97,11 @@ function createCustomFilter<TCarry>(filterName: string) {
|
|||||||
return [
|
return [
|
||||||
async (initialValue: TCarry) =>
|
async (initialValue: TCarry) =>
|
||||||
filter<TCarry>(filterName, initialValue, {}),
|
filter<TCarry>(filterName, initialValue, {}),
|
||||||
async (handler: FilterHandler<TCarry, {}>, priority = 10) =>
|
async <TExtraCarry = unknown>(
|
||||||
registerFilter<TCarry, {}>(filterName, handler, priority),
|
handler: FilterHandler<TCarry & TExtraCarry, {}>,
|
||||||
|
priority = 10,
|
||||||
|
) =>
|
||||||
|
registerFilter<TCarry & TExtraCarry, {}>(filterName, handler, priority),
|
||||||
] as const
|
] as const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user