You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

linqscript

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linqscript

Simple lightweight lambda syntax library for Typescript

1.2.0
Source
npmnpm
Version published
Weekly downloads
7
-30%
Maintainers
1
Weekly downloads
 
Created
Source

Simple lightweight lambda syntax library for Typescript.

No jQuery required! Unit tested.

Typescript arrow functions allows to use lambda syntax, which makes this easy to use.

USAGE:

make sure to use a working module loader like browserify

import { List } from './linqscript/source/source';

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"
	]
}
<script type="text/javascript" src="scripts/linqscript.js"></script>

also include latest jQuery version.

Methods

MethodDescriptionParameter
WhereReturns list, where delegate returns true.Delegate
SelectReturns list of selected valueDelegate
DistinctReturns grouped selected value.Delegate
FirstReturns first item in list.
LastReturns last item in list.
AddAdds element to list.item
AddRangeAdds each item in given list.items
RemoveAtRemoves item from list by index.index
RemoveRemoves item from list.item
IndexOfGets index of given item.item
ContainsReturn true if list contains given item.item
GetGets item by index.index
ClearClears list.
ToArrayConverts list to array. Important for serialization.item
CountReturns listcount.
CountReturns listcount by delegate.Delegate
AnyReturns true if list contains any item.
AnyReturns true if list contains any item by delegate.Delegate
EqualsCompares list with another list. Returns true if lists are equal. If comparePosition is set to false, equality will be checked without comparison on positionitem, comparePosition (default true)
ToListConverts an Array to list. Important for e.g. ajax calls

Keywords

linqscript

FAQs

Package last updated on 02 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts