Registry / data / linq
library0.3.1jsnpmunverified

Linq.js is a comprehensive JavaScript implementation of the .NET Language Integrated Query (LINQ) library, offering a fluent API for querying and manipulating data collections. It includes all the original .NET LINQ methods along with several additions, enabling powerful data transformations and filtering across various iterable objects like arrays, Maps, and Sets. The current stable version is 4.0.3, with a release cadence that has provided incremental updates for improved iteration protocol support and enhanced TypeScript definitions. A key differentiator is its transition to a pure ES module structure in version 4.0.0, making it fully compatible with modern JavaScript environments such as Node.js (v14.13.1 and later), TypeScript projects, Deno, and contemporary web browsers. For projects requiring CommonJS modules or targeting older environments, version 3 of the library remains available.

npm install linq
INSTALL
IMPORT
SIG · LINQ
L
linq
datajavascriptv0.3.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Enumerable
import Enumerable from 'linq'
const Enumerable = require('linq')
The library is an ES module since v4.0.0. CommonJS 'require' syntax will fail; use 'linq@3' for CJS projects.
IEnumerable<T>
import Enumerable from 'linq'; type MyCollection = Enumerable.IEnumerable<number>;
import { IEnumerable } from 'linq'
IEnumerable is a type available via the default 'Enumerable' import, not a named export itself.
Enumerable (CommonJS)
const Enumerable = require('linq')
import Enumerable from 'linq'
This import pattern is only correct for linq@3 and earlier versions. linq@4+ is ESM-only.

Demonstrates basic LINQ operations including filtering, mapping, and querying iterable objects like Maps, highlighting its fluent API.

// For Node.js (v14.13.1+) with "type": "module" in package.json import Enumerable from 'linq'; // Example 1: Basic filtering and transformation let result1 = Enumerable.range(1, 10) .where(i => i % 3 === 0) .select(i => i * 10) .toArray(); console.log('Filtered and multiplied:', result1); // [ 30, 60, 90 ] // Example 2: Working with objects and iterating over Map/Set const data = new Map([ ['apple', 10], ['banana', 20], ['cherry', 30] ]); let result2 = Enumerable.from(data) .where(([key, value]) => value > 15) .select(([key, value]) => ({ fruit: key, quantity: value * 2 })) .toArray(); console.log('Querying Map:', result2); // [ { fruit: 'banana', quantity: 40 }, { fruit: 'cherry', quantity: 60 } ] // Example 3: Finding the first element meeting a condition let firstBigRadius = Enumerable.toInfinity(1) .where(r => r * r * Math.PI > 10000) .first(); console.log('First radius for area > 10000:', firstBigRadius);
Debug
Known issues
breakingVersion 4.0.0 fully transitioned to an ES module (ESM) architecture, deprecating CommonJS (CJS) support for the current major release. This means `require()` syntax is no longer supported with `linq@4` and newer.
fix
For new projects, ensure your Node.js environment is v14.13.1+ and your `package.json` includes `'type': 'module'`. For existing CommonJS projects, continue using `npm install linq@3`.
affects: >=4.0.0
gotchaAttempting to use `linq@4` or newer in a Node.js project without configuring it as an ES module will result in module resolution errors. This is typically indicated by a `SyntaxError: Cannot use import statement outside a module`.
fix
Add `'type': 'module'` to your `package.json` file to enable ES module resolution. Alternatively, rename your `.js` files to `.mjs` or use `linq@3` for CommonJS.
affects: >=4.0.0
gotchaThe library ships with TypeScript definitions, but correct usage requires specific `tsconfig.json` compiler options, particularly `target` set to `ES2020` or higher and `moduleResolution` to `node`.
fix
Configure your `tsconfig.json` with `{'compilerOptions': {'target': 'ES2020', 'moduleResolution': 'node'}}` to ensure types are correctly resolved and compiled.
affects: >=4.0.0
gotchaVersion 3.2.3 introduced `Enumerable.Utils.recallFrom` which implies that `Enumerable.Utils.extendTo` (for prototype pollution) should be used with extreme caution, as direct prototype extension is generally discouraged in modern JavaScript.
fix
Avoid using `Enumerable.Utils.extendTo` to modify built-in prototypes. Prefer direct instantiation with `Enumerable.from()` or method chaining on `Enumerable` directly to avoid global object mutation.
affects: *
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Attempting to use ES module `import` syntax for `linq@4+` in a CommonJS Node.js project.
fix
Add `'type': 'module'` to your `package.json` or switch to `linq@3` and use `const Enumerable = require('linq')`.
ReferenceError: Enumerable is not defined
Using `require('linq')` with `linq@4+` in a Node.js ES module project, or in an environment where the global `Enumerable` is not exposed (e.g., modern browser without `<script type='module'>`).
fix
For `linq@4+`, use `import Enumerable from 'linq'` in an ES module project. For CommonJS, use `linq@3` and `const Enumerable = require('linq')`.
TypeError: 'Enumerable' is not a constructor
The `Enumerable` object is a singleton or a static class-like object, not a constructor. It is meant to be used with static methods like `Enumerable.range()` or `Enumerable.from()`.
fix
Do not attempt to instantiate `Enumerable` with `new`. Call its static methods directly, e.g., `Enumerable.range(1, 10)` or `Enumerable.from(myArray)`.
TS2305: Module '"linq"' has no exported member 'IEnumerable'.
`IEnumerable` is a type available via the default `Enumerable` import, not a named export itself, or `tsconfig.json` is not configured correctly.
fix
Import `Enumerable` as a default import and then use `Enumerable.IEnumerable<T>` for type annotation: `import Enumerable from 'linq'; type MyType = Enumerable.IEnumerable<string>;`. Ensure `tsconfig.json` includes `{'compilerOptions': {'target': 'ES2020', 'moduleResolution': 'node'}}`.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
linq — npm install linq · libregistry