Skip to content

Commit 9b976f2

Browse files
committed
feat(migrate): remove lodash.flatten
1 parent 26d9cfd commit 9b976f2

28 files changed

+57
-98
lines changed

packages/sync-actions/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"dependencies": {
2626
"fast-equals": "^2.0.0",
2727
"jsondiffpatch": "^0.4.0",
28-
"lodash.flatten": "^4.4.0",
2928
"lodash.foreach": "^4.5.0",
3029
"lodash.intersection": "^4.4.0",
3130
"lodash.isequal": "^4.5.0",

packages/sync-actions/src/attribute-groups.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import flatten from 'lodash.flatten'
21
import type {
32
SyncAction,
43
ActionGroup,
@@ -36,15 +35,13 @@ function createAttributeGroupsMapActions(
3635
)
3736
)
3837
allActions.push(
39-
flatten(
40-
mapActionGroup(
41-
'attributes',
42-
(): Array<UpdateAction> =>
43-
attributeGroupsActions.actionsMapAttributes(diff, oldObj, newObj)
44-
)
45-
)
38+
mapActionGroup(
39+
'attributes',
40+
(): Array<UpdateAction> =>
41+
attributeGroupsActions.actionsMapAttributes(diff, oldObj, newObj)
42+
).flat()
4643
)
47-
return flatten(allActions)
44+
return allActions.flat()
4845
}
4946
}
5047

packages/sync-actions/src/cart-discounts.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import flatten from 'lodash.flatten'
21
import createBuildActions from './utils/create-build-actions'
32
import createMapActionGroup from './utils/create-map-action-group'
43
import actionsMapCustom from './utils/action-map-custom'
@@ -23,7 +22,7 @@ function createCartDiscountsMapActions(mapActionGroup, syncActionConfig) {
2322
mapActionGroup('custom', () => actionsMapCustom(diff, newObj, oldObj))
2423
)
2524

26-
return combineValidityActions(flatten(allActions))
25+
return combineValidityActions(allActions.flat())
2726
}
2827
}
2928

packages/sync-actions/src/categories.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import flatten from 'lodash.flatten'
21
import type {
32
SyncAction,
43
SyncActionConfig,
@@ -64,7 +63,7 @@ function createCategoryMapActions(
6463
)
6564
)
6665

67-
return flatten(allActions)
66+
return allActions.flat()
6867
}
6968
}
7069

packages/sync-actions/src/channels.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import flatten from 'lodash.flatten'
21
import createBuildActions from './utils/create-build-actions'
32
import createMapActionGroup from './utils/create-map-action-group'
43
import actionsMapCustom from './utils/action-map-custom'
@@ -22,7 +21,7 @@ function createChannelsMapActions(mapActionGroup, syncActionConfig) {
2221
mapActionGroup('custom', () => actionsMapCustom(diff, newObj, oldObj))
2322
)
2423

25-
return flatten(allActions)
24+
return allActions.flat()
2625
}
2726
}
2827

packages/sync-actions/src/customer-group.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import flatten from 'lodash.flatten'
21
import createBuildActions from './utils/create-build-actions'
32
import createMapActionGroup from './utils/create-map-action-group'
43
import actionsMapCustom from './utils/action-map-custom'
@@ -22,7 +21,7 @@ function createCustomerGroupMapActions(mapActionGroup, syncActionConfig) {
2221
mapActionGroup('custom', () => actionsMapCustom(diff, newObj, oldObj))
2322
)
2423

25-
return flatten(allActions)
24+
return allActions.flat()
2625
}
2726
}
2827

packages/sync-actions/src/customers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import flatten from 'lodash.flatten'
21
import type {
32
SyncAction,
43
SyncActionConfig,
@@ -99,7 +98,7 @@ function createCustomerMapActions(
9998
)
10099
)
101100

102-
return flatten(allActions)
101+
return allActions.flat()
103102
}
104103
}
105104

packages/sync-actions/src/discount-codes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import flatten from 'lodash.flatten'
21
import createBuildActions from './utils/create-build-actions'
32
import createMapActionGroup from './utils/create-map-action-group'
43
import actionsMapCustom from './utils/action-map-custom'
@@ -20,7 +19,7 @@ function createDiscountCodesMapActions(mapActionGroup, syncActionConfig) {
2019
allActions.push(
2120
mapActionGroup('custom', () => actionsMapCustom(diff, newObj, oldObj))
2221
)
23-
return combineValidityActions(flatten(allActions))
22+
return combineValidityActions(allActions.flat())
2423
}
2524
}
2625

packages/sync-actions/src/inventories.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import flatten from 'lodash.flatten'
21
import type {
32
SyncAction,
43
SyncActionConfig,
@@ -48,7 +47,7 @@ function createInventoryMapActions(
4847
(): Array<UpdateAction> => actionsMapCustom(diff, newObj, oldObj)
4948
)
5049
)
51-
return flatten(allActions)
50+
return allActions.flat()
5251
}
5352
}
5453

packages/sync-actions/src/orders.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import flatten from 'lodash.flatten'
21
import type {
32
SyncAction,
43
SyncActionConfig,
@@ -72,20 +71,18 @@ function createOrderMapActions(
7271
)
7372

7473
allActions.push(
75-
flatten(
76-
mapActionGroup(
77-
'returnInfo',
78-
(): Array<UpdateAction> =>
79-
orderActions.actionsMapReturnsInfo(diff, oldObj, newObj)
80-
)
81-
)
74+
mapActionGroup(
75+
'returnInfo',
76+
(): Array<UpdateAction> =>
77+
orderActions.actionsMapReturnsInfo(diff, oldObj, newObj)
78+
).flat()
8279
)
8380

8481
allActions.push(
8582
mapActionGroup('custom', () => actionsMapCustom(diff, newObj, oldObj))
8683
)
8784

88-
return flatten(allActions)
85+
return allActions.flat()
8986
}
9087
}
9188

0 commit comments

Comments
 (0)