UNPKG

@modern-js/runtime-utils

Version:

A Progressive React Framework for modern web development.

17 lines (16 loc) 467 B
function createRequestContext(context) { const _context = context || new Map(); function get(key) { if ('string' == typeof key) return _context.get(key); return _context.get(key.symbol) || key.getDefaultValue(); } function set(key, value) { if ('string' == typeof key) _context.set(key, value); else _context.set(key.symbol, value); } return { set, get }; } export { createRequestContext };