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

ect-ng-linq

v1.18.1

Published

ECT NgLinq draws inspiration from .NET LINQ and brings this inspiration to TypeScript.

Downloads

19

Readme

ECT NgLinq

This library was generated with Angular CLI version 18.0.0.

Description

Language-Integrated Query (LINQ) was created for C# by Microsoft. It's a way of retrieving and sorting data in arrays, using strongly typed collections of objects, and using familiar operators and functions used in languages like SQL. More details can be found here: (https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/)

ECT NgLinq draws inspiration from LINQ and brings this inspiration to TypeScript. One of the great ideas in LINQ was the ability to chain methods, and this is also built as standard in NgLinq too.

Usage

First add the EctNgLinqService service to your Modules' or AppComponent's Providers list.

Then, if an IUser interface is defined as this:

export interface IUser {
  id: number;
  firstName: string;
  lastName: string;
  email: string;
}

An array can be created like this:

const usersArray: IUser[] = [];

or

const usersArray: Array<IUser> = new Array<IUser>();

With NqLinq, first we import the EctNgLinqService service like this:

import { EctNgLinqService } from 'ect-ng-linq';

Secondly we inject into a component's constructor the EctNgLinqService service e.g.:

constructor(public ngLinqService: EctNgLinqService)

Lastly, we create an NqLinq array like this:

const usersArray = this.ngLinqService.createNgLinq<IUser>();

To search for a users with a lastName value of Jones, then sort by firstName, then take the first, just like in LINQ, using NgLinq we can chain a query up like this:

const firstUserWithLastNameOfJones = usersList.where((rec: IUser) => rec.lastName.endsWith('Jones'))
          .orderBy((rec: IUser) => rec.firstName)
          .takeFirst();

Functions

INgLinqArray exposes the following functions:

  • add: Add a single item to the current list
  • addRange: Add an array of items to the current list
  • all: Do ALL elements in the current list match the search condition
  • any: Do ANY elements in the current list match the search condition
  • average: Get the average of all elements by a field condition
  • clear: Remove all elements from the array
  • count: Count the number of elements in the current list
  • distinct: Distinct matching at record or field level
  • empty: Is the current list null or contain no items
  • first: Fetch the FIRST element in the list that matches with the search condition
  • groupBy: Group all elements by a key field
  • last: Fetch the LAST element in the list that matches with the search condition
  • min: Get the minimum of all elements by a field condition
  • max: Get the maximum of all elements by a field condition
  • orderBy: Order the list in ascending order
  • orderByDescending: Order the list in descending order
  • remove: Remove a single item from the current list
  • removeRange: Remove an array of items from the current list
  • skipAndTake: Skip a number of elements in the list, then take a specified number of elements from then on
  • sum: Total all elements by a field condition
  • takeFirst: Fetch first element in the current list
  • takeLast: Fetch last element in the current list
  • takeTop: Fetch the first X number of elements in the current list
  • where: Same as a SQL where clause to filter the list

Dependencies

None

Cost

If you find some benefit from using this package, please consider the time it took to put this together, and why not buy me a coffee? Goodness only knows that most of us would not function without coffee. All donations very much welcomed: (https://www.buymeacoffee.com/exoduscloudtech)

Further help

To get more help on the this ECT NgLinq, please visit (https://angular-grid.net/free/ect-ng-linq)