Skip to content

jinhduong/linq-fns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

linq-fns

.NET LINQ functions for Javascript, written by TypeScript.

  • âš¡ Provide Queryable<T>, it's reusable, also variable and use Predicate collection for holding query and execute later.
  • 🔨 Contains almost the original .NET and some extends methods.
  • 🔨 Support Promise like as a input source.
  • 🙅 All APIs like a Javascript native methods so easily, simply implementation.
  • 📊 Have some drivers for firebase realtime db or any storage libraries...

Basic example

let query = Queryable
            .from(nations)
            .join(continents, (x, y) => x.areaId === y.id)
            .groupBy(o => o.y.areaName)
            .select(x => {
                return {
                    area: x.key,
                    total: Queryable.fromSync(x.items).count() // Here will return number, not Promise<number>
                }
            })
const asyncData = query.toList() // Will return Promise<{area:string, total:number}>
asyncData.then(data => {
    console.log(data);
    // [
    //     {area: 'Euro': total: 2},
    //     {area:'South Ameria', total: 1}
    // ]
});

Process

  • from
  • where
  • select
  • selectMany
  • join
  • leftJoin
  • groupJoin
  • orderBy
  • orderByDescending
  • take
  • takeWhile
  • skip
  • skipWhile
  • groupBy
  • distinct
  • concat
  • zip
  • union
  • intersect
  • except
  • first : Promise<T>
  • firstOrDefault : Promise<T | null>
  • last : Promise<T>
  • lastOrDefault : Promise<T | null>
  • single
  • singleOrDefault
  • contains
  • sequenceEqual
  • any : Promise<boolean>
  • all : Promise<boolean>
  • count : Promise<number>
  • min : Promise<number>
  • max : Promise<number>
  • sum : Promise<number>
  • average
  • aggregate
  • toList : Promise<T[]>

License

MIT License