npm install @mgmguardiana/linqts
Import to your typescript file
import {Linq} from '@mgmguardiana/linqts/linq';
Initialize instance and use array objects inside the instance using Linq.create
export class SampleModel{
constructor(public province:string,public city:string,public barangay:string){}
}
export class main{
var arrays=[
new SampleModel("Batangas","Calaca","Cawong"),
new SampleModel("Cavite","Dasmarinas","San Agustin"),
new SampleModel("Batangas","Calaca","Dacanlao"),
new SampleModel("Batangas","Balayan","Lanatan"),
new SampleModel("Batangas","Balayan","Sampaga")
];
var linq=Linq.create(arrays);//Linq uses generic, it will detect the type that your array use
}
Sample functions
var orderedByProvinceArrays=linq.orderBy(x=>x.province)
.toArray();
var orderByThenArrays=linq.orderBy(x=>x.province)
.thenBy(x=>x.city)
.thenByDescending(x=>x.barangay)
.toArray();
var batangasAreas=linq.where(x=>x.province=="Batangas")
.toArray();
}