提交 b6625830 编写于 作者: J Johannes Rieken

chore - more ES6 iteration

上级 d1bc5d86
......@@ -36,32 +36,32 @@ namespace delta {
export function ofSets<T>(before: Set<T>, after: Set<T>): { removed: T[], added: T[] } {
const removed: T[] = [];
const added: T[] = [];
before.forEach(element => {
for (let element of before) {
if (!after.has(element)) {
removed.push(element);
}
});
after.forEach(element => {
}
for (let element of after) {
if (!before.has(element)) {
added.push(element);
}
});
}
return { removed, added };
}
export function ofMaps<K, V>(before: Map<K, V>, after: Map<K, V>): { removed: V[], added: V[] } {
const removed: V[] = [];
const added: V[] = [];
before.forEach((value, index) => {
for (let [index, value] of before) {
if (!after.has(index)) {
removed.push(value);
}
});
after.forEach((value, index) => {
}
for (let [index, value] of after) {
if (!before.has(index)) {
added.push(value);
}
});
}
return { removed, added };
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册