UNPKG

docsify

Version:

A magical documentation generator.

24 lines (19 loc) 572 B
/** @typedef {(value: any) => void} CB */ /** @typedef {(cb: CB) => void} OnNext */ /** @typedef {(value: any) => void} NextFunction */ /** * Creates a pair of a function and an event emitter. * When the function is called, the event emitter calls the given callback with the value that was passed to the function. * @returns {[NextFunction, OnNext]} */ export function createNextFunction() { /** @type {CB} */ let storedCb = () => {}; function next(value) { storedCb(value); } function onNext(cb) { storedCb = cb; } return [next, onNext]; }