Skip to content

Commit 7655f0c

Browse files
fastArrayJoin()
1 parent f91f10a commit 7655f0c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/utils.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,10 @@ const byteToHex = [
260260
const fastArrayJoin = (array, separator = '') => {
261261
const length = array.length
262262
let result = ''
263-
let firstAdded = false
263+
const last = length - 1
264264
for (let i = 0; i < length; i++) {
265-
if (array[i] === undefined || array[i] === null) continue
266-
267-
result += firstAdded ? separator + array[i] : array[i]
268-
269-
if (!firstAdded) firstAdded = true
265+
const value = array[i] === undefined || array[i] === null ? '' : array[i]
266+
result += i !== last ? value + separator : value
270267
}
271268
return result
272269
}

0 commit comments

Comments
 (0)