From 6bb1932db8e367e56d266271680b7f4fb40a3045 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Mon, 23 Dec 2019 18:03:16 -0800 Subject: [PATCH] fix: remove core-js dependency --- src/components/picker/nimble-picker.js | 4 +++- src/utils/index.js | 6 ++++-- src/utils/store.js | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/picker/nimble-picker.js b/src/components/picker/nimble-picker.js index dfbfe5e..3c1e8b4 100644 --- a/src/components/picker/nimble-picker.js +++ b/src/components/picker/nimble-picker.js @@ -105,7 +105,9 @@ export default class NimblePicker extends React.PureComponent { this.CUSTOM.push(customEmoji) }) - allCategories.push(...Object.values(customCategories)) + allCategories = allCategories.concat( + Object.keys(customCategories).map((key) => customCategories[key]), + ) } this.hideRecent = true diff --git a/src/utils/index.js b/src/utils/index.js index 9b4fa4d..90e3ddd 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -5,6 +5,8 @@ import { uncompress } from './data' const COLONS_REGEX = /^(?:\:([^\:]+)\:)(?:\:skin-tone-(\d)\:)?$/ const SKINS = ['1F3FA', '1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'] +const _JSON = JSON // don't let babel include all of core-js for stringify/parse + function unifiedToNative(unified) { var unicodes = unified.split('-'), codePoints = unicodes.map((u) => `0x${u}`) @@ -107,7 +109,7 @@ function getData(emoji, skin, set, data) { emojiData.variations || (emojiData.variations = []) if (emojiData.skin_variations && skin > 1) { - emojiData = JSON.parse(JSON.stringify(emojiData)) + emojiData = _JSON.parse(_JSON.stringify(emojiData)) var skinKey = SKINS[skin - 1], variationData = emojiData.skin_variations[skinKey] @@ -132,7 +134,7 @@ function getData(emoji, skin, set, data) { } if (emojiData.variations && emojiData.variations.length) { - emojiData = JSON.parse(JSON.stringify(emojiData)) + emojiData = _JSON.parse(_JSON.stringify(emojiData)) emojiData.unified = emojiData.variations.shift() } diff --git a/src/utils/store.js b/src/utils/store.js index 763476e..48179bd 100644 --- a/src/utils/store.js +++ b/src/utils/store.js @@ -3,6 +3,8 @@ var NAMESPACE = 'emoji-mart' var isLocalStorageSupported = typeof window !== 'undefined' && 'localStorage' in window +const _JSON = JSON // don't let babel include all of core-js for stringify/parse + let getter let setter @@ -30,7 +32,7 @@ function set(key, value) { } else { if (!isLocalStorageSupported) return try { - window.localStorage[`${NAMESPACE}.${key}`] = JSON.stringify(value) + window.localStorage[`${NAMESPACE}.${key}`] = _JSON.stringify(value) } catch (e) {} } } @@ -44,7 +46,7 @@ function get(key) { var value = window.localStorage[`${NAMESPACE}.${key}`] if (value) { - return JSON.parse(value) + return _JSON.parse(value) } } catch (e) { return