我们不支持 IE 10 及以下版本浏览器

It appears you’re using an unsupported browser

Linqa.js首页、文档和下载 - 常用JavaScript包 - 开源中国社区

LGPL

3 人收藏

Linqa.js 详细介绍

Linqa.js 这是一个帮助我们像 LINQ 一样操作数组的扩展库。

``````    var data = [{x:1, y:5}, {x:3, y:7}, {x:5, y:9}, {x:7, y:11}, {x:9, y:13}];
document.write('(' + data.select(a=>a.x + ',' + a.y).join('), (') + ')');

output:
(1,5), (3, 7), (5,9), (7,11), (9, 13)

-----------------------------------------------

var data = [{x:1, y:1}, {x:3, y:3}, {x:5, y:5}, {x:7, y:7}, {x:9, y:9}];
var q = data.where(a=>a.x*a.y == 25).first();

q's value:
{x:5, y:5} )

-----------------------------------------------

var data= [1, 5, 3, 9, 7];
var str = data.orderAsc(a=>a).join(',');

str's value:
'1,3,5,7,9'

------------------------------------------------

var data6 = [{x:1, y:6, z:3}, {x:1, y:5, z:3}, {x:2, y:1, z:8}, {x:2, y:6, z:5}, {x:2, y:9, z:8}];
grps = data6.groupBy(a=>[a.x, a.z]);

grps's value:
[
{
key: [1, 3],
list: [{x:1,y:6,z:3}, {x:1, y:5, z:3}]
},
{
key: [2, 8],
list: [{x:2, y:1, z:8}, {x:2, y:9, z:8}]
},
{
key: [2, 5],
list: [{x:2, y:6, z:5}]
}
]
``````