Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

fix: types for withTimeoutOptions #3422

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions packages/ipfs-core-utils/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
'use strict'

/**
* @template {any[]} ARGS
* @template R
* @typedef {(...args: ARGS) => R} Fn
*/
8 changes: 4 additions & 4 deletions packages/ipfs-core-utils/src/with-timeout-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ const parseDuration = require('parse-duration').default
const { TimeoutError } = require('./errors')

/**
* @template {any[]} ARGS
* @template {any[]} Args
* @template {Promise<any> | AsyncIterable<any>} R - The return type of `fn`
* @param {Fn<ARGS, R>} fn
* @param {(...args:Args) => R} fn
* @param {number} [optionsArgIndex]
* @returns {Fn<ARGS, R>}
* @returns {(...args:Args) => R}
*/
function withTimeoutOption (fn, optionsArgIndex) {
// eslint-disable-next-line
return /** @returns {R} */(/** @type {ARGS} */...args) => {
return /** @returns {R} */(/** @type {Args} */...args) => {
const options = args[optionsArgIndex == null ? args.length - 1 : optionsArgIndex]
if (!options || !options.timeout) return fn(...args)

Expand Down