Function after

  • The opposite of before. This method creates a function that invokes func once it's called n or more times.

    Type Parameters

    • T extends ((...args) => any)

    Parameters

    • n: number

      The number of calls before func is invoked.

    • func: T

      The function to restrict.

    Returns T

    Returns the new restricted function.

    Since

    5.3.0

    Example

    const saves = ['profile', 'settings']
    const done = after(saves.length, () => console.log('done saving!'))

    forEach(saves, type => asyncSave({ 'type': type, 'complete': done }))
    // => Logs 'done saving!' after the two async saves have completed.