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

linqy

v0.0.3

Published

Linq impletation for nodejs, originaly made in typescript.

Downloads

35

Readme

Linqy

Portage of .NET Enumerable class of linq to nodejs.

NPM version Build Status

Intallation

npm install linqy

Usage

Node

var linqy = require('linqy');

var e = linqy.e;

API

To use the API the first thing you want to do, is transform your array into an enumerable:

var enumerable = e([1,2,3,4,5]);

Note that if you are using typescript, the type of enumerable will be inferred to linqy.Enumerable.

Then with an enumerable you can call a load of useful functions:

.aggregate(predicate, seed)

Apply an accumulator function, starting with the seed.

  • predicate: a function taking two arguments, the aggregate so far and the current element to aggregate, and returning the aggregated result.
  • seed optional: the seed to start aggregating against.

Returns: the final aggregate.

.all(predicate)

Determines whether all elements satisfy a condition.

  • predicate: a function taking the current element to test, returning a boolean.

Returns: a boolean.

.any(predicate)

Determines whether any elements satisfy a condition.

  • predicate: a function taking the current element to test, returning a boolean.

Returns: a boolean.

.average(predicate)

Computes the average value of the elements.

  • predicate optional: a function taking the current element to transform to a number, returning that number.

Returns: a number.

.cast()

Typescript usage only.

Cast the generic type of the enumerable.

  • U: the type to cast to.

Returns: a linqy.Enumerable.

.concat(enumerable)

Concatenates with another enumerable.

  • enumerable: an enumerable or simple array to concatenate.

Returns: a linqy enumerable.

.contains(item)

Determines whether an item is contained.

  • item: an item to check.

Returns: a boolean.

.count(predicate)

Returns the number of elements satisfying a predicate.

  • predicate optional: a function taking the current element to test, returning a boolean.

Returns: a number.

.distinct(predicate)

Returns distinct elements by using a predicate to establish the distinction criterion.

  • predicate optional: a function taking the current element to transform to its distinction criterion.

Returns: a linqy enumerable.

.elementAt(index)

Returns the element at the given position.

Returns: the item.

.empty()

Returns an empty enumerable. Very handy in a typescript context.

Returns: an empty linqy enumerable.

.except(enumerable)

Produces the difference with another enumerable, containing items not available in the two enumerables.

  • enumerable: an enumerable or simple array to compare with.

Returns: A linqy enumerable.

.first(predicate)

Returns the first element satisfying a predicate.

  • predicate: a function taking the current element to test, returning a boolean.

Returns: the item.

.forEach(action)

Calls a function on every items.

  • action: a function taking the current element.

Returns: nothing.

.groupBy(predicate)

Groups the elements by using a predicate to establish the grouping value.

  • predicate: a function taking the current element to transform to its grouping value.

Returns: a linqy enumerable of grouping object. The grouping object has a key field representing the grouping value, it is an linqy enumerable itself of the items within the group.

.intersect(enumerable)

Produces the intersection with another enumerable, containing items only available in the two enumerables.

  • enumerable: an enumerable or simple array to compare with.

Returns: A linqy enumerable.

.join(inner, outerSelector, innerSelector, resultSelector)

Correlates the elements with another enumerable by using predicates to establish matching keys and result.

  • inner: an enumerable or simple array to compare with.
  • outerSelector: a function taking the current outer element to transform to its matching value.
  • innerSelector: a function taking the current inner element to transform to its grouping value.
  • resultSelector: a function taking two arguments, the matching outer and inner items, and returning the joined result.

Returns: A linqy enumerable.

.last(predicate)

Returns the last element satisfying a predicate.

  • predicate: a function taking the current element to test, returning a boolean.

Returns: the item.

.max(predicate)

Returns the item having the maximum decimal value by using a predicate to establish the decimal value.

  • predicate optional: a function taking the current element to evaluate, returning a number.

Returns: the item.

.min(predicate)

Returns the item having the minimum decimal value by using a predicate to establish the decimal value.

  • predicate optional: a function taking the current element to evaluate, returning a number.

Returns: the item.

.orderBy(predicate)

Sorts the items in an ascending order by using a predicate to establish the sorting value.

  • predicate optional: a function taking the current element to transform to its sorting value.

Returns: a linqy enumerable.

.orderByDescending(predicate)

Sorts the items in a descending order by using a predicate to establish the sorting value.

  • predicate optional: a function taking the current element to transform to its sorting value.

Returns: a linqy enumerable.

.reverse()

Inverts the order of the items.

Returns: a linqy enumerable.

.select(predicate)

Transforms each items by using a predicate.

  • predicate: a function taking the current element to transform to its projected value.

Returns: a linqy enumerable.

.selectMany(predicate)

Transforms each items by using a predicate and flattens it into a single enumerable.

  • predicate: a function taking the current element to transform to its projected enumerable value.

Return: a linqy enumerable.

.single(predicate)

Returns the only element satisfying a predicate, throwing an exception if no or more that on element is available.

  • predicate: a function taking the current element to test, returning a boolean.

Returns: the item.

.skip(number)

Bypasses the specified number of elements, keeping the remaining ones.

  • number: the number of items to skip.

Return: a linqy enumerable.

.skipWhile(predicate)

Bypasses the elements while they are satisfying a predicate, keeping the remaining ones.

  • predicate: a function taking the current element to test, returning a boolean.

Return: a linqy enumerable.

.sum(predicate)

Computes the sum of the elements.

  • predicate optional: a function taking the current element to transform to a number, returning that number.

Returns: a number.

.take(number)

Keeps the specified number of elements, ignoring the remaining ones.

  • number: the number of items to take.

Return: a linqy enumerable.

.takeWhile(predicate)

Keeps the elements while they are satisfying a predicate, ignoring the remaining ones.

  • predicate: a function taking the current element to test, returning a boolean.

Return: a linqy enumerable.

.thenBy(predicate)

Subsequent sorts the items in an ascending order by using a predicate to establish the sorting value.

  • predicate optional: a function taking the current element to transform to its sorting value.

Returns: a linqy enumerable.

.thenByDescending(predicate)

Subsequent sorts the items in a descending order by using a predicate to establish the sorting value.

  • predicate optional: a function taking the current element to transform to its sorting value.

Returns: a linqy enumerable.

.union(enumerable)

Produces the union with another enumerable, containing distinct items available in the two enumerables.

  • enumerable: an enumerable or simple array to compare with.

Returns: A linqy enumerable.

.toArray()

Creates an array from the current enumerable.

Returns: plain array.

.where(predicate)

Filter the items by keeping elements satisfying a condition.

  • predicate: a function taking the current element to test, returning a boolean.

Returns: a linqy enumerable.

.zip(enumerable, resultSelector)

Merge with another enumerable by using a predicate.

  • enumerable: an enumerable or simple array to compare with.
  • resultSelector: a function taking two arguments, the items at the same positions, and returning the joined result.

Returns: a linqy enumerable.