All Projects → jinhduong → linq-fns

jinhduong / linq-fns

Licence: MIT license
👴 LINQ for Javascript, written by TypeScript

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to linq-fns

Typescript.net
A JavaScript-Friendly .NET Based TypeScript Library (Moved)
Stars: ✭ 245 (+231.08%)
Mutual labels:  linq
react-gist-slideshow
React Component to view gists in a slideshow
Stars: ✭ 15 (-79.73%)
Mutual labels:  gist
Linq.Expression.Optimizer
System.Linq.Expression expressions optimizer. http://thorium.github.io/Linq.Expression.Optimizer
Stars: ✭ 81 (+9.46%)
Mutual labels:  linq
GitHub Android
A simple client for GitHub.
Stars: ✭ 49 (-33.78%)
Mutual labels:  gist
mypy-playground
The mypy playground. Try mypy with your web browser.
Stars: ✭ 58 (-21.62%)
Mutual labels:  gist
LinqBuilder
LinqBuilder is an advanced implementation of the specification pattern specifically targeting LINQ query generation.
Stars: ✭ 34 (-54.05%)
Mutual labels:  linq
Dapper.lnskydb
基于Dapper的LINQ扩展,支持Lambda表达式,支持按时间分库分表,也可以自定义分库分表方法,且实体类有T4模版自动生成.省去手写实体类的麻烦。已在实际项目使用
Stars: ✭ 228 (+208.11%)
Mutual labels:  linq
linq2db.LINQPad
linq2db.LINQPad is a driver for LINQPad.
Stars: ✭ 65 (-12.16%)
Mutual labels:  linq
Linq.ts
linq for typescript
Stars: ✭ 33 (-55.41%)
Mutual labels:  linq
gister
A command line app to create Gists in Go
Stars: ✭ 26 (-64.86%)
Mutual labels:  gist
Masuit.Tools
该仓库为 https://github.com/ldqk/Masuit.Tools 的镜像仓库,代码更新存在较大的延迟。建议前往源仓库:https://github.com/ldqk/Masuit.Tools
Stars: ✭ 755 (+920.27%)
Mutual labels:  linq
cli-cube-timer
Time your solves, without leaving the terminal
Stars: ✭ 19 (-74.32%)
Mutual labels:  gist
python-linq-samples
Python Linq Examples: Comparision of C# Linq functional programming to Python
Stars: ✭ 69 (-6.76%)
Mutual labels:  linq
PocoDynamo
C# .NET Typed POCO Client for AWS Dynamo DB
Stars: ✭ 39 (-47.3%)
Mutual labels:  linq
Kendo.DynamicLinqCore
KendoNET.DynamicLinq implements server paging, filtering, sorting, grouping, and aggregating to Kendo UI via Dynamic Linq for .Net Core App(1.x ~ 3.x).
Stars: ✭ 36 (-51.35%)
Mutual labels:  linq
Morelinq
Extensions to LINQ to Objects
Stars: ✭ 2,833 (+3728.38%)
Mutual labels:  linq
pastila
a electron app that takes notes via markdown and github gist.
Stars: ✭ 25 (-66.22%)
Mutual labels:  gist
multiplex.js
LINQ for JavaScript.
Stars: ✭ 79 (+6.76%)
Mutual labels:  linq
ObservableComputations
Cross-platform .NET library for computations whose arguments and results are objects that implement INotifyPropertyChanged and INotifyCollectionChanged (ObservableCollection) interfaces.
Stars: ✭ 94 (+27.03%)
Mutual labels:  linq
ideas-md
A float-to-the-top ideas log built with React
Stars: ✭ 32 (-56.76%)
Mutual labels:  gist

linq-fns

.NET LINQ functions for JavaScript written in TypeScript.

  • Provides Queryable<T>,which is reusable, variable and uses a predicate collection for deferred execution.
  • 🔨 Contains most of the original .NET methods and some additional methods.
  • 🔨 Supports Promise as an input source.
  • 🙅 All APIs are JavaScript native methods so can be easily incorporated into existing JavaScript projects.
  • 📊 Includes some simple drivers (such as Firebase Realtime database).
npm install linq-fns --save

Browser client files can be found in the release folder.

Basic example

Node or browser

// ES6
import { Queryable } from 'linq-fns';
// ES5
const Queryable = require('linq-fns').Queryable;

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() 
                    // This will return a number, not Promise<number>
                }
            })

// Async/ await
const data = await query.toList();

// Promise
// Will return Promise<{area:string, total:number}>
const asyncData = query.toList(); 
asyncData.then(data => {
    console.log(data);
    // [
    //     {area: 'Euro': total: 2},
    //     {area:'South America', total: 1}
    // ]
});

Firebase

const FireBaseQueryable = require('linq-fns').FireBaseQueryable;
const admin = require('firebase-admin');
const serviceAccount = require('./serviceAccountKey');

admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    databaseURL: 'https://xxx.firebaseio.com'
});

const db = admin.database();
const postsRepo = new FireBaseQueryable(db,'<yourdb>.posts');

// READ AND QUERY DATA
// ES5 Promise
postsRepo.getQuery()
    .where('...')
    .select('...')
    .toList().then(x=>'...');

// Async/await
const data = await postsRepo.getQuery()
                            .where('...')
                            .select('...')
                            .toList();

// WRITE DATA
// Prepare calls, but do not send requests to server
postsRepo.add(item);
postsRepo.remove(item);
postsRepo.update(item);

// Call this to execute 3 above methods
postsRepo.commitChanges();

localStorage

// Node
const LocalStorageQueryable = require('linq-fns').LocalStorageQueryable;
const postsRepo = new LocalStorageQueryable("posts");

postsRepo.add(item);
postsRepo.remove(item);
postsRepo.update(item);

// Call this to execute 3 above methods
postsRepo.commitChanges();

gist file

//Node
const GistQueryable = require('linq-fns').GistQueryable;
const postsRepo = new GistQueryable(
    "6d183b7f997819cd5a8354f35c1e471f123", // gist file
    "259f97b96762c9d3a155630d12321fd1cfaf253ff", // access token
    "posts") // table name

postsRepo.add(item);
postsRepo.remove(item);
postsRepo.update(item);
postsRepo.commitChanges();

Process

1.Methods

  • 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[]>

2. Drivers

  • Firebase : Node
  • Localstorage : Node & Browser
  • Gists Github : Node & Browser
  • ...

Documents

https://github.com/jinhduong/linq-fns/tree/docs

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].