All Projects → wm123450405 → linqjs

wm123450405 / linqjs

Licence: MIT License
use linq and lambda in javascript on es6, can use linq function in an Object or an Array or a String value | 一个方便对数组、字典、树形数据进行操作、筛选等操作的工具库

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to linqjs

linqjs
Perform queries on collections in the manner of C#s System.Linq in JavaScript
Stars: ✭ 14 (-17.65%)
Mutual labels:  linq, lazy, array
Netfabric.hyperlinq
High performance LINQ implementation with minimal heap allocations. Supports enumerables, async enumerables, arrays and Span<T>.
Stars: ✭ 479 (+2717.65%)
Mutual labels:  linq, array
Qone
Next-generation web query language, extend .NET LINQ for javascript.
Stars: ✭ 463 (+2623.53%)
Mutual labels:  linq, query
Jaque
Lets Java 8 Lambdas to be represented as objects in the form of expression trees at runtime
Stars: ✭ 152 (+794.12%)
Mutual labels:  linq, lambda
VBA-Arrays
😎 Array functions that are similar JavaScript functions. Example: Push, Pop, Shift, Unshift, Sort, length, toString.
Stars: ✭ 48 (+182.35%)
Mutual labels:  query, array
Yalinqo
Yet Another LINQ to Objects for PHP [Simplified BSD]
Stars: ✭ 400 (+2252.94%)
Mutual labels:  linq, query
Masuit.tools
ldqk.xyz/55
Stars: ✭ 2,539 (+14835.29%)
Mutual labels:  linq, lambda
ienumerable
Deep immutable, Lightweight Enumerable with superpowers
Stars: ✭ 63 (+270.59%)
Mutual labels:  linq, array
Gridify
Easy and optimized way to apply Filtering, Sorting, and Pagination using text-based data.
Stars: ✭ 372 (+2088.24%)
Mutual labels:  linq, query
lambda2js
Converts a C# expression tree (from Linq namespace) to a syntatically correct javascript code.
Stars: ✭ 51 (+200%)
Mutual labels:  linq, lambda
go-streams
Stream Collections for Go. Inspired in Java 8 Streams and .NET Linq
Stars: ✭ 127 (+647.06%)
Mutual labels:  linq, array
Fluentvalidation.blazor
Fluent Validation-powered Blazor component for validating standard <EditForm> 🌌 ✅
Stars: ✭ 140 (+723.53%)
Mutual labels:  linq, lambda
Dapper.lnskydb
基于Dapper的LINQ扩展,支持Lambda表达式,支持按时间分库分表,也可以自定义分库分表方法,且实体类有T4模版自动生成.省去手写实体类的麻烦。已在实际项目使用
Stars: ✭ 228 (+1241.18%)
Mutual labels:  linq, lambda
linq
A familiar set of functions that operate on JavaScript iterables (ES2015+) in a similar way to .NET's LINQ does with enumerables.
Stars: ✭ 39 (+129.41%)
Mutual labels:  linq, enumerable
lazy-arr
Arrays that look just like regular JavaScript arrays, but are computed lazily.
Stars: ✭ 67 (+294.12%)
Mutual labels:  lazy, array
shim
HTTP Handler shim for Go projects running on AWS Lambda
Stars: ✭ 64 (+276.47%)
Mutual labels:  lambda
utils.js
👷 🔧 zero dependencies vanilla JavaScript utils.
Stars: ✭ 14 (-17.65%)
Mutual labels:  array
tts
📝 🔉 A simple text-to-speech tool. Converts your text to speech with any of Streamlab's voices. Frontend built with GatsbyJS, backend is serverless Node.js
Stars: ✭ 133 (+682.35%)
Mutual labels:  lambda
TIL
Today I Learned
Stars: ✭ 43 (+152.94%)
Mutual labels:  query
lib12
lib12 is a library of universal helpers and extensions useful in any .NET project
Stars: ✭ 30 (+76.47%)
Mutual labels:  linq

LinqJs

GitHub release npm npm Travis (.com) Codecov npm bundle size NPM GitHub search hit counter GitHub search hit counter GitHub search hit counter

Since 2.1.0, I rewrite all to use new features of ES6. The performance be better, memory used less and using deferred execution.

对 JavaScript 中原生数组、对象进行扩展, 提供了一些对数据的操作方法. 包括对数组结构、树形结构、对象结构等数据进行 查询,排序,连接,合并,分组,分段,转换,遍历 等一系列功能. 可以用精炼和易懂的代码实现比较复杂的操作.

一开始,在 ES5 的时代,我觉得 js 对数组的操作实在太繁琐了. 可能正是这种繁琐才有了像 underscore 这样优秀的 js 库的出现. 我本不是做前端出身的,我觉得其他语言对于数组或列表的操作要比 js 好用很多,提供了大量的方法和功能. 于是最早参考的 C#中的功能实现了一些方法, 就有了1.0版本. 后来,ES6 发布并普及开来,js 原生数组也增加了很多好用的功能,但是这还远远不够. 于是我又翻出了我的代码用 ES6 重写, 有了2.1版本, 并发布至npm上. 这一次我又借鉴了另外一些语言中的部分特性, 比如 php.我想我后面可能再会添加一些其他语言或框架类似的功能,比如 Java,Python 等. 后来我在 stackoverflow 中看到很多人对于树形结构的操作提了很多的问题,我想我的工具包应该要可以为他们提供帮助.于是在最新的几个版本中我加入了对树形结构的一些操作.

帮助文档(完善中) 👍

Documentation(not completed) 👍

Usage 用法

1. Import 引入

Use NodeJs 使用NodeJs

$ npm install --save linq-js
const Enumerable = require('linq-js');
  • description:This module require ES6. I suggest you to use this with ES6. The following examples is already use ES6.
  • 说明:本module依赖于ES6。建议项目在中使用ES6。以下案例中将均使用ES6写法。

2. Get IEnumerable instance 获取IEnumerable对象

interface IEnumerable { };

function asEnumerable():IEnumerable;
//You can use the asEnumerable methods of every object's to get an IEnumerable object;
//任何对象都有asEnumerable方法用来获取IEnumerable对象

e.g. 案例

'abc'.asEnumerable();
[1,2,3].asEnumerable();
({a:1,b:2}).asEnumerable();

3. Use IEnumerable instance 使用IEnumerable对象

e.g. 案例 简单的判断数组中的数据

let pets = [ { name: "Barley", age: 8, vaccinated: true }, { name: "Boots", age: 4, vaccinated: false }, { name: "Whiskers", age: 1, vaccinated: false } ];
let unvaccinated = pets.asEnumerable().any(p => p.age > 1 && p.vaccinated === false);
console.log(`There ${ unvaccinated ? "are" : "are not any" } unvaccinated animals over age one.`);
// This code produces the following output: 这段代码输出以下内容:
//  There are unvaccinated animals over age one.

e.g. 案例 两个数组进行内连接查询

let magnus = { id: 1, name: "Hedlund, Magnus" }, terry = { id: 2, name: "Adams, Terry" }, charlotte = { id: 3, name: "Weiss, Charlotte" };
let barley = { name: "Barley", owner: 2 }, boots = { name: "Boots", owner: 2 }, whiskers = { name: "Whiskers", owner: 3 }, daisy = { name: "Daisy", owner: 1 };
let people = [ magnus, terry, charlotte ];
let pets = [ barley, boots, whiskers, daisy ];
let query = people.asEnumerable().join(pets,
    (person, pet) => ({ ownerName: person.name, pet: pet.name }),
    person => person.id,
    pet => pet.owner);
for (let obj of query) {
    console.log(`${ obj.ownerName } - ${ obj.pet }`);
}
/*
 This code produces the following output: 这段代码输出以下内容:
 Hedlund, Magnus - Daisy
 Adams, Terry - Barley
 Adams, Terry - Boots
 Weiss, Charlotte - Whiskers
 */

:see mdn(Array) :参考 MDN(Array)

:see msdn(IEnumerable) :参考 MSDN(IEnumerable)

:see msdn(Enumerable) :参考 MSDN(Enumerable)

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].