refactor: remove _JSON
parent
99eae3605d
commit
97f6ffde2d
|
@ -5,8 +5,6 @@ import { uncompress } from './data'
|
||||||
const COLONS_REGEX = /^(?:\:([^\:]+)\:)(?:\:skin-tone-(\d)\:)?$/
|
const COLONS_REGEX = /^(?:\:([^\:]+)\:)(?:\:skin-tone-(\d)\:)?$/
|
||||||
const SKINS = ['1F3FA', '1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF']
|
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) {
|
function unifiedToNative(unified) {
|
||||||
var unicodes = unified.split('-'),
|
var unicodes = unified.split('-'),
|
||||||
codePoints = unicodes.map((u) => `0x${u}`)
|
codePoints = unicodes.map((u) => `0x${u}`)
|
||||||
|
@ -109,7 +107,7 @@ function getData(emoji, skin, set, data) {
|
||||||
emojiData.variations || (emojiData.variations = [])
|
emojiData.variations || (emojiData.variations = [])
|
||||||
|
|
||||||
if (emojiData.skin_variations && skin > 1) {
|
if (emojiData.skin_variations && skin > 1) {
|
||||||
emojiData = _JSON.parse(_JSON.stringify(emojiData))
|
emojiData = JSON.parse(JSON.stringify(emojiData))
|
||||||
|
|
||||||
var skinKey = SKINS[skin - 1],
|
var skinKey = SKINS[skin - 1],
|
||||||
variationData = emojiData.skin_variations[skinKey]
|
variationData = emojiData.skin_variations[skinKey]
|
||||||
|
@ -134,7 +132,7 @@ function getData(emoji, skin, set, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emojiData.variations && emojiData.variations.length) {
|
if (emojiData.variations && emojiData.variations.length) {
|
||||||
emojiData = _JSON.parse(_JSON.stringify(emojiData))
|
emojiData = JSON.parse(JSON.stringify(emojiData))
|
||||||
emojiData.unified = emojiData.variations.shift()
|
emojiData.unified = emojiData.variations.shift()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@ var NAMESPACE = 'emoji-mart'
|
||||||
var isLocalStorageSupported =
|
var isLocalStorageSupported =
|
||||||
typeof window !== 'undefined' && 'localStorage' in window
|
typeof window !== 'undefined' && 'localStorage' in window
|
||||||
|
|
||||||
const _JSON = JSON // don't let babel include all of core-js for stringify/parse
|
|
||||||
|
|
||||||
let getter
|
let getter
|
||||||
let setter
|
let setter
|
||||||
|
|
||||||
|
@ -32,7 +30,7 @@ function set(key, value) {
|
||||||
} else {
|
} else {
|
||||||
if (!isLocalStorageSupported) return
|
if (!isLocalStorageSupported) return
|
||||||
try {
|
try {
|
||||||
window.localStorage[`${NAMESPACE}.${key}`] = _JSON.stringify(value)
|
window.localStorage[`${NAMESPACE}.${key}`] = JSON.stringify(value)
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +44,7 @@ function get(key) {
|
||||||
var value = window.localStorage[`${NAMESPACE}.${key}`]
|
var value = window.localStorage[`${NAMESPACE}.${key}`]
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
return _JSON.parse(value)
|
return JSON.parse(value)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue