Skip to content

Commit

Permalink
fastArrayJoin() optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
piliugin-anton committed Jul 23, 2022
1 parent 7655f0c commit dc16960
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uquik",
"version": "1.0.49",
"version": "1.0.50",
"description": "uQuik HTTP(S) framework",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 8 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,14 @@ const fastArrayJoin = (array, separator = '') => {
let result = ''
const last = length - 1
for (let i = 0; i < length; i++) {
const value = array[i] === undefined || array[i] === null ? '' : array[i]
result += i !== last ? value + separator : value
if (array[i] === undefined || array[i] === null) {
if (i !== last) result += separator
} else if (typeof array[i] === 'object') {
const value = array[i].toString()
result += i !== last ? value + separator : value
} else {
result += i !== last ? array[i] + separator : array[i]
}
}
return result
}
Expand Down

0 comments on commit dc16960

Please sign in to comment.