Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Create polyfill to Object.fromEntries add it to filter control #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion assets/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@

// Polifyll to Object.fromEntries
export function fromEntries(iterable) {
return [...iterable]
.reduce((obj, {
0: key,
1: val
}) => Object.assign(obj, {
[key]: val
}), {})
}

export function shuffleEffects(obj) {
const copy = Object.entries(obj).slice(0);
const length = copy.length;
Expand All @@ -11,5 +23,5 @@ export function shuffleEffects(obj) {
copy[index] = value;
}

return Object.fromEntries(copy);
return fromEntries(copy);
}
4 changes: 2 additions & 2 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Effects from "~/components/Effects";
import Inspect from "~/components/Inspect";
import Controls from "~/components/Controls";
import { effects } from "~/assets/effects.js";
import { shuffleEffects } from "~/assets/utils.js";
import { shuffleEffects, fromEntries } from "~/assets/utils.js";

export default {
components: { Navbar, Header, CarbonAd, Effects, Inspect, Controls },
Expand All @@ -48,7 +48,7 @@ export default {
const filtered = Object.entries(effects).filter(
([name, data]) => filters[data.type]
);
this.effects = Object.fromEntries(filtered);
this.effects = fromEntries(filtered);
}
}
};
Expand Down