UNPKG

@fanoutio/eventstream

Version:

Connect-compatible middleware that enables the easy creation of EventStream endpoints

23 lines (22 loc) 520 B
const singletons = {}; export function getProcessSingletons() { let dict; if (process.env.NODE_ENV !== 'production') { const proc = process; if (proc.devSingletons == null) { proc.devSingletons = {}; } dict = proc.devSingletons; } else { dict = singletons; } return dict; } export function getProcessSingleton(key, fn) { const dict = getProcessSingletons(); if (!(key in dict)) { dict[key] = fn(); } return dict[key]; }