{"id":21815310,"url":"https://github.com/denorid/genfn","last_synced_at":"2026-05-05T18:36:34.834Z","repository":{"id":43491509,"uuid":"464245389","full_name":"denorid/genfn","owner":"denorid","description":"A module that helps you to write generated functions","archived":false,"fork":false,"pushed_at":"2022-02-27T21:24:01.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-12T22:52:35.980Z","etag":null,"topics":["deno","function-compiler","function-generator","javascript","typescript"],"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/denorid.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}},"created_at":"2022-02-27T20:27:24.000Z","updated_at":"2022-02-27T21:23:53.000Z","dependencies_parsed_at":"2022-09-19T00:40:54.991Z","dependency_job_id":null,"html_url":"https://github.com/denorid/genfn","commit_stats":null,"previous_names":["denokit/genfn"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/denorid/genfn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denorid%2Fgenfn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denorid%2Fgenfn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denorid%2Fgenfn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denorid%2Fgenfn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denorid","download_url":"https://codeload.github.com/denorid/genfn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denorid%2Fgenfn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32663422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["deno","function-compiler","function-generator","javascript","typescript"],"created_at":"2024-11-27T15:17:35.112Z","updated_at":"2026-05-05T18:36:34.809Z","avatar_url":"https://github.com/denorid.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @denorid/genfn\n\nA module that helps you to write generated functions in [Deno](https://deno.land),\nbased on npm [generate-function](https://github.com/mafintosh/generate-function) package.\n\n## Usage\n\n```TypeScript\nimport { genFn } from \"https://deno.land/x/denorid_genfn@1.0.0/mod.ts\"\n\nconst addNumber = (val: number) =\u003e {\n  const gen = genFn(`\n    function add(n) {\n      return n + ${val}\n    }\n  `);\n\n  return gen.toFunction();\n}\n\nconst addTen = addNumber(10);\n\nconsole.log(addTen.toString()); // prints the generated function\nconsole.log(\"5 + 10 =\", addTen(5));\n```\n\nIf you need to close over variables in your generated function pass them to `toFunction(scope?: Record\u003cstring, unknown\u003e)`\n\n```TypeScript\nfunction multiply(a: number, b: number) {\n  return a * b;\n}\n\nfunction addAndMultiplyNumber(val: number) {\n  const gen = genFn(`\n    function (n) {\n      if (typeof n !== 'number') {\n        throw new Error('argument should be a number')\n      }\n      const result = multiply(${val}, n + ${val})\n      return result\n    }\n  `);\n\n  return gen.toFunction({ multiply });\n}\n\nconst addAndMultiply2 = addAndMultiplyNumber(2);\n\nconsole.log(addAndMultiply2.toString()); // prints the generated function\nconsole.log(\"(3 + 2) * 2 =\", addAndMultiply2(3));\n```\n\nYou can call `gen.generate(code: string | string[])` as many times as you want to append more source code to the function.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenorid%2Fgenfn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenorid%2Fgenfn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenorid%2Fgenfn/lists"}