diff --git a/lib/internal/util.js b/lib/internal/util.js index 113c0c66c0fe47..1a4e8d62477f2a 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -252,6 +252,20 @@ function promisify(orig) { promisify.custom = kCustomPromisifiedSymbol; +// The build-in Array#join is slower in v8 6.0 +function join(output, separator) { + var str = ''; + if (output.length !== 0) { + for (var i = 0; i < output.length - 1; i++) { + // It is faster not to use a template string here + str += output[i]; + str += separator; + } + str += output[i]; + } + return str; +} + module.exports = { assertCrypto, cachedResult, @@ -265,6 +279,7 @@ module.exports = { normalizeEncoding, objectToString, promisify, + join, // Symbol used to customize promisify conversion customPromisifyArgs: kCustomPromisifyArgsSymbol,