Skip to content

Commit

Permalink
fastArrayJoin()
Browse files Browse the repository at this point in the history
  • Loading branch information
piliugin-anton committed Jul 23, 2022
1 parent dc16960 commit 70c9267
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 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.50",
"version": "1.0.51",
"description": "uQuik HTTP(S) framework",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 7 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,14 @@ const fastArrayJoin = (array, separator = '') => {
let result = ''
const last = length - 1
for (let i = 0; i < length; i++) {
if (array[i] === undefined || array[i] === null) {
if (array[i] === null || array[i] === undefined) {
if (i !== last) result += separator
} else if (typeof array[i] === 'object') {
const value = array[i].toString()
} else if (typeof array[i] === 'object' || typeof array[i] === 'function') {
let value = '[object Object]'
if (typeof array[i].toString === 'function') {
const toStringValue = array[i].toString()
if (typeof toStringValue === 'string') value = toStringValue
}
result += i !== last ? value + separator : value
} else {
result += i !== last ? array[i] + separator : array[i]
Expand Down

0 comments on commit 70c9267

Please sign in to comment.