{"id":24668765,"url":"https://github.com/shreypurohit/code-converter-vscode","last_synced_at":"2026-04-22T16:33:36.952Z","repository":{"id":270884692,"uuid":"911730639","full_name":"ShreyPurohit/code-converter-vscode","owner":"ShreyPurohit","description":"Repository to maintain VS Code Extension 'Ternary ⇄ If-Else Converter'","archived":false,"fork":false,"pushed_at":"2025-01-14T16:13:55.000Z","size":165,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T09:17:19.718Z","etag":null,"topics":["clean-code","code-converter","code-formatter","code-quality","code-transformation","conditional-statements","debugging","hover-preview","if-else-statements","productivity","readability","refactoring","ternary","vscode-extension"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShreyPurohit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-03T17:55:40.000Z","updated_at":"2025-01-14T16:14:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"dce16268-9a3b-45da-b6aa-26050ba3ea61","html_url":"https://github.com/ShreyPurohit/code-converter-vscode","commit_stats":null,"previous_names":["shreypurohit/code-converter-vscode"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShreyPurohit%2Fcode-converter-vscode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShreyPurohit%2Fcode-converter-vscode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShreyPurohit%2Fcode-converter-vscode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShreyPurohit%2Fcode-converter-vscode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShreyPurohit","download_url":"https://codeload.github.com/ShreyPurohit/code-converter-vscode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244804576,"owners_count":20513139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-code","code-converter","code-formatter","code-quality","code-transformation","conditional-statements","debugging","hover-preview","if-else-statements","productivity","readability","refactoring","ternary","vscode-extension"],"created_at":"2025-01-26T09:17:24.708Z","updated_at":"2026-04-22T16:33:31.908Z","avatar_url":"https://github.com/ShreyPurohit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ternary ⇄ If-Else Converter\n\nA powerful VS Code extension that enables bidirectional visualization and conversion between `ternary expressions` and `if-else statements`. Boost your code readability and performance with instant previews and conversions.\n\n- 🔄 Instantly convert between **ternary expressions** ⇄ **if-else statements**\n- 🔍 Smart detection and conversion of nested ternary operations\n- 🐛 Make complex conditions more readable and easier to debug\n- 👁️ Real-time preview on hover without modifying your code\n- 📖 Improve code readability for better team collaboration\n- ⚡ Copy converted code with a single click\n- 🎛️ Enable/Disable converter with one click\n- 🔬 Granular level conversion support for nested conditions\n\n## Table of Contents\n\n- [Features](#features)\n- [If-Else to Ternary](#if-else-to-ternary)\n- [Ternary to If-Else](#ternary-to-if-else)\n- [Additional Features](#additional-features)\n- [How to Use](#how-to-use)\n- [Ternary to If-Else](#ternary-to-if-else-1)\n- [If-Else to Ternary](#if-else-to-ternary-1)\n- [Enable/Disable Converter](#enabledisable-converter)\n- [Supported Languages](#supported-languages)\n- [Debugging](#debugging)\n- [Common Issues](#common-issues)\n    - [1. Unsupported File Types](#1-unsupported-file-types)\n    - [2. Invalid Syntax](#2-invalid-syntax)\n    - [3. Complex Nested Structures](#3-complex-nested-structures)\n- [More Examples To Try With](#more-examples-to-try-with)\n- [License](#license)\n\n## Features:\n\n### If-Else to Ternary\n\n- **Description**: Transform nested `if-else` statements into concise `ternary expressions`.\n- **Key Benefits**:\n  - Faster execution compared to traditional if-else blocks\n  - Reduces code length without losing functionality\n  - Embraces modern JavaScript practices\n  - Optimizes memory usage and final bundle size in production\n  - Supports granular conversion of nested conditions\n\n### Ternary to If-Else\n\n- **Description**: Convert `ternary expressions` into more readable `if-else` statements.\n- **Key Benefits**:\n  - Simplifies debugging and understanding of complex logic\n  - Serves as a learning aid for new team members\n  - Useful for teaching fundamental programming concepts\n  - Supports conversion at any nesting level\n\n### Additional Features:\n- **Copy \u0026 Paste**: Easy to copy the converted code and modify it for your needs\n- **Instant Preview**: See conversions in real-time without affecting original code\n- **Bidirectional Conversion**: Freedom to switch between both formats as needed\n- **Toggle Converter**: Quick enable/disable functionality via status bar\n- **Granular Conversion**: Convert specific parts of nested conditions\n\n### Enable/Disable Converter:\n1. **Status Bar Button**: Click the converter status in the status bar to toggle\n2. **Quick Access**: Instantly enable/disable without going through settings\n3. **Visual Feedback**: Status bar shows current state (Enabled/Disabled)\n\n\u003cimg src=\"./assets/toggle_converter.webp\" alt=\"Toggle Converter\" style=\"height: 200px;\"\u003e\n\n### Ternary to If-Else:\n1. **Hover Over Ternary**: Simply hover your mouse over any ternary expression (`condition ? value1 : value2`).\n2. **View Conversion**: The extension will automatically show the corresponding `if-else` statement as a hover preview.\n\n\u003cimg src=\"./assets/ternaryView_sample.webp\" alt=\"Hover Example\" style=\"height: 200px; border: 5px solid black;\"\u003e\n\n### If-Else to Ternary:\n1. **Hover Over If-Else**: Hover over an if-else statement to see its ternary equivalent.\n2. **View Conversion**: The extension shows a preview of the ternary expression.\n\n\u003cimg src=\"./assets/if-else_sample.webp\" alt=\"Hover Example\" style=\"height: 200px; border: 5px solid black;\"\u003e\n\n### Granular Level Conversion:\nThe extension now supports converting specific parts of nested conditions:\n\n\u003cimg src=\"./assets/granular-level.webp\" alt=\"Hover Example\" style=\"height: 200px; border: 5px solid black;\"\u003e\n\n\n## Supported Languages:\n\nThis extension supports the following languages:\n- JavaScript (`.js`)\n- TypeScript (`.ts`)\n- JavaScript React (`.jsx`)\n- TypeScript React (`.tsx`)\n\n## Debugging:\n\n### Common Issues:\n\n#### 1. Unsupported File Types\n- Verify that you're using one of the supported file extensions:\n    - JavaScript (.js)\n    - TypeScript (.ts)\n    - JavaScript React (.jsx)\n    - TypeScript React (.tsx)\n\n#### 2. Invalid Syntax\n- Code must be syntactically correct for the converter to work\n- Use your IDE's linting tools to check for syntax errors\n\n#### 3. Complex Nested Structures\n- While both converters support nested structures, extremely complex cases might need to be broken down\n- Consider splitting very complex conditions into smaller, more manageable parts\n\n## More Examples To Try With:\n\n- [Nested Ternary to If-Else    ](#nested-ternary-to-if-else)\n- [Ternary in Functions](#ternary-in-functions)\n- [JSX Ternary Expression](#jsx-ternary-expression)\n- [Objects](#objects)\n- [Nested If-Else to Ternary](#nested-if-else-to-ternary)\n\n### Nested Ternary to If-Else:\n```javascript\nconst value = conditionA ? (conditionB ? 'B1' : 'B2') : 'A2';\n\n// Converts to:\nif (conditionA) {\n    if (conditionB) {\n        'B1';\n    } else {\n        'B2';\n    }\n} else {\n    'A2';\n}\n```\n\n### Ternary in Functions:\n```javascript\nfunction getStatus(conditionA: any) {\n    return conditionA\n        ? 100 + 50\n        : Math.random() \u003e 0.5\n            ? 'Random True'\n            : 'Random False';\n}\n\n// Converts to:\nif (conditionA) {\n    100 + 50\n} else {\n    if (Math.random() \u003e 0.5) {\n        'Random True'\n    } else {\n        'Random False'\n    }\n}\n```\n\n### JSX Ternary Expression:\n```javascript\n{isLoading ? (\n    \u003cSpinner /\u003e\n) : error ? (\n    \u003cErrorMessage error={error} /\u003e\n) : (\n    \u003cContent data={data} /\u003e\n)}\n\n// Converts to:\nif (isLoading) {\n    \u003cSpinner /\u003e\n} else if (error) {\n    \u003cErrorMessage error={error} /\u003e\n} else {\n    \u003cContent data={data} /\u003e\n}\n```\n\n### Objects:\n```javascript\nconst obj2 = {\n    key: conditionA ? (conditionB ? 'value1' : 'value2') : 'value3',\n}\n\n// Converts to:\nif (conditionA) {\n    if (conditionB) {\n        'value1'\n    } else {\n        'value2'\n    }\n} else {\n    'value3'\n}\n```\n\n### Nested If-Else to Ternary:\n```javascript\nif (hardCustomOccupancy \u0026\u0026 roomCustomOccupancy) {\n    roomCustomOccupancy?.adult;\n} else {\n    if (setSelectionDetails) {\n        if (condition) {\n            valueA;\n        } else {\n            valueB;\n        }\n    } else {\n        valueC;\n    }\n}\n\n// Converts to:\nhardCustomOccupancy \u0026\u0026 roomCustomOccupancy \n    ? roomCustomOccupancy?.adult \n    : setSelectionDetails \n        ? condition ? valueA : valueB \n        : valueC\n```\n\n## License:\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshreypurohit%2Fcode-converter-vscode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshreypurohit%2Fcode-converter-vscode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshreypurohit%2Fcode-converter-vscode/lists"}