16 lines
315 B
JavaScript
16 lines
315 B
JavaScript
|
export const buildDict = (fn, ...args) => {
|
||
|
const dict = {};
|
||
|
for (let [key, value] of fn(...args)) {
|
||
|
dict[key] = value;
|
||
|
}
|
||
|
return dict;
|
||
|
}
|
||
|
|
||
|
export const buildList = (fn, ...args) => {
|
||
|
const list = [];
|
||
|
for (let value of fn(...args)) {
|
||
|
list.push(value);
|
||
|
}
|
||
|
return list;
|
||
|
}
|