{"id":18886913,"url":"https://github.com/lostjared/code.crunch.javascript","last_synced_at":"2026-05-03T15:33:31.665Z","repository":{"id":242286349,"uuid":"809167337","full_name":"lostjared/Code.Crunch.JavaScript","owner":"lostjared","description":"Code Cruncher written in JavaScript","archived":false,"fork":false,"pushed_at":"2024-06-06T07:25:10.000Z","size":1846,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-24T01:42:57.151Z","etag":null,"topics":["code","compactor","cplusplus","crunch","cruncher"],"latest_commit_sha":null,"homepage":"http://lostsidedead.biz/crunch","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lostjared.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-01T22:28:09.000Z","updated_at":"2024-06-06T07:25:13.000Z","dependencies_parsed_at":"2024-06-01T23:49:13.375Z","dependency_job_id":"8e2a64e8-f7e8-4728-b3e8-9d7e097c07cd","html_url":"https://github.com/lostjared/Code.Crunch.JavaScript","commit_stats":null,"previous_names":["lostjared/code.crunch.javascript"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lostjared/Code.Crunch.JavaScript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostjared%2FCode.Crunch.JavaScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostjared%2FCode.Crunch.JavaScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostjared%2FCode.Crunch.JavaScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostjared%2FCode.Crunch.JavaScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lostjared","download_url":"https://codeload.github.com/lostjared/Code.Crunch.JavaScript/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostjared%2FCode.Crunch.JavaScript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32575110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["code","compactor","cplusplus","crunch","cruncher"],"created_at":"2024-11-08T07:32:01.219Z","updated_at":"2026-05-03T15:33:31.638Z","avatar_url":"https://github.com/lostjared.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ Code Cruncher (compactor)\n\n![screenshot2](https://github.com/lostjared/Code.Crunch.JavaScript/blob/main/crunch.jpg)\n\nThis project is a simple web-based tool to \"crunch\" C++ code by removing \nunnecessary whitespace and comments while preserving the code's \nfunctionality. It processes input C++ code and outputs a more compact \nversion. I got this working for most C++ code. I am not going to work on this anymore\nas I used this to create some videos and now am moving on.\n\n## Motivation\nI wanted to make a video with scrolling compacted C++ code so I wrote this to accomplish that.\nI thought others might find it useful so I posted it here.\n\n## Features\n- Preserves preprocesscor directives.\n- Removes multiline and single line comments.\n- Preserves single character constants and string literals.\n- Eliminates unnecessary whitespace, including double spaces and unrequired space between operaators.\n- Skips empty lines and space characters before comments.\n\n## Known Issues\n- when you have // within a string under certain conditions it will cause the text to be unaligned\n- does not work with most other languages\n- raw strings as of now are unsupported.\n\nif you want to fix these issues fork and submit a pull request!\n\n## Usage\n\n1. Open the `index.html` file in your web browser.\n2. Enter your C++ code in the provided textarea.\n3. Click the \"Crunch\" button.\n4. View the processed code in the output section.\n\n## Code Explanation\n\nThe main functionality is provided by the JavaScript code within the \n`index.html` file:\n\n- **crunch(input)**: Main function that processes the input text, removing \ncomments and crunching lines.\n- **removeMlComment(text)**: Helper function to remove multiline comments.\n- **chkChr(text, i, c)**: Helper function to check if a character matches \na specified character.\n- **crunchLine(s)**: Function to process each line, handling string \nliterals, character constants, and removing unnecessary characters.\n- **testchr(s, i)**: Helper function to test for characters that should be \nremoved.\n- **crunchText()**: Function to get input from the textarea, process it, \nand display the output.\n\n## Example\n\nInput:\n```cpp\n#include \u003ciostream\u003e\n\nint main() {\n    // This is a single line comment\n    std::cout \u003c\u003c \"Hello, World!\" \u003c\u003c std::endl;  /* This is a\n    multiline comment */\n    char c = '\\\\';\n    return 0;\n}\n```\n\nOutput:\n```cpp\n#include \u003ciostream\u003e\nint main(){std::cout \u003c\u003c\"Hello, World!\"\u003c\u003cstd::endl;char c ='\\\\';return 0;}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostjared%2Fcode.crunch.javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flostjared%2Fcode.crunch.javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostjared%2Fcode.crunch.javascript/lists"}