Skip to content

Commit 3b7a006

Browse files
authored
Fixed mutation issue
2 parents b628538 + a18efb8 commit 3b7a006

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@flipbyte/when-condition",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Check conditional statements and return true/false",
55
"main": "lib/index.js",
66
"module": "es/index.js",

src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,17 @@ const when = (conditions, data) => {
8383
return processRule(conditions, data);
8484
}
8585

86-
var type = conditions.shift();
87-
var result = conditions.map((condition, index) => {
86+
var logicalRule = conditions.slice(0, 1)[0];
87+
var comparisonRules = conditions.slice(1);
88+
var result = comparisonRules.map((condition, index) => {
8889
if (isValidCondition(condition)) {
8990
return when(condition, data)
9091
}
9192

9293
return processRule(condition, data);
9394
})
9495

95-
return processCondition(type, result)
96+
return processCondition(logicalRule, result)
9697
}
9798

9899
export default when;

0 commit comments

Comments
 (0)