MCPcopy Create free account
hub / github.com/RubyLouvre/anu / formatPrimitive

Function formatPrimitive

test/babel.js:10917–10927  ·  view source on GitHub ↗
(ctx, value)

Source from the content-addressed store, hash-verified

10915 }
10916
10917 function formatPrimitive(ctx, value) {
10918 if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
10919 if (isString(value)) {
10920 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
10921 return ctx.stylize(simple, 'string');
10922 }
10923 if (isNumber(value)) return ctx.stylize('' + value, 'number');
10924 if (isBoolean(value)) return ctx.stylize('' + value, 'boolean');
10925 // For some reason typeof null is "object", so special case here.
10926 if (isNull(value)) return ctx.stylize('null', 'null');
10927 }
10928
10929 function formatError(value) {
10930 return '[' + Error.prototype.toString.call(value) + ']';

Callers 1

formatValueFunction · 0.85

Calls 5

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

Tested by

no test coverage detected