MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / formatPrimitive

Function formatPrimitive

lib/web/jshint.js:1123–1139  ·  view source on GitHub ↗
(ctx, value)

Source from the content-addressed store, hash-verified

1121
1122
1123function formatPrimitive(ctx, value) {
1124 if (isUndefined(value))
1125 return ctx.stylize('undefined', 'undefined');
1126 if (isString(value)) {
1127 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
1128 .replace(/'/g, "\\'")
1129 .replace(/\\"/g, '"') + '\'';
1130 return ctx.stylize(simple, 'string');
1131 }
1132 if (isNumber(value))
1133 return ctx.stylize('' + value, 'number');
1134 if (isBoolean(value))
1135 return ctx.stylize('' + value, 'boolean');
1136 // For some reason typeof null is "object", so special case here.
1137 if (isNull(value))
1138 return ctx.stylize('null', 'null');
1139}
1140
1141
1142function formatError(value) {

Callers 1

formatValueFunction · 0.85

Calls 6

isUndefinedFunction · 0.85
isStringFunction · 0.85
isBooleanFunction · 0.85
isNullFunction · 0.85
replaceMethod · 0.80
isNumberFunction · 0.70

Tested by

no test coverage detected