{"id":13459165,"url":"https://github.com/mihaifm/linq","last_synced_at":"2025-05-14T07:08:22.996Z","repository":{"id":2944234,"uuid":"3957383","full_name":"mihaifm/linq","owner":"mihaifm","description":"linq.js - LINQ for JavaScript","archived":false,"fork":false,"pushed_at":"2024-05-19T10:03:34.000Z","size":333,"stargazers_count":1705,"open_issues_count":17,"forks_count":229,"subscribers_count":67,"default_branch":"master","last_synced_at":"2025-05-13T04:34:03.052Z","etag":null,"topics":["javascript","linq"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"RicterZ/exserial","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mihaifm.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":"2012-04-07T11:39:29.000Z","updated_at":"2025-05-12T09:54:51.000Z","dependencies_parsed_at":"2024-01-12T00:27:03.042Z","dependency_job_id":"9f29e4a0-9081-4f91-9211-83e0596473ef","html_url":"https://github.com/mihaifm/linq","commit_stats":{"total_commits":94,"total_committers":24,"mean_commits":"3.9166666666666665","dds":0.5319148936170213,"last_synced_commit":"45a45fb9b6e79380a84b9925dae519662c66e335"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihaifm%2Flinq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihaifm%2Flinq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihaifm%2Flinq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihaifm%2Flinq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mihaifm","download_url":"https://codeload.github.com/mihaifm/linq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253877450,"owners_count":21977638,"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":["javascript","linq"],"created_at":"2024-07-31T09:01:07.685Z","updated_at":"2025-05-14T07:08:22.979Z","avatar_url":"https://github.com/mihaifm.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Libraries","Implementations"],"sub_categories":["[Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript)","Miscs"],"readme":"# linq\n\nThis is a JavaScript implementation of the .NET [LINQ](https://msdn.microsoft.com/en-us/library/bb308959.aspx) library.\n\nIt contains all the original .NET methods plus a few additions.\n\nWritten in pure JavaScript with no dependencies.\n\n## Examples\n\n```js\n// C# LINQ - delegate\nEnumerable.Range(1, 10)\n    .Where(delegate(int i) { return i % 3 == 0; })\n    .Select(delegate(int i) { return i * 10; });\n\n// linq.js - anonymous function\nEnumerable.range(1, 10)\n    .where(function(i) { return i % 3 == 0; })\n    .select(function(i) { return i * 10; });\n```\n\n```js\n// C# LINQ - lambda\nEnumerable.Range(1, 10).Where((i) =\u003e i % 3 == 0).Select((i) =\u003e i * 10);\n\n// linq.js - arrow function\nEnumerable.range(1, 10).where((i) =\u003e i % 3 == 0).select((i) =\u003e i * 10);\n```\n\n```js\n// C# LINQ - anonymous type\narray.Select((val, i) =\u003e new { Value: val, Index: i }());\n\n// linq.js - object literal\nEnumerable.from(array).select((val, i) =\u003e ({ value: val, index: i }));\n```\n\nSee [sample/tutorial.js](https://github.com/mihaifm/linq/blob/master/sample/tutorial.js) and the [test](https://github.com/mihaifm/linq/tree/master/test) folder for more examples.\n\n# Usage\n\n## Node.js (ES modules)\n\nInstall the latest version of the library with npm:\n\n    npm install linq\n\nLoad it in your code with the `import` syntax:\n\n```js\nimport Enumerable from 'linq'\n\nlet result = Enumerable.range(1, 10).where(i =\u003e i % 3 == 0).select(i =\u003e i * 10)\nconsole.log(result.toArray()) // [ 30, 60, 90 ]\n```\n\nBecause the library is an ES module, this code will only work if your project is also configured as an ES module. Add the following line in your `package.json` to make it an ES module:\n\n```json\n\"type\": \"module\"\n```\n\nIf you're not planning to use ES modules, check the CommonJS section below.\n\n## Node.js (CommonJS modules)\n\nInstall version 3 of this library:\n\n    npm install linq@3\n\nLoad it with the `require` syntax:\n\n```js\nconst Enumerable = require('linq')\n\nlet count = Enumerable.range(1, 10).count(i =\u003e i \u003c 5)\nconsole.log(count) // 4\n```\n\nThe [cjs](https://github.com/mihaifm/linq/tree/cjs) branch contains the source code for the CommonJS version of the library.\n\n## TypeScript\n\nInstall the latest version of the library with npm.\n\nConfigure your compiler options in `tsconfig.json`\n\n```json\n\"compilerOptions\": {\n    \"target\": \"ES2020\",\n    \"moduleResolution\": \"node\"\n}\n```\n\nThe library comes with a `d.ts` file containing type definitions for all the objects and methods, feel free to use them in your code:\n\n```ts\nimport Enumerable from 'linq';\n\ntype tnum = Enumerable.IEnumerable\u003cnumber\u003e;\nlet x: tnum = Enumerable.from([1, 2, 3]);\n```\n\n## Deno\n\nImport the library from deno.land. Use the `@deno-types` annotation to load type definitions:\n\n```ts\n// @deno-types=\"https://deno.land/x/linq@4.0.0/linq.d.ts\"\nimport Enumerable from 'https://deno.land/x/linq@4.0.0/linq.js'\n\nlet radius = Enumerable.toInfinity(1).where(r =\u003e r * r * Math.PI \u003e 10000).first()\n```\n\nYou can also install locally with npm. Use the full file path when importing the library:\n\n```ts\n// @deno-types=\"./node_modules/linq/linq.d.ts\"\nimport Enumerable from './node_modules/linq/linq.js'\n```\n\n## Browser\n\nThe minified version of the library is available in the [release](https://github.com/mihaifm/linq/releases/latest) archive.\n\nLoad it via `\u003cscript type=\"module\"\u003e`:\n\n```html\n\u003cscript type=\"module\" src=\"./linq.min.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"module\"\u003e\n    import Enumerable from './linq.min.js'\n    Enumerable.from([1, 2, 3]).forEach(x =\u003e console.log(x))\n\u003c/script\u003e\n```\n\nYou can also load the library via a CDN:\n\n|        CDN | URL                                        |\n| ---------: | :----------------------------------------- |\n| unpkg      | \u003chttps://unpkg.com/linq/\u003e                  |\n| jsDelivr   | \u003chttps://jsdelivr.com/package/npm/linq\u003e    |\n| packd      | \u003chttps://bundle.run/linq@latest?name=linq\u003e |\n\n# Credits\n\n[Yoshifumi Kawai](https://github.com/neuecc) developed the [original version](https://github.com/neuecc/linq.js/) of this library.\n\n# License\n\n[MIT License](https://github.com/mihaifm/linq/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihaifm%2Flinq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmihaifm%2Flinq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihaifm%2Flinq/lists"}