UNPKG

@expo/vector-icons

Version:

Built-in support for popular icon fonts and the tooling to create your own Icon components from your font and glyph map. This is a wrapper around react-native-vector-icons to make it compatible with Expo.

28 lines (21 loc) 601 B
const TYPE_VALUE = 'value'; const TYPE_ERROR = 'error'; export default function createIconSourceCache() { const cache = new Map(); const setValue = (key, value) => cache.set(key, { type: TYPE_VALUE, data: value }); const setError = (key, error) => cache.set(key, { type: TYPE_ERROR, data: error }); const has = key => cache.has(key); const get = key => { if (!cache.has(key)) { return undefined; } const { type, data } = cache.get(key); if (type === TYPE_ERROR) { throw data; } return data; }; return { setValue, setError, has, get }; }