MCPcopy Index your code
hub / github.com/microsoft/SandDance / formatPrimitive

Function formatPrimitive

docs/tests/v2/es6/js/sanddance.js:8004–8016  ·  view source on GitHub ↗
(ctx, value)

Source from the content-addressed store, hash-verified

8002}
8003
8004function formatPrimitive(ctx, value) {
8005 if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
8006
8007 if (isString(value)) {
8008 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
8009 return ctx.stylize(simple, 'string');
8010 }
8011
8012 if (isNumber(value)) return ctx.stylize('' + value, 'number');
8013 if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here.
8014
8015 if (isNull(value)) return ctx.stylize('null', 'null');
8016}
8017
8018function formatError(value) {
8019 return '[' + Error.prototype.toString.call(value) + ']';

Callers 1

formatValueFunction · 0.85

Calls 6

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

Tested by

no test coverage detected