Function after

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

    Parameters

    • n: number

      The number of calls before func is invoked.

    • func: (() => any)

      The function to restrict.

        • (): any
        • Returns any

    Returns ((this: any, ...args: any[]) => any)

    Returns the new restricted function.

      • (this, ...args): any
      • Parameters

        • this: any
        • Rest...args: any[]

        Returns any

    0.1.0

    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.