Skip to content

Instantly share code, notes, and snippets.

@abozhilov
Created December 22, 2017 18:29
Show Gist options
  • Save abozhilov/a8f80a69c5874f77ab9252d5859460eb to your computer and use it in GitHub Desktop.
Save abozhilov/a8f80a69c5874f77ab9252d5859460eb to your computer and use it in GitHub Desktop.
function fromKeys(iterable, value) {
let obj = {};
for (let i of iterable) {
if (typeof value === 'function') {
obj[i] = value(i)
}
else {
obj[i] = value;
}
}
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment