{"id":16092320,"url":"https://github.com/alecthomas/oink","last_synced_at":"2025-07-09T13:07:55.846Z","repository":{"id":66600210,"uuid":"841055","full_name":"alecthomas/oink","owner":"alecthomas","description":"Oink is a Python to Javascript translator.","archived":false,"fork":false,"pushed_at":"2023-12-02T11:43:42.000Z","size":9,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-16T17:45:11.884Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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/alecthomas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2010-08-16T13:26:39.000Z","updated_at":"2025-03-09T14:37:17.000Z","dependencies_parsed_at":"2024-10-27T17:23:51.771Z","dependency_job_id":"d6972672-86f3-4e6f-aa5d-cdd54306dcf8","html_url":"https://github.com/alecthomas/oink","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Foink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Foink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Foink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Foink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecthomas","download_url":"https://codeload.github.com/alecthomas/oink/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244169368,"owners_count":20409705,"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":[],"created_at":"2024-10-09T16:07:03.554Z","updated_at":"2025-03-18T06:30:58.699Z","avatar_url":"https://github.com/alecthomas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Oink - a Python to Javascript translator\n\nOink attempts to translate Python source to idiomatic Javascript.\n\nIt consists of the translator itself and a JS runtime.\n\n## Examples\n\nHere are a couple of examples from [Project Euler](http://projecteuler.net/):\n\n### Project Euler 1\n\nPython source for solution 1:\n\n```python\ndef euler1():\n    \"\"\"Add all the natural numbers below 1000 that are multiples of 3 or 5\"\"\"\n    multiple = lambda x, y: x % y == 0\n    return sum(x for x in xrange(1, 1000)\n               if multiple(x, 3) or multiple(x, 5))\n\nprint euler1()\n```\n\nRunning `oink euler1.py` on this example produces the following Javascript:\n\n```javascript\n/** Add all the natural numbers below 1000 that are multiples of 3 or 5 */\nfunction euler1() {\n  var multiple = function (x, y) { return x % y == 0; };\n  return Oink.sum(Oink.listComprehension(Oink.range(1, 1000), function (x) {\n    return x;\n  }, function (x) {\n    return multiple(x, 3) || multiple(x, 5);\n  }));\n};\n\nconsole.log(euler1());\n```\n\n### Project Euler 6\n\nPython source for solution 6:\n\n```python\ndef euler6(op, end):\n    return op(sum(xrange(end + 1))) - sum(op(x) for x in xrange(end + 1))\n\nprint euler6(lambda x: x ** 2, 100)\n```\n\nRunning `oink euler6.py` on this example produces the following Javascript:\n\n```javascript\nfunction euler6(op, end) {\n  return op(Oink.sum(Oink.range(end + 1))) - Oink.sum(Oink.listComprehension(Oink.range(end + 1), function (x) {\n      return op(x);\n  }));\n};\n\nconsole.log(euler6(function (x) { return Math.pow(x, 2); }, 100));\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Foink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falecthomas%2Foink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Foink/lists"}