Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function propString(prop, options) {
if (isString(prop)) {
return inspect(String(prop), { quoteStyle: 'double' });
}
if (isNumber(prop)) {
return `{${inspect(Number(prop))}}`;
}
if (isBoolean(prop)) {
return `{${inspect(booleanValue(prop))}}`;
}
if (isCallable(prop)) {
return `{${inspect(prop)}}`;
}
if (typeof prop === 'object') {
if (options.verbose) {
return `{${inspect(prop)}}`;
}
return '{{...}}';
}
return `{[${typeof prop}]}`;
}
}).catch(err => {
consoleOutput({
content: ['Error compiling ' + file.compiler + ':', inspect(err)],
type: 'error',
stack: []
})
return {
name: file.name,
type: file.type,
content: file.content
}
})
}
export function createFieldValue(value, context) {
const {schema, field, resolveInputComponent} = context
if (!field) {
throw new Error(`Missing field for value ${inspect(value)}`)
}
const fieldType = getFieldType(schema, field)
let ResolvedInput
try {
ResolvedInput = resolveInputComponent(field, fieldType)
} catch (error) {
error.message = `Got error while resolving input component for field "${field.name}" of type ${fieldType.name}: ${error.message}.`
throw error
}
const ResolvedContainer = (ResolvedInput && ResolvedInput.valueContainer) || PrimitiveValueContainer
return ResolvedContainer.deserialize(value, context)
}
export function debugNode(node, indentLength = 2, options = {}) {
if (typeof node === 'string' || typeof node === 'number') return escape(node);
if (typeof node === 'function') {
const name = functionName(node);
return `[function${name ? ` ${name}` : ''}]`;
}
if (!node) return '';
const adapter = getAdapter();
if (!adapter.isValidElement(node) && !isRSTNodeLike(node)) {
return `{${inspect(node)}}`;
}
const childrenStrs = childrenOfNode(node)
.map((n) => debugNode(n, indentLength, options))
.filter(Boolean);
const type = typeName(node);
const props = options.ignoreProps ? '' : propsString(node, options);
const beforeProps = props ? ' ' : '';
const afterProps = childrenStrs.length
? '>'
: ' ';
const childrenIndented = indentChildren(childrenStrs, indentLength);
const nodeClose = childrenStrs.length ? `` : '/>';
return `<${type}${beforeProps}${props}${afterProps}${childrenIndented}${nodeClose}`;
}
function propString(prop, options) {
if (isString(prop)) {
return inspect(String(prop), { quoteStyle: 'double' });
}
if (isNumber(prop)) {
return `{${inspect(Number(prop))}}`;
}
if (isBoolean(prop)) {
return `{${inspect(booleanValue(prop))}}`;
}
if (isCallable(prop)) {
return `{${inspect(prop)}}`;
}
if (typeof prop === 'object') {
if (options.verbose) {
return `{${inspect(prop)}}`;
}
return '{{...}}';
}
return `{[${typeof prop}]}`;
}
export default function prettyPrint(value) {
return inspect(value, {quoteStyle: 'double'});
}
function propString(prop, options) {
if (isString(prop)) {
return inspect(String(prop), { quoteStyle: 'double' });
}
if (isNumber(prop)) {
return `{${inspect(Number(prop))}}`;
}
if (isBoolean(prop)) {
return `{${inspect(booleanValue(prop))}}`;
}
if (isCallable(prop)) {
return `{${inspect(prop)}}`;
}
if (typeof prop === 'object') {
if (options.verbose) {
return `{${inspect(prop)}}`;
}
return '{{...}}';
}
return `{[${typeof prop}]}`;
}