{
  "_id": "function-timeout",
  "maintainers": [
    {
      "name": "sindresorhus",
      "email": "sindresorhus@gmail.com"
    }
  ],
  "keywords": [
    "function",
    "synchronous",
    "timeout",
    "time",
    "out",
    "cancel",
    "expire",
    "abort",
    "regex",
    "regexp",
    "redos",
    "security",
    "func",
    "fn",
    "script",
    "execute",
    "halt",
    "termination"
  ],
  "dist-tags": {
    "latest": "1.0.2"
  },
  "author": {
    "name": "Sindre Sorhus",
    "email": "sindresorhus@gmail.com",
    "url": "https://sindresorhus.com"
  },
  "_rev": "4-e7802c24d65b8b759189f050614cb754",
  "description": "Make a synchronous function have a timeout",
  "readme": "# function-timeout\n\n> Make a synchronous function have a timeout\n\nThis can be useful if you accept external data and want to ensure processing it does not take too long.\n\nThe timeout only works in Node.js. When used in a browser, the function will be wrapped, but never time out.\n\n*I have a [different package](https://github.com/sindresorhus/super-regex) to prevent [ReDoS](https://en.wikipedia.org/wiki/ReDoS) for regexes.*\n\n## Install\n\n```sh\nnpm install function-timeout\n```\n\n## Usage\n\n```js\nimport functionTimeout, {isTimeoutError} from 'function-timeout';\n\nconst generateNumbers = count => {\n\t// Imagine this takes a long time.\n};\n\nconst generateNumbersWithTimeout = functionTimeout(generateNumbers, {timeout: 100});\n\ntry {\n\tconsole.log(generateNumbersWithTimeout(500));\n} catch (error) {\n\tif (isTimeoutError(error)) {\n\t\tconsole.error('Timed out');\n\t} else {\n\t\tthrow error;\n\t}\n}\n```\n\n## API\n\n### functionTimeout(function, options?)\n\nReturns a wrapped version of the given function that throws a timeout error if the execution takes longer than the given timeout.\n\n#### options\n\nType: `object`\n\n##### timeout?\n\nType: `number` *(integer)*\n\nThe time in milliseconds to wait before timing out.\n\nKeep in mind that execution time can vary between different hardware and Node.js versions. Set a generous timeout to avoid flakiness.\n\n### isTimeoutError(error)\n\nReturns a boolean for whether the given error is a timeout error.\n\n## Related\n\n- [super-regex](https://github.com/sindresorhus/super-regex) - Make a regular expression time out if it takes too long to execute\n- [p-timeout](https://github.com/sindresorhus/p-timeout) - Timeout a promise after a certain amount of time\n",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/sindresorhus/function-timeout.git"
  },
  "bugs": {
    "url": "https://github.com/sindresorhus/function-timeout/issues"
  },
  "license": "MIT",
  "versions": {
    "0.1.0": {
      "name": "function-timeout",
      "version": "0.1.0",
      "description": "Make a synchronous function have a timeout",
      "license": "MIT",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/sindresorhus/function-timeout.git"
      },
      "funding": "https://github.com/sponsors/sindresorhus",
      "author": {
        "name": "Sindre Sorhus",
        "email": "sindresorhus@gmail.com",
        "url": "https://sindresorhus.com"
      },
      "type": "module",
      "exports": {
        "types": "./index.d.ts",
        "node": "./index.js",
        "default": "./browser.js"
      },
      "engines": {
        "node": ">=14.16"
      },
      "scripts": {
        "test": "xo && ava && tsd"
      },
      "keywords": [
        "function",
        "synchronous",
        "timeout",
        "time",
        "out",
        "cancel",
        "expire",
        "abort",
        "regex",
        "regexp",
        "redos",
        "security",
        "func",
        "fn",
        "script",
        "execute"
      ],
      "devDependencies": {
        "ava": "^4.3.0",
        "in-range": "^3.0.0",
        "time-span": "^5.0.0",
        "tsd": "^0.20.0",
        "xo": "^0.49.0"
      },
      "types": "./index.d.ts",
      "gitHead": "8ee023af773e121d970da212224fe21a3376a1ea",
      "bugs": {
        "url": "https://github.com/sindresorhus/function-timeout/issues"
      },
      "homepage": "https://github.com/sindresorhus/function-timeout#readme",
      "_id": "function-timeout@0.1.0",
      "_nodeVersion": "14.19.2",
      "_npmVersion": "8.3.2",
      "dist": {
        "integrity": "sha512-P+OaGUVgyAJS3b9l2p1mHzAfjZhNLrZ0IcCzo+RY2mVWm15j6s75ck5p6j5ZLoVkVGki2X1L4lOiUkxLoCYpBg==",
        "shasum": "ddbf013e9ab83bbe170a65589b6a233b0084bfa0",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/function-timeout/-/function-timeout-0.1.0.tgz",
        "fileCount": 6,
        "unpackedSize": 5828,
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIEipPN73WEHn2hz/9goMr0hgcHe/STh73JnNCzfI26a7AiEAo/ZRg/sCjOpqTL27yvQIRhkYiFtQb8xIXTbt9KdMi5s="
          }
        ],
        "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJimds+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrIBw/+MVvAVMhZPgZLXx+mZwNyoFHDhkUXddwUkf8Hsa+qJHYrX7ir\r\nYrJNX+sOj+H1Ko5tgiy5HmW9WXH0CQeban9LwcILpB4y74RHAM6FRD0Nf7mo\r\n9u6tlObPgpqTZLb4hv2B7PHK5doXgQc1KFZwVLhuak7ZA1UjH2TOQ53dXxAw\r\nHk7tccGeFLEEetlNAbFc0foN6lF8yDDCpNYzz72qm4kHa6X8OZmyD+ZsOO1n\r\nJZ49Itl+YA13I9LlFiRh8TXqvO+9OKmaZUQ5eXeeP8KrXtkTN09i9d6S/JBs\r\nveaXYfSqQHnAmeczyXKGE9PMu6P+nPFQkfmrE/E5LzK2h7rmWtZVfDaaQiVX\r\nvIMmvdmqVjPdC55/t5V5PfdOHXqnAQRn0THbpHYzrUclCM6fHxBpk+I6cx4S\r\nLCgxZOydt35wji4y0jiQQruuSaVXXBKB4tSaNQK9POU73y3h6GA/QkbaNzrq\r\nuVgs4vt80gZUsaJfl2AH65Ul34aD0v7YEDZLTZFozxLxQKgvUyjwIYvuIN+w\r\n7yuKTisoJzt6Rzuk8o0Lqa0+IGnVxebG+o6WT4fyB8yElPR/6sGTpo8bO12i\r\nmsH7kvADCE/u3l0zZSWU6mVBc0CGW9s/J7BW9RIXpHpu9B95We2JdCYxuTFp\r\npMcmDOKKcRqFS9S4nmXCmyL5RInOd1XBHTA=\r\n=8sFf\r\n-----END PGP SIGNATURE-----\r\n"
      },
      "_npmUser": {
        "name": "sindresorhus",
        "email": "sindresorhus@gmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "sindresorhus",
          "email": "sindresorhus@gmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages",
        "tmp": "tmp/function-timeout_0.1.0_1654250302461_0.9300863745963093"
      },
      "_hasShrinkwrap": false
    },
    "0.1.1": {
      "name": "function-timeout",
      "version": "0.1.1",
      "description": "Make a synchronous function have a timeout",
      "license": "MIT",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/sindresorhus/function-timeout.git"
      },
      "funding": "https://github.com/sponsors/sindresorhus",
      "author": {
        "name": "Sindre Sorhus",
        "email": "sindresorhus@gmail.com",
        "url": "https://sindresorhus.com"
      },
      "type": "module",
      "exports": {
        "types": "./index.d.ts",
        "node": "./index.js",
        "default": "./browser.js"
      },
      "engines": {
        "node": ">=14.16"
      },
      "scripts": {
        "test": "xo && ava && tsd"
      },
      "keywords": [
        "function",
        "synchronous",
        "timeout",
        "time",
        "out",
        "cancel",
        "expire",
        "abort",
        "regex",
        "regexp",
        "redos",
        "security",
        "func",
        "fn",
        "script",
        "execute"
      ],
      "devDependencies": {
        "ava": "^4.3.0",
        "in-range": "^3.0.0",
        "time-span": "^5.0.0",
        "tsd": "^0.20.0",
        "xo": "^0.49.0"
      },
      "types": "./index.d.ts",
      "gitHead": "8bd130c18582a2572680520d96c7046e9be9ef16",
      "bugs": {
        "url": "https://github.com/sindresorhus/function-timeout/issues"
      },
      "homepage": "https://github.com/sindresorhus/function-timeout#readme",
      "_id": "function-timeout@0.1.1",
      "_nodeVersion": "14.19.3",
      "_npmVersion": "8.3.2",
      "dist": {
        "integrity": "sha512-0NVVC0TaP7dSTvn1yMiy6d6Q8gifzbvQafO46RtLG/kHJUBNd+pVRGOBoK44wNBvtSPUJRfdVvkFdD3p0xvyZg==",
        "shasum": "6bf71d3d24c894d43b2bec312cabb8c5add2e9da",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/function-timeout/-/function-timeout-0.1.1.tgz",
        "fileCount": 6,
        "unpackedSize": 5885,
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIQDL1EWTh085K/D+2bUiTUSRCmyn1TBPz87dozp/SuloPQIgSGut92rFobXQCe1+m955sRsSqwH3yfPPMFXEBCyOBAc="
          }
        ],
        "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiu5PVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo0KQ/5Ab/aXBwzJrrL4X0ykav5FNYG9QmHIY8O3X9F1Vm6W8m05NUL\r\nAvAs3Yg0SsVII17VzOLgImo54Nu/9rfH7TiBrnnFGjaxq86be/MiLxckOjBh\r\nFHsv9yXUZ1rspbDS96KNf4mI4HZXntk3FnDYeNN3cUePVUhacCbmH+Q40Puj\r\ni2MOKRaR/P7a/xdjQGAhVDpzCOJ23vBMeh5j+ZEritAoLnvlWKwSJR2PBdy4\r\n96fFWVZcxTYM9thlT6F9ewxXtVFU2DSECqV4nT52Ihw1QKY56SDb6qVLw09R\r\n8p0/iGisWDRmrBdh6A1ocD7BBHkI/g+l7ltm9vqrjWQL5aZ8/7Q4qO3HK+ns\r\nZR7limsBiQTWVTQaWgqKIbUIHYliEy/Y14bzFfN+9xxpRd4kUPl/QXo3mkoB\r\n8JUj6zfjdu3Z5Ihkv4gnvYk2eK6cxGzY8WVXHYkAZqDs/LJeeDk4U/Ikdy1n\r\n17Z5++FVLWHnV970tphN/z4QQ9GNIhYhuZb9qCo2RRtVJQgO4pq1EnX8wfQU\r\nSEcrE1MQcoXcXH2pLRgroB0mv7riKxtCsAc46JdER0KlIF/NYFsP/U4+c6yF\r\nd5Zzt+THRE7LxrZu4OooXJ4gnPvwDuUqAJOZRer9xFTqyvvlT4q7hoE4eS2X\r\nMaaWqDmpHvWaD0YQ9eCf1JOLtzLqlstgWwY=\r\n=MrAo\r\n-----END PGP SIGNATURE-----\r\n"
      },
      "_npmUser": {
        "name": "sindresorhus",
        "email": "sindresorhus@gmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "sindresorhus",
          "email": "sindresorhus@gmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages",
        "tmp": "tmp/function-timeout_0.1.1_1656460245514_0.4325109032765051"
      },
      "_hasShrinkwrap": false
    },
    "1.0.0": {
      "name": "function-timeout",
      "version": "1.0.0",
      "description": "Make a synchronous function have a timeout",
      "license": "MIT",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/sindresorhus/function-timeout.git"
      },
      "funding": "https://github.com/sponsors/sindresorhus",
      "author": {
        "name": "Sindre Sorhus",
        "email": "sindresorhus@gmail.com",
        "url": "https://sindresorhus.com"
      },
      "type": "module",
      "exports": {
        "types": "./index.d.ts",
        "node": "./index.js",
        "default": "./browser.js"
      },
      "engines": {
        "node": ">=18"
      },
      "scripts": {
        "test": "xo && ava && tsd"
      },
      "keywords": [
        "function",
        "synchronous",
        "timeout",
        "time",
        "out",
        "cancel",
        "expire",
        "abort",
        "regex",
        "regexp",
        "redos",
        "security",
        "func",
        "fn",
        "script",
        "execute",
        "halt",
        "termination"
      ],
      "devDependencies": {
        "ava": "^5.3.1",
        "in-range": "^3.0.0",
        "time-span": "^5.1.0",
        "tsd": "^0.29.0",
        "xo": "^0.56.0"
      },
      "types": "./index.d.ts",
      "gitHead": "dfc2e4a2a1773a8bc8d53132cfe362d56c5d0739",
      "bugs": {
        "url": "https://github.com/sindresorhus/function-timeout/issues"
      },
      "homepage": "https://github.com/sindresorhus/function-timeout#readme",
      "_id": "function-timeout@1.0.0",
      "_nodeVersion": "18.18.2",
      "_npmVersion": "9.2.0",
      "dist": {
        "integrity": "sha512-WLrn66AAnPhguecuOOECspA4Tsc1oC2bYfqGiPx9GmS6Oh4pVrtiPPn1oAfn7nMLpfvzyoTzzK16YhT9UwSX3w==",
        "shasum": "a0197b49d669a5add7a56dd67abc517d226f1fe7",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/function-timeout/-/function-timeout-1.0.0.tgz",
        "fileCount": 6,
        "unpackedSize": 5909,
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEYCIQCro29VXGNfznP0xROKXR7b31jXsipFBVjNuuHXMA8EIQIhALNiDlPBLlqg6W7O+Ppch3zMqE0UO80FIjbjXlqnLW5X"
          }
        ]
      },
      "_npmUser": {
        "name": "sindresorhus",
        "email": "sindresorhus@gmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "sindresorhus",
          "email": "sindresorhus@gmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages",
        "tmp": "tmp/function-timeout_1.0.0_1699106336551_0.8912591252975248"
      },
      "_hasShrinkwrap": false
    },
    "1.0.1": {
      "name": "function-timeout",
      "version": "1.0.1",
      "description": "Make a synchronous function have a timeout",
      "license": "MIT",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/sindresorhus/function-timeout.git"
      },
      "funding": "https://github.com/sponsors/sindresorhus",
      "author": {
        "name": "Sindre Sorhus",
        "email": "sindresorhus@gmail.com",
        "url": "https://sindresorhus.com"
      },
      "type": "module",
      "exports": {
        "types": "./index.d.ts",
        "node": "./index.js",
        "default": "./browser.js"
      },
      "sideEffects": false,
      "engines": {
        "node": ">=18"
      },
      "scripts": {
        "test": "xo && ava && tsd"
      },
      "keywords": [
        "function",
        "synchronous",
        "timeout",
        "time",
        "out",
        "cancel",
        "expire",
        "abort",
        "regex",
        "regexp",
        "redos",
        "security",
        "func",
        "fn",
        "script",
        "execute",
        "halt",
        "termination"
      ],
      "devDependencies": {
        "ava": "^5.3.1",
        "in-range": "^3.0.0",
        "time-span": "^5.1.0",
        "tsd": "^0.29.0",
        "xo": "^0.56.0"
      },
      "types": "./index.d.ts",
      "gitHead": "dcf1b5c856557450a1122c4dd5f4498d2645001f",
      "bugs": {
        "url": "https://github.com/sindresorhus/function-timeout/issues"
      },
      "homepage": "https://github.com/sindresorhus/function-timeout#readme",
      "_id": "function-timeout@1.0.1",
      "_nodeVersion": "18.18.2",
      "_npmVersion": "9.2.0",
      "dist": {
        "integrity": "sha512-6yPMImFFuaMPNaTMTBuolA8EanHJWF5Vju0NHpObRURT105J6x1Mf2a7J4P7Sqk2xDxv24N5L0RatEhTBhNmdA==",
        "shasum": "fd379f96501e536617a89ae080d44539ed805f63",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/function-timeout/-/function-timeout-1.0.1.tgz",
        "fileCount": 6,
        "unpackedSize": 6114,
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIHvzWh4l7SMmpQ/HYhizA8iM1AyAUxUQ1O7Kgo8AtsV5AiEAtueHszwtJK5Q19c9fgMIhV6GCi3WnndV6HuvdKLbbU0="
          }
        ]
      },
      "_npmUser": {
        "name": "sindresorhus",
        "email": "sindresorhus@gmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "sindresorhus",
          "email": "sindresorhus@gmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages",
        "tmp": "tmp/function-timeout_1.0.1_1699558758958_0.2950830782318752"
      },
      "_hasShrinkwrap": false
    },
    "1.0.2": {
      "name": "function-timeout",
      "version": "1.0.2",
      "description": "Make a synchronous function have a timeout",
      "license": "MIT",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/sindresorhus/function-timeout.git"
      },
      "funding": "https://github.com/sponsors/sindresorhus",
      "author": {
        "name": "Sindre Sorhus",
        "email": "sindresorhus@gmail.com",
        "url": "https://sindresorhus.com"
      },
      "type": "module",
      "exports": {
        "types": "./index.d.ts",
        "node": "./index.js",
        "default": "./browser.js"
      },
      "sideEffects": false,
      "engines": {
        "node": ">=18"
      },
      "scripts": {
        "test": "xo && ava && tsd"
      },
      "keywords": [
        "function",
        "synchronous",
        "timeout",
        "time",
        "out",
        "cancel",
        "expire",
        "abort",
        "regex",
        "regexp",
        "redos",
        "security",
        "func",
        "fn",
        "script",
        "execute",
        "halt",
        "termination"
      ],
      "devDependencies": {
        "ava": "^5.3.1",
        "in-range": "^3.0.0",
        "time-span": "^5.1.0",
        "tsd": "^0.29.0",
        "xo": "^0.56.0"
      },
      "_id": "function-timeout@1.0.2",
      "gitHead": "12471c7f085b034c3b2432a223376e60173ec43a",
      "types": "./index.d.ts",
      "bugs": {
        "url": "https://github.com/sindresorhus/function-timeout/issues"
      },
      "homepage": "https://github.com/sindresorhus/function-timeout#readme",
      "_nodeVersion": "22.1.0",
      "_npmVersion": "10.6.0",
      "dist": {
        "integrity": "sha512-939eZS4gJ3htTHAldmyyuzlrD58P03fHG49v2JfFXbV6OhvZKRC9j2yAtdHw/zrp2zXHuv05zMIy40F0ge7spA==",
        "shasum": "e5a7b6ffa523756ff20e1231bbe37b5f373aadd5",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/function-timeout/-/function-timeout-1.0.2.tgz",
        "fileCount": 6,
        "unpackedSize": 6115,
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEQCIQC9uWZVCW5+1NN3WCiIuvBMkRutFxQ7rG44Y2fLEWWl1AIfBtg9mEwZQp0SEZj2vFi92s9dN1am853+WdwoHctXjw=="
          }
        ]
      },
      "_npmUser": {
        "name": "sindresorhus",
        "email": "sindresorhus@gmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "sindresorhus",
          "email": "sindresorhus@gmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages",
        "tmp": "tmp/function-timeout_1.0.2_1715967003799_0.03519201814812045"
      },
      "_hasShrinkwrap": false
    }
  },
  "name": "function-timeout",
  "time": {
    "created": "2022-06-03T09:58:22.460Z",
    "0.1.0": "2022-06-03T09:58:22.569Z",
    "modified": "2026-09-27T21:44:35.338Z",
    "0.1.1": "2022-06-28T23:50:45.701Z",
    "1.0.0": "2023-11-04T13:58:56.733Z",
    "1.0.1": "2023-11-09T19:39:19.141Z",
    "1.0.2": "2024-05-17T17:30:03.940Z"
  },
  "readmeFilename": "readme.md",
  "homepage": "https://github.com/sindresorhus/function-timeout#readme"
}