{"id":24603912,"url":"https://github.com/gearz-lab/lambda2js","last_synced_at":"2025-04-05T16:09:09.453Z","repository":{"id":26264917,"uuid":"29712196","full_name":"gearz-lab/lambda2js","owner":"gearz-lab","description":"Converts a C# expression tree (from Linq namespace) to a syntatically correct javascript code.","archived":false,"fork":false,"pushed_at":"2024-02-09T07:48:01.000Z","size":518,"stargazers_count":61,"open_issues_count":6,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T15:07:44.521Z","etag":null,"topics":["c-sharp","converts","expression-tree","javascript","lambda","linq"],"latest_commit_sha":null,"homepage":null,"language":"C#","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/gearz-lab.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":"2015-01-23T02:19:49.000Z","updated_at":"2025-01-24T14:52:37.000Z","dependencies_parsed_at":"2024-06-20T18:57:47.606Z","dependency_job_id":null,"html_url":"https://github.com/gearz-lab/lambda2js","commit_stats":{"total_commits":122,"total_committers":12,"mean_commits":"10.166666666666666","dds":0.180327868852459,"last_synced_commit":"21fe75aa05ee1064d1a5984e9332f68d8d803e7c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gearz-lab%2Flambda2js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gearz-lab%2Flambda2js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gearz-lab%2Flambda2js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gearz-lab%2Flambda2js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gearz-lab","download_url":"https://codeload.github.com/gearz-lab/lambda2js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361691,"owners_count":20926643,"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":["c-sharp","converts","expression-tree","javascript","lambda","linq"],"created_at":"2025-01-24T15:16:31.451Z","updated_at":"2025-04-05T16:09:09.395Z","avatar_url":"https://github.com/gearz-lab.png","language":"C#","readme":"# Lambda2Js\n\nThis is an ExpressionTree (lambda) to Javascript converter.\n\nIt is portable, so that you can use it in most environments.\n\nIts purpose is to convert a C# expression tree (from Linq name space) to a syntactically correct javascript code.\n\nIt can be extended to customize the mapping of expressions:\n- support custom static methods, instead of emitting code that would otherwise depend on external Javascript\n- support custom types, converting method calls and properties accordingly\n\nIt is well tested, and won't break. **More than 140 tests passing**.\n\nThis project uses Semantic versioning.\n\nInstalling [NuGet package](https://www.nuget.org/packages/Lambda2Js):\n\n    PM\u003e Install-Package Lambda2Js\n\nSamples\n-------\n\nConverting lambda with boolean and numeric operations:\n\n    Expression\u003cFunc\u003cMyClass, object\u003e\u003e expr = x =\u003e x.PhonesByName[\"Miguel\"].DDD == 32 || x.Phones.Length != 1;\n    var js = expr.CompileToJavascript();\n    // js = PhonesByName[\"Miguel\"].DDD===32||Phones.length!==1\n\nConverting lambda with LINQ expression, containing an inner lambda:\n\n    Expression\u003cFunc\u003cMyClass, object\u003e\u003e expr = x =\u003e x.Phones.FirstOrDefault(p =\u003e p.DDD \u003e 10);\n    var js = expr.CompileToJavascript();\n    // js = System.Linq.Enumerable.FirstOrDefault(Phones,function(p){return p.DDD\u003e10;})\n\nConverting lambda with Linq `Select` method:\n\n\tExpression\u003cFunc\u003cstring[], IEnumerable\u003cchar\u003e\u003e\u003e expr = array =\u003e array.Select(x =\u003e x[0]);\n    var js = expr.CompileToJavascript(\n        new JavascriptCompilationOptions(\n            JsCompilationFlags.BodyOnly | JsCompilationFlags.ScopeParameter,\n            new[] { new LinqMethods(), }));\n    // js = array.map(function(x){return x[0];})\n\nClone using `ToArray` and targeting ES6:\n\n    Expression\u003cFunc\u003cstring[], IEnumerable\u003cstring\u003e\u003e\u003e expr = array =\u003e array.ToArray();\n    var js = expr.Body.CompileToJavascript(\n        ScriptVersion.Es60,\n        new JavascriptCompilationOptions(new LinqMethods()));\n    // js = [...array]\n\nDeveloping custom plugins\n--------\n\nYou can develop and use some built-in plugins. See the [readme.md in the Plugins folder](https://github.com/gearz-lab/lambda2js/tree/master/Lambda2Js/Plugins).\n\n# Building and testing\n\n***ATENTION!*** Please, run the **ProjectsGenerator**\nbefore doing any of these:\n\n- build the signed assembly\n- running tests for specific frameworks\n\n    ![Run Projects Generator](docs/images/RunProjectsGenerator.png)\n\nDue to current Visual Studio limitations, I had to create\na project generator to create some of the `csproj` files:\n\n- **Lambda2Js.Signed.csproj** is generated using the\n`Lambda2Js.csproj` as it's template. It will copy the\npackage version to the FileVersion and to the\nAssemblyVersion fields to keep them consistent.\nAlso, it adds the `\".Signed\"` string where appropriate\nin file names and in project name, and finally it\nincludes a reference to the snk file.\n\n- **Lambda2Js.Tests.$(TargetFramework).csproj** are\ngenerated from `Lambda2Js.Tests.csproj`. That is needed\nbecause this project is a multitargeted test project,\nand Visual Studio cannot see the tests inside after\ncompiling it... so what I did was: create copy projects\nthat have only one target framework for each of the\npossible targets.\n\n## Testing\n\nTo test support on the .Net 4.0, you need to run the\n`Test.Net-v4.0.csproj` because this framework version\ndoes not support the native test attributes to do\nautomatic testing.\n\nTo test other framework versions, please, take a \nlook at the `TargetedTests` solution folder. In that \nfolder you will find all the tests. Unload all of them, \nbut keep the framework version you want to test, \nthen build it. Visual Studio will see the newly built \ntests and will list them. If the other frameworks test \nprojects are not unloaded, Visual Studio may or may \nnot list them.\n\n**Errors while building test projects**\n\nMake sure to NOT LOAD MORE THAN ONE test project inside the TargetedTests solution folder.\n\n- Load a single test project\n\n    ![Load Single Test Project](docs/images/LoadSingleTestProject.png)\n\n- Update Test Framework Packages\n\n    ![Update Test Framework Packages](docs/images/UpdateTestFrameworkPackages.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgearz-lab%2Flambda2js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgearz-lab%2Flambda2js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgearz-lab%2Flambda2js/lists"}