Skip to content

Commit

Permalink
refactor(publicodes-state): reviewed helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileRolley committed Oct 13, 2023
1 parent c928189 commit 680dfa0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/publicodes-state/helpers/safeEvaluateHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Engine, NGCEvaluatedNode } from '../types'
import { Engine, NGCEvaluatedNode, RuleName } from '../types'

export const safeEvaluateHelper = (
rule: string,
rule: RuleName,
engineUsed: Engine
): NGCEvaluatedNode | null => {
try {
Expand Down
14 changes: 7 additions & 7 deletions src/publicodes-state/helpers/safeGetSituation.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { NodeValue, Situation } from '../types'
import { RuleName, Situation } from '../types'

export const safeGetSituation = ({
situation,
everyRules,
}: {
situation: Situation
everyRules: string[]
}): any =>
everyRules: RuleName[]
}): Situation =>
everyRules
.filter((rule: string) => situation[rule] || situation[rule] === 0)
.filter((rule: RuleName) => situation[rule] || situation[rule] === 0)
.reduce(
(accumulator: Record<string, NodeValue>, currentValue: string) => ({
...accumulator,
[currentValue]: situation[currentValue],
(situationAcc: Situation, currentRule: RuleName) => ({
...situationAcc,
[currentRule]: situation[currentRule],
}),
{}
)

0 comments on commit 680dfa0

Please sign in to comment.