KingNET.WebUI/Scripts/linqjs/test/join.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/// <reference path="testrunner.htm"/>
module("Join");
test("Join", function ()
{
var math = { yamada: 100, tanaka: 80, yoshida: 94 };
var english = { yamada: 73, yoshida: 26, tanaka: 99 };
actual = Enumerable.From(math)
.Join(english, "outer=>outer.Key", "inner=>inner.Key",
"o,i=>{Name:o.Key,Math:o.Value,English:i.Value}")
.ToArray();
expected = [{ Name: "yamada", Math: 100, English: 73 },
{ Name: "tanaka", Math: 80, English: 99 },
{ Name: "yoshida", Math: 94, English: 26}];
deepEqual(actual, expected);
actual = Enumerable.From(math)
.Join(english, "outer=>outer", "inner=>inner",
"o,i=>{Name:o.Key,Math:o.Value,English:i.Value}", "$.Key")
.ToArray();
expected = [{ Name: "yamada", Math: 100, English: 73 },
{ Name: "tanaka", Math: 80, English: 99 },
{ Name: "yoshida", Math: 94, English: 26}];
deepEqual(actual, expected);
});
test("GroupJoin", function ()
{
var array1 = [3, 3, 4, 5, 6];
var array2 = [2, 4, 5, 6, 6];
actual = Enumerable.From(array1)
.GroupJoin(array2, " i => i", " i => i",
function (outer, collection)
{
return {
outer: outer,
collection: collection.ToArray()
}
})
.ToArray();
expected = [{ outer: 3, collection: [] },
{ outer: 3, collection: [] },
{ outer: 4, collection: [4] },
{ outer: 5, collection: [5] },
{ outer: 6, collection: [6, 6]}];
deepEqual(actual, expected);
actual = Enumerable.From(array1)
.GroupJoin(array2, " i => i", " i => i",
function (outer, collection)
{
return {
outer: outer,
collection: collection.ToArray()
}
},
function (key) { return key % 2 == 0; })
.ToArray();
expected = [{ outer: 3, collection: [5] },
后面还有 6 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。