Merge pull request #402 from missive/nolan/fix-json

refactor: remove _JSON
release
Etienne Lemay 2020-03-13 08:11:01 -04:00 committed by GitHub
commit 113b07abcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -5,8 +5,6 @@ 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}`)
@ -109,7 +107,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]
@ -134,7 +132,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()
}

View File

@ -3,8 +3,6 @@ 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
@ -32,7 +30,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) {}
}
}
@ -46,7 +44,7 @@ function get(key) {
var value = window.localStorage[`${NAMESPACE}.${key}`]
if (value) {
return _JSON.parse(value)
return JSON.parse(value)
}
} catch (e) {
return