common-stuff
    Preparing search index...

    Function pSeries

    • Runs the given task functions sequentially and collects their results.

      Stops at the first rejection. If you want to keep going on errors, wrap each task in a tryCatch (from fp.ts) before passing it.

      Return type preserves the tuple shape of the input so heterogeneous return types are inferred individually instead of being unified.

      Type Parameters

      • const T extends readonly (() => Promise<unknown>)[]

      Parameters

      • tasks: T

      Returns Promise<
          {
              -readonly [K in string
              | number
              | symbol]: T[K<K>] extends () => Promise<R> ? R : never
          },
      >

      const [user, post] = await pSeries([
      () => loadUser(1), // () => Promise<User>
      () => loadPost(2), // () => Promise<Post>
      ])
      // user: User, post: Post