(ctx, entries, b1, b2, insideObject)
| 214 | |
| 215 | |
| 216 | function joinCollection(ctx, entries, b1, b2, insideObject) { |
| 217 | if (entries.length === 0) { |
| 218 | return b1 + ctx.space + b2; |
| 219 | } |
| 220 | var shouldWrap = false; |
| 221 | var length = b1.length + b2.length; |
| 222 | if (ctx.wrapWidth >= 0) { |
| 223 | length += (entries.length - 1) * (1 + ctx.space.length); // separators |
| 224 | for(var i = 0, l = entries.length; i < l; i++) { |
| 225 | length += (entries[i].real_length || entries[i].length); |
| 226 | if (length > ctx.wrapWidth) { |
| 227 | shouldWrap = true; |
| 228 | break; |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | var ret; |
| 234 | if (shouldWrap) { |
| 235 | ret = b1 + ctx.cr + ctx.indent + entries.join(',' + ctx.cr + ctx.indent) + ctx.cr + b2; |
| 236 | } else { |
| 237 | var sp = insideObject ? ctx.space : ''; |
| 238 | ret = b1 + sp + entries.join(',' + ctx.space) + sp + b2; |
| 239 | ret = new String(ret); |
| 240 | ret.real_length = length; // needed for correct line wrapping in the presence of ANSI color escapes |
| 241 | } |
| 242 | return ret; |
| 243 | } |
| 244 | |
| 245 | function formatArray(ctx, value) { |
| 246 | ctx.seen.push(value); |
no outgoing calls
no test coverage detected