From f21169e3b09fbace31d7ab3eba2441e99bdce8f6 Mon Sep 17 00:00:00 2001 From: luan0ap Date: Sun, 4 Aug 2019 21:52:35 -0300 Subject: [PATCH 1/2] Create polyfill to Object.fromEntries add it to filter control --- assets/utils.js | 12 ++++++++++++ pages/index.vue | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/assets/utils.js b/assets/utils.js index 943893f..39f122f 100644 --- a/assets/utils.js +++ b/assets/utils.js @@ -13,3 +13,15 @@ export function shuffleEffects(obj) { return Object.fromEntries(copy); } + + +// Polifyll to Object.fromEntries +export function fromEntries(iterable) { + return [...iterable] + .reduce((obj, { + 0: key, + 1: val + }) => Object.assign(obj, { + [key]: val + }), {}) +} diff --git a/pages/index.vue b/pages/index.vue index e9da2df..0095b40 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -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 }, @@ -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); } } }; From 27aa17ed4736162487666cefa8c64cd0aba0ca8a Mon Sep 17 00:00:00 2001 From: luan0ap Date: Thu, 8 Aug 2019 11:12:59 -0300 Subject: [PATCH 2/2] Add polyfill fromEntries in shuffleEffects function --- assets/utils.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/assets/utils.js b/assets/utils.js index 39f122f..dd7042f 100644 --- a/assets/utils.js +++ b/assets/utils.js @@ -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; @@ -11,17 +23,5 @@ export function shuffleEffects(obj) { copy[index] = value; } - return Object.fromEntries(copy); -} - - -// Polifyll to Object.fromEntries -export function fromEntries(iterable) { - return [...iterable] - .reduce((obj, { - 0: key, - 1: val - }) => Object.assign(obj, { - [key]: val - }), {}) + return fromEntries(copy); }