{"id":23441689,"url":"https://github.com/vitia-fritelle/tail-code-optimization","last_synced_at":"2025-08-02T10:12:21.855Z","repository":{"id":131214578,"uuid":"565831600","full_name":"vitia-fritelle/tail-code-optimization","owner":"vitia-fritelle","description":"Tail Code Optimization in JavaScript","archived":false,"fork":false,"pushed_at":"2022-11-14T12:58:30.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T21:42:37.019Z","etag":null,"topics":["javascript","recursion","tail-recursion"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/vitia-fritelle.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":"2022-11-14T12:24:10.000Z","updated_at":"2023-03-20T12:24:24.000Z","dependencies_parsed_at":"2023-05-02T17:14:35.203Z","dependency_job_id":null,"html_url":"https://github.com/vitia-fritelle/tail-code-optimization","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vitia-fritelle/tail-code-optimization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitia-fritelle%2Ftail-code-optimization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitia-fritelle%2Ftail-code-optimization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitia-fritelle%2Ftail-code-optimization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitia-fritelle%2Ftail-code-optimization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitia-fritelle","download_url":"https://codeload.github.com/vitia-fritelle/tail-code-optimization/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitia-fritelle%2Ftail-code-optimization/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268370180,"owners_count":24239766,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["javascript","recursion","tail-recursion"],"created_at":"2024-12-23T17:18:10.646Z","updated_at":"2025-08-02T10:12:21.789Z","avatar_url":"https://github.com/vitia-fritelle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tail Code Optimization\n\nIt is often difficult to connect knowledge learned in recursion with practice. \nCompilers associated with popular programming languages do not automatically transform recursive calls into iterative ones, and this ends up in a difficulty to efficiently implement recursive techniques.\nGiven the advantages of approaching the code recursively, such as brevity and reducing the number of states to be handled, it is worth finding a way to adapt the code in order to abstract the programming logic.\nIn this code, I present a way to implement the conversion for a specific case, tail recursion in JavaScript.\n\nFor using this code all you have to do is:\n\n``` javascript\n  function recursiveFuction(recursiveFunctionParameters) {\n      if (someBaseCase) {\n        return new BaseCase(someValue);\n      } else if (anotherBaseCase) {\n        return new BaseCase(anotherValue);\n      } else {\n        return new TailCall(newArgs);\n      }\n  }\n\n  tco(recursiveFunction, recursiveFunctionArgs)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitia-fritelle%2Ftail-code-optimization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitia-fritelle%2Ftail-code-optimization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitia-fritelle%2Ftail-code-optimization/lists"}