Skip to content

Commit f4aa7be

Browse files
authored
Delete values regardless of whether they are truthy (#15)
* Delete values when they are not truthy * Drop contractId when not truthy * change contractId order
1 parent 2a38188 commit f4aa7be

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/handleEvent.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ export function handleEvent<Context = unknown, Event = unknown>(
9191
conditionResult = test(
9292
handler.Condition,
9393
{
94-
Value: event,
94+
...(newContext || {}),
9595
...(options.contractId && {
9696
ContractId: options.contractId,
9797
}),
98-
...(newContext || {}),
9998
...(definition.Constants || {}),
99+
Value: event,
100100
},
101101
{
102102
pushUniqueAction(reference, item) {
@@ -155,30 +155,28 @@ export function handleEvent<Context = unknown, Event = unknown>(
155155
[action]: actionSet[action],
156156
},
157157
{
158-
Value: event,
158+
...newContext,
159159
...(options.contractId && {
160160
ContractId: options.contractId,
161161
}),
162-
...newContext,
163162
...(definition.Constants || {}),
163+
Value: event,
164164
},
165165
{
166-
originalContext: definition.Context ?? {}
167-
},
166+
originalContext: definition.Context ?? {},
167+
}
168168
)
169169
}
170170
}
171171

172172
// drop this specific event's value
173-
// @ts-expect-error
174-
if (newContext.Value) {
173+
if (newContext.hasOwnProperty("Value")) {
175174
// @ts-expect-error
176175
delete newContext.Value
177176
}
178177

179178
// drop this specific event's ContractId
180-
// @ts-expect-error
181-
if (newContext.ContractId) {
179+
if (newContext.hasOwnProperty("ContractId")) {
182180
// @ts-expect-error
183181
delete newContext.ContractId
184182
}

0 commit comments

Comments
 (0)