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

linqscript

v1.4.3

Published

C# alike List in Javascript. Simple lightweight lambda syntax library for Typescript, extending Array. Works with Angular

Downloads

17

Readme

NPM

C# alike List in Javascript. Simple lightweight lambda syntax library for Typescript, extending Array.

No jQuery required! Unit tested.

Typescript arrow functions allows us, to use lambda syntax, which makes this easy to use.
This library extends the native Array. Use full advantage of an Array, extended with this methods. Works with Angular.
import { List } from 'linqscript';

USAGE:

var fruits = new List<string>();
fruits.Add("apple");
fruits.Add("banana");

var fruit = fruits.Where(x => x === "apple").First();

You can use of course more complex objects:

enum Color {
	Green,
	Red
}

class Fruits {
	public Name: string;
	public Color: Color;
}

var fruits = new List<Fruits>();
var apple = new Fruit();
apple.Color = Color.Green;
apple.Name = "Apple";
fruits.Add(apple);

var redApple = new Fruit();
redApple.Color = Color.Red;
redApple.Name = "Apple";
fruits.Add(redApple);

var kiwi = new Fruit();
kiwi.Color = Color.Green;
kiwi.Name = "Kiwi";
fruits.Add(kiwi);

fruits.Where(x => x.Color === Color.Green);
Output:
{
	"Fruits": [{
		"Name": "Kiwi",
		"Color": 1
	}, {
		"Name": "Apple",
		"Color": 1
	}]
}
fruits.Select(x => x.Color);
{
	"Color": [
		"Green",
		"Red"
	]
}
fruits.Distinct(x => x.Name)
{
	"Name": [
		"Apple",
		"Kiwi"
	]
}
List.Range(3, 10)

[3,4,5,6,7,8,9,10,11,12] // starting at 3, generates 10 numbers
var numbersToSum = new List<number>();

numbersToSum.Add(1);
numbersToSum.Add("2"); // will be converted
numbersToSum.Add(3);
numbersToSum.Add(5);
numbersToSum.Add("eight"); // will be ignored
numbersToSum.Add(8);
numbersToSum.Add(13);

var sum = numbersToSum.Sum(); // 32

var sumPlusOne = numbersToSum.Sum(x => x+1); // 38 -> use delegate to manipulate.

Methods

| Method | Description | Parameter | | ------------- |:------------- |:----- | | Where | Returns list, where delegate returns true. | Delegate | | Select | Returns list of selected value | Delegate | | Distinct | Returns grouped selected value. | Delegate | | First | Returns first item in list. | | | Last | Returns last item in list. | | | Range (static) | Creates list of numbers, within a specified range. | start, length | | Add | Adds element to list. | item | | AddRange | Adds each item in given list. | items | | RemoveAt | Removes item from list by index. | index | | Remove | Removes item from list. | item | | IndexOf | Gets index of given item. | item | | Contains | Return true if list contains given item. | item | | Get | Gets item by index. | index | | Clear | Clears list. | | | ToArray | Converts list to array. Important for serialization. | item | | Count | Returns listcount. | | | Count | Returns listcount by delegate. | Delegate | | Sum | Summarizes numbers in list. | | | Sum | Summarizes numbers in list by delegate. | Delegate | | Any | Returns true if list contains any item. | | | Any | Returns true if list contains any item by delegate. | Delegate | | Equals | Compares list with another list. Returns true if lists are equal. If comparePosition is set to false, equality will be checked without comparison on position | item, comparePosition (default true) | | ToList | Converts an Array to list. | |

any questions or feedback, please contact me!