npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@moyal/js-linq

v1.0.4

Published

A lightweight, zero-dependency JavaScript library that brings LINQ-style querying capabilities to native arrays. Designed for both clarity and performance, it offers a fluent, chainable API for filtering, projecting, grouping, ordering, and aggregating da

Readme

moyal.js.linq

license npm version jsDelivr CDN minzipped size

A lightweight, zero-dependency JavaScript library that brings LINQ-style querying capabilities to native arrays. Designed for both clarity and performance, it offers a fluent, chainable API for filtering, projecting, grouping, ordering, and aggregating data—without relying on external frameworks.

Information

Table of Contents

Installation

npm install @moyal/js-linq

Importing

In Node.js (ES Module)

import { Linq } from "@moyal/js-linq";

In Node.js (CommonJS)

const { Linq } = require("@moyal/js-linq");

In the Browser (ES Module via CDN)

<!-- From jsDelivr CDN (minified version) -->
<script type="module">
  import "https://cdn.jsdelivr.net/npm/@moyal/[email protected]/dist/moyal.linq.umd.min.js";
</script>

<!-- From jsDelivr CDN (non minified version with documentation) -->
<script type="module">
  import "https://cdn.jsdelivr.net/npm/@moyal/[email protected]/dist/moyal.linq.umd.js";
</script>

Or using unpkg:

<script type="module">
  import "https://unpkg.com/@moyal/[email protected]/dist/moyal.linq.umd.min.js";
</script>

Features

  • Fully Chainable: Every operation returns a LINQ-like wrapper to continue your query seamlessly.
  • Deferred Execution: Most operations are lazily evaluated using generators.
  • Zero Dependencies: No third-party libraries required. Works in both Node.js and browsers.
  • Rich Set of Operators: Includes filtering, projection, ordering, joining, grouping, set operations, aggregation, and statistics.
  • Built-in Statistics: Easily compute count, sum, average, median, mode, variance, and standard deviation.
  • Extensible Comparers & Selectors: All key-based operations support custom comparison and projection logic.
  • Supports thisArg Binding: Pass custom context for user-defined callbacks.
  • Typed Statistics API: Strongly encapsulated results with .clone(), .equal(), and .toJSON() support.

Quick Start

import { Linq } from '@moyal/js-linq';

const numbers = [1, 2, 3, 4, 5, 6];

const result = Linq
    .from(numbers)
    .where(x => x % 2 === 0)
    .select(x => x * 10)
    .toArray();

console.log(result); // Output: [20, 40, 60]

/*

In this quick start example:

- We filter out odd numbers.
- We multiply each number in 10.
- Dumping the result iterable to array.

*/

For more code examples, see also "/examples" and (or) "/test/units" in GitHub Repository.

API Overview

| Method / Static | Purpose | |----------------|---------| | from(iter) | Start LINQ chain from iterable | | aggregate(seed, fn) | Accumulate values with custom logic | | all(fn) | Check if all elements match predicate | | any([fn]) | Check if any element exists or matches | | append(value) | Append a value to the sequence | | average() | Compute average (returns undefined if non-numeric) | | concat(...iterables) | Concatenate multiple sequences | | contains(value, [comparer]) | Check for value presence | | count() | Count elements | | defaultIfEmpty(val) | Provide default if empty | | distinct([comparer]) | Unique values with optional comparer | | duplicate(n, inplace) | Repeat sequence n times | | elementAt(i) / elementAtOrDefault(i, def) | Get item by index (or fallback) | | empty() | Return an empty sequence | | except(other, [comparer]) | Exclude items in another iterable | | first([fn]) / firstOrDefault(def, [fn]) | Get first (matching) element | | forEach(fn) | Run function for each item | | groupBy(keyFn, elFn, resFn, cmp) | Group by key with full control | | groupJoin(...) | Join left with grouped-right by key | | intersect(other, [cmp]) | Common unique elements | | join(...) | Standard inner join | | last([fn]) / lastOrDefault(def, [fn]) | Get last (matching) element | | max([cmp]) / min([cmp]) | Get maximum/minimum value | | orderBy([keyFn], [cmp]) | Sort ascending | | orderByDescending(...) | Sort descending | | thenBy(...) / thenByDescending(...) | Chain ordering | | prepend(value) | Add value at start | | range(start, count) | Generate integer range | | removeNullishes() | Filter out null/undefined | | repeat(value, count) | Repeat value count times | | reverse() | Reverse sequence | | select(fn) | Transform each element | | selectMany(collFn, resFn) | Flatten nested sequences | | sequenceEqual(other, [cmp]) | Compare two sequences | | single([fn]) / singleOrDefault(def, [fn]) | Enforce single (matching) element | | skip(n) / skipLast(n) | Skip n items (from start/end) | | skipWhile(fn) | Skip until predicate fails | | statistics([extended]) | Return statistics object | | sum() | Sum of all elements | | take(n) / takeLast(n) | Take n items (from start/end) | | takeWhile(fn) | Take while predicate passes | | toArray() | Convert to array | | toMap(keyFn, valFn) | Build Map from sequence | | toDictionary(...) | Alias for toMap | | toSet([keyFn]) | Build Set from sequence | | where(fn) | Filter by predicate | | union(other, [cmp]) | Union of sequences (unique values) | | zip(iter1, iter2, transform) | Zip two sequences with transform | | Statistics | Encapsulates count, average, median, mode, etc. |

Note: Many methods support optional thisArg to bind context in user-defined functions.

Version Access

Access the library version directly:

import * as myLib from "@moyal/js-linq";

myLib.Version // → e.g., "1.0.4"

License

MIT License - free to use, modify, and distribute.

Author: Ilan Moyal

Website: https://www.moyal.es

GitHub: Ilan Moyal

LinkedIn: Ilan Moyal