MCPcopy Index your code
hub / github.com/ddopson/underscore-cli / formatArray

Function formatArray

lib/formatter.js:245–267  ·  view source on GitHub ↗
(ctx, value)

Source from the content-addressed store, hash-verified

243}
244
245function formatArray(ctx, value) {
246 ctx.seen.push(value);
247
248 var output = [];
249 for (var i = 0, l = value.length; i < l; ++i) {
250 if (Object.prototype.hasOwnProperty.call(value, String(i))) {
251 if (ctx.jsonParity && value[i] === undefined) {
252 // jsonParity: when array entries are equal to 'undefined', JSON.stringify prints 'null'
253 output.push(ctx.stylize('null', 'null'));
254 } else {
255 output.push(formatProperty(ctx, value, String(i), false, true));
256 }
257 } else {
258 // jsonParity: when value entries are unset, JSON.stringify prints 'null'
259 output.push(ctx.jsonParity ? ctx.stylize('null', 'null') : '');
260 }
261 }
262
263
264 ctx.seen.pop();
265
266 return joinCollection(ctx, output, '[', ']');
267}
268
269function formatObject(ctx, value, type) {
270 ctx.seen.push(value);

Callers 1

formatValueFunction · 0.85

Calls 2

formatPropertyFunction · 0.85
joinCollectionFunction · 0.85

Tested by

no test coverage detected