UNPKG

@kubb/core

Version:

Core functionality for Kubb's plugin-based code generation system, providing the foundation for transforming OpenAPI specifications.

26 lines (20 loc) 575 B
import { trimQuotes } from './trim' export function stringify(value: string | number | boolean | undefined): string { if (value === undefined || value === null) { return '""' } return JSON.stringify(trimQuotes(value.toString())) } export function stringifyObject(value: object): string { const items = Object.entries(value) .map(([key, value]) => { if (typeof value === 'object') { return `${key}: { ${stringifyObject(value)} }` } return `${key}: ${value}` }) .filter(Boolean) return items.join(',\n') }