We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It causes performance issues with big json data
The text was updated successfully, but these errors were encountered:
Thanks! feel free to create a PR for a better approach.
Sorry, something went wrong.
I have created this pretty fast preview function. It breaks generation if limit is reached
function previewLimited(obj:any, limit = 100, stringsLimit = 10) { let result = ''; if (typeof obj === 'string') { if(obj.length > stringsLimit) result += `"${obj.substring(0, stringsLimit)}…"`; else result += `"${obj}"`; } else if (typeof obj === 'boolean') { result += `${obj ? 'true' : 'false'}`; } else if (typeof obj === 'number') { result += `${obj}`; } else if (typeof obj === 'object'){ const isArray = Array.isArray(obj) result += isArray ? `(${obj.length})[` : '{'; for (const key in obj) { const value = obj[key]; result += isArray ? '': `${key}: `; if(result.length >= limit) return result.substring(0, limit) result += previewLimited(value, limit - result.length); result += `, `; } if(result.endsWith(', ')) result = result.slice(0, -2) result += isArray ? ']' : '}'; } if(result.length >= limit) return result.substring(0, limit) return result; }
Pull request: #126
No branches or pull requests
It causes performance issues with big json data
The text was updated successfully, but these errors were encountered: