Skip to content

Commit 178d82f

Browse files
committed
fix: Removed reference sharing in return values to prevent potential mutability issues
Signed-off-by: Jaid <jaid.jsx@gmail.com>
1 parent 5e3a3b4 commit 178d82f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
const debug = require("debug")(_PKG_NAME)
2121

22-
const emptyReturn = {}
23-
2422
/**
2523
* Converts an array to an object with static keys and customizable values
2624
* @example
@@ -42,7 +40,7 @@ const emptyReturn = {}
4240
*/
4341
export default (array, valueGenerator = null) => {
4442
if (!Array.isArray(array) || !array.length) {
45-
return emptyReturn
43+
return {}
4644
}
4745
const object = {}
4846
if (typeof valueGenerator === "function") {
@@ -84,7 +82,7 @@ export default (array, valueGenerator = null) => {
8482
*/
8583
export const parallel = async (array, valueGenerator = null) => {
8684
if (!Array.isArray(array) || !array.length) {
87-
return emptyReturn
85+
return {}
8886
}
8987
const object = {}
9088
if (typeof valueGenerator === "function") {

0 commit comments

Comments
 (0)