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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@siderite/linqer-ts

v2.0.2

Published

LInQer for Typescript

Downloads

4

Readme

LInQer-ts

The C# Language Integrated Queries ported for Javascript for amazing performance

npm version License: MIT

Installation

$ npm install @siderite/linqer-ts

Quick start

const source = ... an array or a generator function or anything that is iterable... ;
const enumerable = Enumerable.from(source); // now you can both iterate and use LINQ like functions
const result = enumerable
                .where(item=>!!item.value) // like filter
                .select(item=>{ value: item.value, key: item.name }) // like map
                .groupBy(item=>item.key)
                .where(g=>g.length>10)
                .orderBy(g=>g.key)
                .selectMany()
                .skip(15)
                .take(5);
for (const item of result) ...

in Node.js you have to prepend:

const Enumerable = require('@siderite/linqer');

in Typescript, use:

import '@siderite/linqer-ts'

Licence

MIT

Array functions in Javascript create a new array for each operation, which is terribly wasteful. Using iterators and generator functions and objects, we can limit the operations to the items in the array that interest us, not all of them.

Blog post

https://siderite.dev/blog/linq-in-javascript-linqer. Leave comments there or add Issues on GitHub for feedback and support.

Hosted

Find it hosted on GitHub Pages and use it freely in your projects at:

  • https://siderite.github.io/LInQer-ts/lib/LInQer.js - main library
  • https://siderite.github.io/LInQer-ts/lib/LInQer.min.js - main library minified

Reference

Reference Linqer.js for the basic methods:

  • from, empty, range, repeat - static on Linqer.Enumerable

  • length property - same as count, but throws error if the enumerable needs to be enumerated to get the length (no side effects)

  • concat

  • count

  • distinct

  • elementAt and elementAtOrDefault

  • first and firstOrDefault

  • last and lastOrDefault

  • min, max, stats (min, max and count)

  • select

  • skip and take

  • splice function - kind of useless, but it was an experiment to see if I can make Enumerable appear as an Array-like object

  • sum and sumAndCount (sum and count)

  • toArray

  • toList - similar to toArray, but returns a seekable Enumerable (itself if already seekable) that can do count and elementAt without iterating

  • where

  • aggregate

  • all

  • any

  • append

  • average

  • asEnumerable

  • cast

  • contains

  • defaultIfEmpty - throws not implemented

  • except

  • intersect

  • join

  • groupBy

  • groupJoin

  • longCount

  • ofType

  • orderBy

  • orderByDescending

  • prepend

  • reverse

  • selectMany

  • sequenceEqual

  • single

  • singleOrDefault

  • skip - on an ordered enumerable

  • skipLast - on a regular or ordered enumerable

  • skipWhile

  • slice

  • take - on an ordered enumerable

  • takeLast - on a regular or ordered enumerable

  • takeWhile

  • thenBy - on an ordered enumerable

  • thenByDescending - on an ordered enumerable

  • toDictionary - throws not implemented

  • toLookup - throws not implemented

  • toMap

  • toObject

  • toHashSet - throws not implemented

  • toSet

  • union

  • zip

  • shuffle - randomizes the enumerable

  • randomSample - implements random reservoir sampling of k items

  • distinctByHash - distinct based on a hashing function, not a comparer - faster

  • exceptByHash - except based on a hashing function, not a comparer - faster

  • intersectByHash - intersect based on a hashing function, not a comparer - faster

  • binarySearch - find the index of a value in a sorted enumerable by binary search

  • lag - joins each item of the enumerable with previous items from the same enumerable

  • lead - joins each item of the enumerable with next items from the same enumerable

  • padStart - pad enumerable at the start to a minimum length

  • padEnd - pad enumerable at the end to a minimum length

Original Enumerable .NET class

The original C# class can be found here: https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable .

Building the solution

The library has been ported to Typescript. Run build.bat to create the .js files from the .ts code and copy the documentation to the docs folder